diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-20 03:20:35 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:10 +0800 |
commit | b28f26916fc51fa13308f335e3cd0bd5d3b075fc (patch) | |
tree | 49dbc81c3ee70c93c6179488308c1fdda97f3943 /packages/utils/test | |
parent | a2ad15be0dc500fa196021a5b32e80af8500043c (diff) | |
download | dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.tar dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.tar.gz dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.tar.bz2 dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.tar.lz dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.tar.xz dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.tar.zst dexon-sol-tools-b28f26916fc51fa13308f335e3cd0bd5d3b075fc.zip |
Tests for Bool
Diffstat (limited to 'packages/utils/test')
-rw-r--r-- | packages/utils/test/abi_encoder_test.ts | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/packages/utils/test/abi_encoder_test.ts b/packages/utils/test/abi_encoder_test.ts index 5b341545e..123ebe11d 100644 --- a/packages/utils/test/abi_encoder_test.ts +++ b/packages/utils/test/abi_encoder_test.ts @@ -896,24 +896,43 @@ describe.only('ABI Encoder', () => { }); }); - /* - describe('Bool', () => { - const testBoolDataItem = { name: 'testBool', type: 'bool' }; + describe.only('Bool', () => { it('True', async () => { - const boolDataType = new AbiEncoder.Bool(testBoolDataItem); - boolDataType.assignValue(true); - const expectedAbiEncodedBool = '0x0000000000000000000000000000000000000000000000000000000000000001'; - expect(boolDataType.getHexValue()).to.be.equal(expectedAbiEncodedBool); + // Create DataType object + const testDataItem = { name: 'Boolean', type: 'bool' }; + const dataType = new AbiEncoder.Bool(testDataItem); + // Construct args to be encoded + const args = true; + // Encode Args and validate result + const encodedArgs = dataType.encode(args); + const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000001'; + expect(encodedArgs).to.be.equal(expectedEncodedArgs); + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(encodedArgs); + const decodedArgsAsJson = JSON.stringify(decodedArgs); + const argsAsJson = JSON.stringify(args); + expect(decodedArgsAsJson).to.be.equal(argsAsJson); }); it('False', async () => { - const boolDataType = new AbiEncoder.Bool(testBoolDataItem); - boolDataType.assignValue(false); - const expectedAbiEncodedBool = '0x0000000000000000000000000000000000000000000000000000000000000000'; - expect(boolDataType.getHexValue()).to.be.equal(expectedAbiEncodedBool); + // Create DataType object + const testDataItem = { name: 'Boolean', type: 'bool' }; + const dataType = new AbiEncoder.Bool(testDataItem); + // Construct args to be encoded + const args = false; + // Encode Args and validate result + const encodedArgs = dataType.encode(args); + const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000000'; + expect(encodedArgs).to.be.equal(expectedEncodedArgs); + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(encodedArgs); + const decodedArgsAsJson = JSON.stringify(decodedArgs); + const argsAsJson = JSON.stringify(args); + expect(decodedArgsAsJson).to.be.equal(argsAsJson); }); }); + /* describe('Integer', () => { const testIntDataItem = { name: 'testInt', type: 'int' }; it('Positive - Base case', async () => { @@ -1073,5 +1092,5 @@ describe.only('ABI Encoder', () => { '0x000000000000000000000000000000000000000000000000000000000000002861616161616161616161616161616161616161616161616161616161616161616161616161616161000000000000000000000000000000000000000000000000'; expect(stringDataType.getHexValue()).to.be.equal(expectedAbiEncodedString); }); - });*/ + }); */ }); |