Skip to content

Commit

Permalink
chore: Update test assertion and regen approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanmenzel committed Jan 8, 2025
1 parent 69052e8 commit aff7644
Show file tree
Hide file tree
Showing 19 changed files with 818 additions and 290 deletions.
2 changes: 1 addition & 1 deletion src/util/arc4-signature-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('arc4 signature parser', () => {
['uint2', 'n must be between 8 and 512, and a multiple of 8', 0],
['(uint8,uint2)', 'n must be between 8 and 512, and a multiple of 8', 7],
['uint8[', "Expecting character ']', but got end of input.", 6],
['uint8]', "Expecting ',', '[', or ')', but got ]", 5],
['uint8]', "Expecting ',', '[', or ')', but got ]", 6],
['uint8,uint8', 'Signature contained more than one type. Wrap multiple types in parentheses to declare a tuple type', 0],
['(uint8', 'Tuple has not been closed', 6],
['(uint8,bool))', "Char ')' has no matching opening '('", 13],
Expand Down
6 changes: 3 additions & 3 deletions tests/approvals/out/abi-decorators/abi-decorators.awst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract AbiDecorators
return 5
}

methodWithDefaults(): uint64
methodWithDefaults(a: uint64, b: uint64, c: uint64): uint64
{
return a * b + c
}
Expand All @@ -57,12 +57,12 @@ contract OverloadedMethods
return True
}

doThingOne(): uint64
doThingOne(x: uint64): uint64
{
return x
}

doThingTwo(): uint64
doThingTwo(x: uint64, y: uint64): uint64
{
return x * y
}
Expand Down
2 changes: 1 addition & 1 deletion tests/approvals/out/accounts/accounts.awst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract AccountsContract
return True
}

getAccountInfo(): getAccountInfoResult{ bytes: bytes, balance: uint64, minBalance: uint64, authAddress: bytes, totalNumUint: uint64, totalNumByteSlice: uint64, totalExtraAppPages: uint64, totalAppsCreated: uint64, totalAppsOptedIn: uint64, totalAssetsCreated: uint64, totalAssets: uint64, totalBoxes: uint64, totalBoxBytes: uint64, isOptInApp: bool, isOptInAsset: bool }
getAccountInfo(account: account, asset: asset): getAccountInfoResult{ bytes: bytes, balance: uint64, minBalance: uint64, authAddress: bytes, totalNumUint: uint64, totalNumByteSlice: uint64, totalExtraAppPages: uint64, totalAppsCreated: uint64, totalAppsOptedIn: uint64, totalAssetsCreated: uint64, totalAssets: uint64, totalBoxes: uint64, totalBoxBytes: uint64, isOptInApp: bool, isOptInAsset: bool }
{
ensure_budget(1400, 0)
return { bytes: (#0 = { bytes: reinterpret_cast<bytes>(account), balance: checked_maybe(acct_params_get<AcctBalance>(account), comment=account funded), minBalance: checked_maybe(acct_params_get<AcctMinBalance>(account), comment=account funded), authAddress: reinterpret_cast<bytes>(checked_maybe(acct_params_get<AcctAuthAddr>(account), comment=account funded)), totalNumUint: checked_maybe(acct_params_get<AcctTotalNumUint>(account), comment=account funded), totalNumByteSlice: checked_maybe(acct_params_get<AcctTotalNumByteSlice>(account), comment=account funded), totalExtraAppPages: checked_maybe(acct_params_get<AcctTotalExtraAppPages>(account), comment=account funded), totalAppsCreated: checked_maybe(acct_params_get<AcctTotalAppsCreated>(account), comment=account funded), totalAppsOptedIn: checked_maybe(acct_params_get<AcctTotalAppsOptedIn>(account), comment=account funded), totalAssetsCreated: checked_maybe(acct_params_get<AcctTotalAssetsCreated>(account), comment=account funded), totalAssets: checked_maybe(acct_params_get<AcctTotalAssets>(account), comment=account funded), totalBoxes: checked_maybe(acct_params_get<AcctTotalBoxes>(account), comment=account funded), totalBoxBytes: checked_maybe(acct_params_get<AcctTotalBoxBytes>(account), comment=account funded), isOptInApp: app_opted_in(account, global<CurrentApplicationID>()), isOptInAsset: asset_holding_get<AssetBalance>(account, asset).1 }).bytes, balance: #0.balance, minBalance: #0.minBalance, authAddress: #0.authAddress, totalNumUint: #0.totalNumUint, totalNumByteSlice: #0.totalNumByteSlice, totalExtraAppPages: #0.totalExtraAppPages, totalAppsCreated: #0.totalAppsCreated, totalAppsOptedIn: #0.totalAppsOptedIn, totalAssetsCreated: #0.totalAssetsCreated, totalAssets: #0.totalAssets, totalBoxes: #0.totalBoxes, totalBoxBytes: #0.totalBoxBytes, isOptInApp: #0.isOptInApp, isOptInAsset: #0.isOptInAsset }
Expand Down
145 changes: 104 additions & 41 deletions tests/approvals/out/arc-28-events/EventEmitter.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,63 @@

// @algorandfoundation/algorand-typescript/arc4/index.d.ts::Contract.approvalProgram() -> uint64:
main:
intcblock 0 1 3
intcblock 0 1 3 4
bytecblock 0x 0x0b6325ed 0x00 0xa313c066

main_block@1:
// tests/approvals/arc-28-events.algo.ts:12
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txn NumAppArgs
intc_0 // 0
!=
bz main_bare_routing@7
bz main_bare_routing@8

main_abi_routing@2:
// tests/approvals/arc-28-events.algo.ts:12
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txna ApplicationArgs 0
pushbytes 0x8769b79a // method "emitSwapped(uint8,uint8)void"
pushbytes 0xf14889d7 // method "emitCustom(string,bool)void"
uncover 2
match main_emitSwapped_route@3 main_emitCustom_route@4
pushbytes 0xd4c97c9c // method "emitDynamicBytes(byte[],byte[])void"
uncover 3
match main_emitSwapped_route@3 main_emitCustom_route@4 main_emitDynamicBytes_route@5

main_switch_case_default@5:
main_switch_case_default@6:

main_switch_case_next@6:
main_switch_case_next@7:

main_after_if_else@11:
// tests/approvals/arc-28-events.algo.ts:12
main_after_if_else@12:
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
intc_0 // 0

main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@12:
main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@13:
return

main_emitDynamicBytes_route@5:
// tests/approvals/arc-28-events.algo.ts:37
// emitDynamicBytes(x: bytes, y: DynamicBytes) {
txn OnCompletion
intc_0 // NoOp
==
assert // OnCompletion is not NoOp
txn ApplicationID
intc_0 // 0
!=
assert // can only call when not creating
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txna ApplicationArgs 1
extract 2 0
txna ApplicationArgs 2
// tests/approvals/arc-28-events.algo.ts:37
// emitDynamicBytes(x: bytes, y: DynamicBytes) {
callsub emitDynamicBytes
intc_1 // 1
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@13

main_emitCustom_route@4:
// tests/approvals/arc-28-events.algo.ts:31
// tests/approvals/arc-28-events.algo.ts:32
// emitCustom(arg0: string, arg1: boolean) {
txn OnCompletion
intc_0 // NoOp
Expand All @@ -46,21 +69,21 @@ main_emitCustom_route@4:
intc_0 // 0
!=
assert // can only call when not creating
// tests/approvals/arc-28-events.algo.ts:12
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txna ApplicationArgs 1
extract 2 0
txna ApplicationArgs 2
intc_0 // 0
getbit
// tests/approvals/arc-28-events.algo.ts:31
// tests/approvals/arc-28-events.algo.ts:32
// emitCustom(arg0: string, arg1: boolean) {
callsub emitCustom
intc_1 // 1
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@12
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@13

main_emitSwapped_route@3:
// tests/approvals/arc-28-events.algo.ts:13
// tests/approvals/arc-28-events.algo.ts:14
// emitSwapped(a: UintN8, b: UintN8) {
txn OnCompletion
intc_0 // NoOp
Expand All @@ -70,47 +93,47 @@ main_emitSwapped_route@3:
intc_0 // 0
!=
assert // can only call when not creating
// tests/approvals/arc-28-events.algo.ts:12
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txna ApplicationArgs 1
txna ApplicationArgs 2
// tests/approvals/arc-28-events.algo.ts:13
// tests/approvals/arc-28-events.algo.ts:14
// emitSwapped(a: UintN8, b: UintN8) {
callsub emitSwapped
intc_1 // 1
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@12
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@13

main_bare_routing@7:
// tests/approvals/arc-28-events.algo.ts:12
main_bare_routing@8:
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txn OnCompletion
intc_0 // 0
swap
match main___algots__.defaultCreate@8
match main___algots__.defaultCreate@9

main_switch_case_default@9:
main_switch_case_default@10:

main_switch_case_next@10:
b main_after_if_else@11
main_switch_case_next@11:
b main_after_if_else@12

main___algots__.defaultCreate@8:
// tests/approvals/arc-28-events.algo.ts:12
main___algots__.defaultCreate@9:
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
txn ApplicationID
intc_0 // 0
==
assert // can only call when creating
callsub __algots__.defaultCreate
intc_1 // 1
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@12
b main_after_inlined_tests/approvals/arc-28-events.algo.ts::EventEmitter.__puya_arc4_router__@13


// tests/approvals/arc-28-events.algo.ts::EventEmitter.emitSwapped(a: bytes, b: bytes) -> void:
emitSwapped:
// tests/approvals/arc-28-events.algo.ts:13
// tests/approvals/arc-28-events.algo.ts:14
// emitSwapped(a: UintN8, b: UintN8) {
proto 2 0
// tests/approvals/arc-28-events.algo.ts:14
// tests/approvals/arc-28-events.algo.ts:15
// emit<Swapped>({ a: b, b: a })
bytec_0 // 0x
frame_dig -1
Expand All @@ -121,12 +144,12 @@ emitSwapped:
swap
concat
log
// tests/approvals/arc-28-events.algo.ts:16
// tests/approvals/arc-28-events.algo.ts:17
// const x: Swapped = { a: b, b: a }
frame_dig -1
frame_dig -2
swap
// tests/approvals/arc-28-events.algo.ts:17
// tests/approvals/arc-28-events.algo.ts:18
// emit(x)
bytec_0 // 0x
swap
Expand All @@ -137,7 +160,7 @@ emitSwapped:
swap
concat
log
// tests/approvals/arc-28-events.algo.ts:19-22
// tests/approvals/arc-28-events.algo.ts:20-23
// const y = new SwappedArc4({
// a: b,
// b: a,
Expand All @@ -147,13 +170,13 @@ emitSwapped:
concat
frame_dig -2
concat
// tests/approvals/arc-28-events.algo.ts:23
// tests/approvals/arc-28-events.algo.ts:24
// emit(y)
pushbytes 0x441e2cd8 // method "SwappedArc4(uint8,uint8)"
swap
concat
log
// tests/approvals/arc-28-events.algo.ts:25
// tests/approvals/arc-28-events.algo.ts:26
// emit('Swapped', b, a)
bytec_0 // 0x
frame_dig -1
Expand All @@ -164,7 +187,7 @@ emitSwapped:
swap
concat
log
// tests/approvals/arc-28-events.algo.ts:27
// tests/approvals/arc-28-events.algo.ts:28
// emit('Swapped(uint8,uint8)', b, a)
bytec_0 // 0x
frame_dig -1
Expand All @@ -175,7 +198,7 @@ emitSwapped:
swap
concat
log
// tests/approvals/arc-28-events.algo.ts:28
// tests/approvals/arc-28-events.algo.ts:29
// emit('Swapped((uint8,uint8),uint8)', [b, b] as const, a)
bytec_0 // 0x
frame_dig -1
Expand All @@ -196,10 +219,10 @@ emitSwapped:

// tests/approvals/arc-28-events.algo.ts::EventEmitter.emitCustom(arg0: bytes, arg1: uint64) -> void:
emitCustom:
// tests/approvals/arc-28-events.algo.ts:31
// tests/approvals/arc-28-events.algo.ts:32
// emitCustom(arg0: string, arg1: boolean) {
proto 2 0
// tests/approvals/arc-28-events.algo.ts:32
// tests/approvals/arc-28-events.algo.ts:33
// emit('Custom', arg0, arg1)
frame_dig -2
len
Expand All @@ -225,7 +248,7 @@ emitCustom:
swap
concat
log
// tests/approvals/arc-28-events.algo.ts:33
// tests/approvals/arc-28-events.algo.ts:34
// emit('Custom(string,bool)', arg0, arg1)
frame_dig -2
len
Expand Down Expand Up @@ -254,9 +277,49 @@ emitCustom:
retsub


// tests/approvals/arc-28-events.algo.ts::EventEmitter.emitDynamicBytes(x: bytes, y: bytes) -> void:
emitDynamicBytes:
// tests/approvals/arc-28-events.algo.ts:37
// emitDynamicBytes(x: bytes, y: DynamicBytes) {
proto 2 0
// tests/approvals/arc-28-events.algo.ts:38
// emit('DB(byte[],byte[])', x, y)
frame_dig -2
len
itob
extract 6 2
frame_dig -2
concat
intc_3 // 4
itob
extract 6 2
bytec_0 // 0x
swap
concat
swap
dup
len
intc_3 // 4
+
itob
extract 6 2
uncover 2
swap
concat
swap
concat
frame_dig -1
concat
pushbytes 0x4524e1dd // method "DB(byte[],byte[])"
swap
concat
log
retsub


// tests/approvals/arc-28-events.algo.ts::EventEmitter.__algots__.defaultCreate() -> void:
__algots__.defaultCreate:
// tests/approvals/arc-28-events.algo.ts:12
// tests/approvals/arc-28-events.algo.ts:13
// class EventEmitter extends Contract {
proto 0 0
retsub
Loading

0 comments on commit aff7644

Please sign in to comment.