diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2019-02-05 08:25:00 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-02-05 08:32:14 +0800 |
commit | db900d180cf7a5b9affbe7ff486b6e3e1e038e84 (patch) | |
tree | e6280a109ab7f2d874d7e9dfcf8ded74056aef85 /packages/utils/test/abi_encoder | |
parent | 74293d5bc844035781d65aa85051ef3bbb7b8b1a (diff) | |
download | dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.gz dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.bz2 dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.lz dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.xz dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.tar.zst dexon-0x-contracts-db900d180cf7a5b9affbe7ff486b6e3e1e038e84.zip |
Decode NULL as false
Diffstat (limited to 'packages/utils/test/abi_encoder')
-rw-r--r-- | packages/utils/test/abi_encoder/evm_data_types_test.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/utils/test/abi_encoder/evm_data_types_test.ts b/packages/utils/test/abi_encoder/evm_data_types_test.ts index 4814ce28b..c146890e0 100644 --- a/packages/utils/test/abi_encoder/evm_data_types_test.ts +++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts @@ -489,6 +489,24 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const argsEncodedFromSignature = dataTypeFromSignature.encode(args); expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); + it('Null should decode as False', async () => { + // Hack @hysz: there are some cases where `false` is encoded as 0x instead of 0x0. + // 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 = '0x'; + const expectedEncodedArgs = '0x0000000000000000000000000000000000000000000000000000000000000000'; + // Decode Encoded Args and validate result + const decodedArgs = dataType.decode(encodedArgs); + expect(decodedArgs).to.be.deep.equal(args); + // Validate signature + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); + }); }); describe('Integer', () => { |