Skip to content

Commit 7967bbb

Browse files
committed
chore: pr feedback
1 parent 734c1bd commit 7967bbb

File tree

1 file changed

+86
-28
lines changed

1 file changed

+86
-28
lines changed

src/transaction/transaction.spec.ts

Lines changed: 86 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,24 @@ describe('access references', () => {
11691169
let appClient: AppClient
11701170
let externalClient: AppClient
11711171

1172+
let alice: algosdk.Address
1173+
let bob: algosdk.Address
1174+
let charlie: algosdk.Address
1175+
let dan: algosdk.Address
1176+
let eve: algosdk.Address
1177+
let frank: algosdk.Address
1178+
let grace: algosdk.Address
1179+
let heidi: algosdk.Address
1180+
let ivan: algosdk.Address
1181+
let judy: algosdk.Address
1182+
let mallory: algosdk.Address
1183+
let niaj: algosdk.Address
1184+
let oscar: algosdk.Address
1185+
let peggy: algosdk.Address
1186+
let quentin: algosdk.Address
1187+
let ruth: algosdk.Address
1188+
let dave: algosdk.Address
1189+
11721190
beforeEach(fixture.newScope)
11731191

11741192
beforeAll(async () => {
@@ -1192,7 +1210,25 @@ describe('access references', () => {
11921210
appId: (await appClient.getGlobalState()).externalAppID.value as bigint,
11931211
defaultSender: testAccount,
11941212
})
1195-
})
1213+
1214+
alice = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1215+
bob = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1216+
charlie = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1217+
dan = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1218+
eve = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1219+
frank = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1220+
grace = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1221+
heidi = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1222+
ivan = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1223+
judy = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1224+
mallory = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1225+
niaj = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1226+
oscar = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1227+
peggy = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1228+
quentin = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1229+
ruth = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1230+
dave = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(1) })
1231+
}, 20_000) // Account generation and funding can be slow
11961232

11971233
test('address reference enables access', async () => {
11981234
const alice = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
@@ -1205,16 +1241,7 @@ describe('access references', () => {
12051241
await appClient.send.bare.call({ args: [method, aliceAddr], populateAppCallResources: false, accessReferences: [{ address: alice }] })
12061242
})
12071243

1208-
test('only 8 non access reference accounts can be supplied', async () => {
1209-
const alice = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1210-
const bob = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1211-
const charlie = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1212-
const dan = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1213-
const eve = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1214-
const frank = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1215-
const grace = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1216-
const heidi = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1217-
1244+
test('up to 8 non access reference accounts can be used', async () => {
12181245
const method = appClient.getABIMethod('addressBalance').getSelector()
12191246

12201247
const addressType = new ABIAddressType()
@@ -1227,24 +1254,22 @@ describe('access references', () => {
12271254
})
12281255
})
12291256

1230-
test('only 16 access addresses can be supplied', async () => {
1231-
const alice = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1232-
const bob = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1233-
const charlie = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1234-
const dan = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1235-
const eve = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1236-
const frank = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1237-
const grace = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1238-
const heidi = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1239-
const ivan = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1240-
const judy = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1241-
const mallory = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1242-
const niaj = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1243-
const oscar = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1244-
const peggy = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1245-
const quentin = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1246-
const ruth = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
1257+
test('throws when more than 8 non access reference accounts are supplied', async () => {
1258+
const method = appClient.getABIMethod('addressBalance').getSelector()
1259+
1260+
const addressType = new ABIAddressType()
1261+
const aliceAddr = addressType.encode(alice)
12471262

1263+
await expect(
1264+
appClient.send.bare.call({
1265+
args: [method, aliceAddr],
1266+
populateAppCallResources: false,
1267+
accountReferences: [alice, bob, charlie, dan, eve, frank, grace, heidi, ivan],
1268+
}),
1269+
).rejects.toThrow(/max number of accounts is 8/)
1270+
})
1271+
1272+
test('up to 16 access addresses can be used', async () => {
12481273
const method = appClient.getABIMethod('addressBalance').getSelector()
12491274

12501275
const addressType = new ABIAddressType()
@@ -1274,6 +1299,39 @@ describe('access references', () => {
12741299
})
12751300
})
12761301

1302+
test('throws when more than 16 access addresses are supplied', async () => {
1303+
const method = appClient.getABIMethod('addressBalance').getSelector()
1304+
1305+
const addressType = new ABIAddressType()
1306+
const aliceAddr = addressType.encode(alice)
1307+
1308+
await expect(
1309+
appClient.send.bare.call({
1310+
args: [method, aliceAddr],
1311+
populateAppCallResources: false,
1312+
accessReferences: [
1313+
{ address: alice },
1314+
{ address: bob },
1315+
{ address: charlie },
1316+
{ address: dan },
1317+
{ address: eve },
1318+
{ address: frank },
1319+
{ address: grace },
1320+
{ address: heidi },
1321+
{ address: ivan },
1322+
{ address: judy },
1323+
{ address: mallory },
1324+
{ address: niaj },
1325+
{ address: oscar },
1326+
{ address: peggy },
1327+
{ address: quentin },
1328+
{ address: ruth },
1329+
{ address: dave },
1330+
],
1331+
}),
1332+
).rejects.toThrow(/max number of references is 16/)
1333+
})
1334+
12771335
test('app reference enables access', async () => {
12781336
const method = appClient.getABIMethod('externalAppCall').getSelector()
12791337

0 commit comments

Comments
 (0)