Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added tests for new abi encoding features #4

Merged
merged 3 commits into from
Nov 6, 2018

Conversation

xmxanuel
Copy link
Member

@xmxanuel xmxanuel commented Nov 6, 2018

I added the tests with the correct encoding for the needed types.

Currently for all dynamic arrays (int,byte,address,...) two ways are supported.

option 1
len
array[0]
...
array[n-1]
option 2
offset
len
array[0]
...
array[n-1]

I changed the tests for all dynamic arrays to option 2 to be consistent with web3.js.

I cross-checked the encodings with latest web3.js version.

I added new tests for string[] and bytes32[][]

@@ -42,7 +42,7 @@ func TestPack(t *testing.T) {
{
"uint8[]",
[]uint8{1, 2},
common.Hex2Bytes("000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002"),
common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002"),
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all these lines only 0000000000000000000000000000000000000000000000000000000000000020 has been added in the beginning

},
{

//web3.eth.abi.encodeParameter('bytes32[][]', [['0x0100000000000000000000000000000000000000000000000000000000000000',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the web3.js calls as a comment for easier cross checking. We can remove them later

@xmxanuel xmxanuel merged commit ded4e8a into centrifuge:master Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant