Skip to content

Commit 3e87f0d

Browse files
committed
chore: pr feedback
1 parent 734c1bd commit 3e87f0d

File tree

1 file changed

+85
-28
lines changed

1 file changed

+85
-28
lines changed

src/transaction/transaction.spec.ts

Lines changed: 85 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,8 +1210,25 @@ describe('access references', () => {
11921210
appId: (await appClient.getGlobalState()).externalAppID.value as bigint,
11931211
defaultSender: testAccount,
11941212
})
1195-
})
11961213

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
11971232
test('address reference enables access', async () => {
11981233
const alice = await fixture.context.generateAccount({ initialFunds: AlgoAmount.Algo(0.1) })
11991234

@@ -1205,16 +1240,7 @@ describe('access references', () => {
12051240
await appClient.send.bare.call({ args: [method, aliceAddr], populateAppCallResources: false, accessReferences: [{ address: alice }] })
12061241
})
12071242

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-
1243+
test('up to 8 non access reference accounts can be used', async () => {
12181244
const method = appClient.getABIMethod('addressBalance').getSelector()
12191245

12201246
const addressType = new ABIAddressType()
@@ -1227,24 +1253,22 @@ describe('access references', () => {
12271253
})
12281254
})
12291255

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) })
1256+
test('throws when more than 8 non access reference accounts are supplied', async () => {
1257+
const method = appClient.getABIMethod('addressBalance').getSelector()
1258+
1259+
const addressType = new ABIAddressType()
1260+
const aliceAddr = addressType.encode(alice)
12471261

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

12501274
const addressType = new ABIAddressType()
@@ -1274,6 +1298,39 @@ describe('access references', () => {
12741298
})
12751299
})
12761300

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

0 commit comments

Comments
 (0)