Skip to content

Commit

Permalink
add related repro test
Browse files Browse the repository at this point in the history
Expected: [ 1n, 2n, 3n, false, [ "abcd", "efgh" ] ]
Received: undefined
  • Loading branch information
joe-p committed Dec 17, 2024
1 parent ab4af1f commit 2ea6009
Show file tree
Hide file tree
Showing 7 changed files with 1,041 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/abi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,12 @@ describe('ABI', function () {
test('nestedArrayInBox', async () => {
const { appClient } = await compileAndCreate('nestedArrayInBox');

expect(await runMethod(appClient, 'nestedArrayInBox')).toEqual([true, 1n, 2n]);
expect(await runMethod(appClient, 'nestedArrayInBox')).toEqual([['abcd', 'efgh'], 1n, 2n, 3n, false]);
});

test('nestedArrayInBoxLast', async () => {
const { appClient } = await compileAndCreate('nestedArrayInBoxLast');

expect(await runMethod(appClient, 'nestedArrayInBoxLast')).toEqual([1n, 2n, 3n, false, ['abcd', 'efgh']]);

Check failure on line 940 in tests/abi.test.ts

View workflow job for this annotation

GitHub Actions / test

error: expect(received).toEqual(expected)

Expected: [ 1n, 2n, 3n, false, [ "abcd", "efgh" ] ] Received: undefined at /home/runner/work/TEALScript/TEALScript/tests/abi.test.ts:940:64
});
});
22 changes: 22 additions & 0 deletions tests/contracts/abi.algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1647,3 +1647,25 @@ class ABITestNestedArrayInBox extends Contract {
};
}
}

type T11 = {
u64a: uint64;
u64b: uint64;
u64c: uint64;
boolValue: boolean;
bytes4Array: bytes<4>[];
};

class ABITestNestedArrayInBoxLast extends Contract {
bMap = BoxMap<bytes, T11>();

nestedArrayInBoxLast() {
this.bMap('bmap').value = {
bytes4Array: ['abcd' as bytes<4>, 'efgh' as bytes<4>],
u64a: 1,
u64b: 2,
u64c: 3,
boolValue: false,
};
}
}
122 changes: 122 additions & 0 deletions tests/contracts/artifacts/ABITestNestedArrayInBoxLast.approval.teal
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#pragma version 10
intcblock 0 1
bytecblock 0x626d6170 0x

// This TEAL was generated by TEALScript v0.106.0
// https://github.com/algorandfoundation/TEALScript

// This contract is compliant with and/or implements the following ARCs: [ ARC4 ]

// The following ten lines of TEAL handle initial program flow
// This pattern is used to make it easy for anyone to parse the start of the program and determine if a specific action is allowed
// Here, action refers to the OnComplete in combination with whether the app is being created or called
// Every possible action for this contract is represented in the switch statement
// If the action is not implemented in the contract, its respective branch will be "*NOT_IMPLEMENTED" which just contains "err"
txn ApplicationID
!
pushint 6
*
txn OnCompletion
+
switch *call_NoOp *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *create_NoOp *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED

*NOT_IMPLEMENTED:
// The requested action is not implemented in this contract. Are you using the correct OnComplete? Did you set your app ID?
err

// nestedArrayInBoxLast()void
*abi_route_nestedArrayInBoxLast:
// execute nestedArrayInBoxLast()void
callsub nestedArrayInBoxLast
intc 1 // 1
return

// nestedArrayInBoxLast(): void
nestedArrayInBoxLast:
proto 0 0

// tests/contracts/abi.algo.ts:1663
// this.bMap('bmap').value = {
// bytes4Array: ['abcd' as bytes<4>, 'efgh' as bytes<4>],
// u64a: 1,
// u64b: 2,
// u64c: 3,
// boolValue: false,
// }
bytec 0 // "bmap"
dup
box_del
pop
bytec 1 // initial head
bytec 1 // initial tail
pushbytes 0x001a // initial head offset
pushbytes 0x0000000000000001
callsub *process_static_tuple_element
pushbytes 0x0000000000000002
callsub *process_static_tuple_element
pushbytes 0x0000000000000003
callsub *process_static_tuple_element
pushbytes 0x00
intc 0 // 0
dup
setbit
callsub *process_static_tuple_element
pushbytes 0x00026162636465666768
callsub *process_dynamic_tuple_element
pop // pop head offset
concat // concat head and tail
box_put
retsub

*abi_route_createApplication:
intc 1 // 1
return

*create_NoOp:
pushbytes 0xb8447b36 // method "createApplication()void"
txna ApplicationArgs 0
match *abi_route_createApplication

// this contract does not implement the given ABI method for create NoOp
err

*call_NoOp:
pushbytes 0xfac03883 // method "nestedArrayInBoxLast()void"
txna ApplicationArgs 0
match *abi_route_nestedArrayInBoxLast

// this contract does not implement the given ABI method for call NoOp
err

