Explicity contract encoding tests (non e2e) (#1040)

This commit is contained in:
Jaco Greeff
2019-06-20 14:06:10 +02:00
committed by GitHub
parent 52fc98f1ef
commit d4c408d28b
2 changed files with 20 additions and 1 deletions
+19
View File
@@ -83,6 +83,25 @@ describe('Abi', () => {
'Vec<(u32,u64)>'
);
});
describe('messages', () => {
it('fails when invalid args are supplied', () => {
expect(
() => abi.messages.primitive(false)
).toThrow(/Expected 2 arguments to contract messages.primitive, found 1/);
});
it('encodes primitives correctly', () => {
expect(
abi.messages.primitive(true, 0x12345678)
).toEqual(new Uint8Array([
9 << 2, // total length (4 + 1 + 4)
0x67, 0x2b, 0, 0, // 11111 -> hex (LE)
1, // true
0x78, 0x56, 0x34, 0x12 // u32
]));
});
});
});
describe('erc20', () => {
+1 -1
View File
@@ -6,7 +6,7 @@
"messages": [
{
"name": "primitive",
"selector": 1111,
"selector": 11111,
"mutates": true,
"args": [
{