Explicity contract encoding tests (non e2e) (#1040)
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"messages": [
|
||||
{
|
||||
"name": "primitive",
|
||||
"selector": 1111,
|
||||
"selector": 11111,
|
||||
"mutates": true,
|
||||
"args": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user