*process_static_tuple_element:
proto 4 3
frame_dig -4 // tuple head
frame_dig -1 // element
concat
frame_dig -3 // tuple tail
frame_dig -2 // head offset
retsub

*process_dynamic_tuple_element:
proto 4 3
frame_dig -4 // tuple head
frame_dig -2 // head offset
concat
frame_bury -4 // tuple head
frame_dig -1 // element
dup
len
frame_dig -2 // head offset
btoi
+
itob
extract 6 2
frame_bury -2 // head offset
frame_dig -3 // tuple tail
swap
concat
frame_bury -3 // tuple tail
frame_dig -4 // tuple head
frame_dig -3 // tuple tail
frame_dig -2 // head offset
retsub
65 changes: 65 additions & 0 deletions tests/contracts/artifacts/ABITestNestedArrayInBoxLast.arc32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"hints": {
"nestedArrayInBoxLast()void": {
"call_config": {
"no_op": "CALL"
}
},
"createApplication()void": {
"call_config": {
"no_op": "CREATE"
}
}
},
"bare_call_config": {
"no_op": "NEVER",
"opt_in": "NEVER",
"close_out": "NEVER",
"update_application": "NEVER",
"delete_application": "NEVER"
},
"schema": {
"local": {
"declared": {},
"reserved": {}
},
"global": {
"declared": {},
"reserved": {}
}
},
"state": {
"global": {
"num_byte_slices": 0,
"num_uints": 0
},
"local": {
"num_byte_slices": 0,
"num_uints": 0
}
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDEwCmludGNibG9jayAwIDEKYnl0ZWNibG9jayAweDYyNmQ2MTcwIDB4CgovLyBUaGlzIFRFQUwgd2FzIGdlbmVyYXRlZCBieSBURUFMU2NyaXB0IHYwLjEwNi4wCi8vIGh0dHBzOi8vZ2l0aHViLmNvbS9hbGdvcmFuZGZvdW5kYXRpb24vVEVBTFNjcmlwd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nJheUluQm94TGFzdAoKCS8vIHRoaXMgY29udHJhY3QgZG9lcyBub3QgaW1wbGVtZW50IHRoZSBnaXZlbiBBQkkgbWV0aG9kIGZvciBjYWxsIE5vT3AKCWVycgoKKnByb2Nlc3Nfc3RhdGljX3R1cGxlX2VsZW1lbnQ6Cglwcm90byA0IDMKCWZyYW1lX2RpZyAtNCAvLyB0dXBsZSBoZWFkCglmcmFtZV9kaWcgLTEgLy8gZWxlbWVudAoJY29uY2F0CglmcmFtZV9kaWcgLTMgLy8gdHVwbGUgdGFpbAoJZnJhbWVfZGlnIC0yIC8vIGhlYWQgb2Zmc2V0CglyZXRzdWIKCipwcm9jZXNzX2R5bmFtaWNfdHVwbGVfZWxlbWVudDoKCXByb3RvIDQgMwoJZnJhbWVfZGlnIC00IC8vIHR1cGxlIGhlYWQKCWZyYW1lX2RpZyAtMiAvLyBoZWFkIG9mZnNldAoJY29uY2F0CglmcmFtZV9idXJ5IC00IC8vIHR1cGxlIGhlYWQKCWZyYW1lX2RpZyAtMSAvLyBlbGVtZW50CglkdXAKCWxlbgoJZnJhbWVfZGlnIC0yIC8vIGhlYWQgb2Zmc2V0CglidG9pCgkrCglpdG9iCglleHRyYWN0IDYgMgoJZnJhbWVfYnVyeSAtMiAvLyBoZWFkIG9mZnNldAoJZnJhbWVfZGlnIC0zIC8vIHR1cGxlIHRhaWwKCXN3YXAKCWNvbmNhdAoJZnJhbWVfYnVyeSAtMyAvLyB0dXBsZSB0YWlsCglmcmFtZV9kaWcgLTQgLy8gdHVwbGUgaGVhZAoJZnJhbWVfZGlnIC0zIC8vIHR1cGxlIHRhaWwKCWZyYW1lX2RpZyAtMiAvLyBoZWFkIG9mZnNldAoJcmV0c3Vi",
"clear": "I3ByYWdtYSB2ZXJzaW9uIDEw"
},
"contract": {
"name": "ABITestNestedArrayInBoxLast",
"desc": "",
"methods": [
{
"name": "nestedArrayInBoxLast",
"args": [],
"returns": {
"type": "void"
}
},
{
"name": "createApplication",
"args": [],
"returns": {
"type": "void"
}
}
]
}
}
20 changes: 20 additions & 0 deletions tests/contracts/artifacts/ABITestNestedArrayInBoxLast.arc4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ABITestNestedArrayInBoxLast",
"desc": "",
"methods": [
{
"name": "nestedArrayInBoxLast",
"args": [],
"returns": {
"type": "void"
}
},
{
"name": "createApplication",
"args": [],
"returns": {
"type": "void"
}
}
]
}
Loading

0 comments on commit 2ea6009

Please sign in to comment.