diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-12-24 12:50:02 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2019-01-15 02:49:44 +0800 |
commit | 86caa4a0bb82e3ba7d362cca9b75565bf8944952 (patch) | |
tree | 1cddd589130d6844dcb6824d1b4bcf588a8719b5 /packages/utils/test/abi_encoder | |
parent | 6d832deb62cdef38c5fa69169986ef00dbc6e1eb (diff) | |
download | dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.tar dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.tar.gz dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.tar.bz2 dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.tar.lz dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.tar.xz dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.tar.zst dexon-0x-contracts-86caa4a0bb82e3ba7d362cca9b75565bf8944952.zip |
Ran prettier and linter
Diffstat (limited to 'packages/utils/test/abi_encoder')
-rw-r--r-- | packages/utils/test/abi_encoder/evm_data_types_test.ts | 264 | ||||
-rw-r--r-- | packages/utils/test/abi_encoder/methods_test.ts | 6 | ||||
-rw-r--r-- | packages/utils/test/abi_encoder/optimizer_test.ts | 2 |
3 files changed, 140 insertions, 132 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 3c7bafc0a..54d536a7e 100644 --- a/packages/utils/test/abi_encoder/evm_data_types_test.ts +++ b/packages/utils/test/abi_encoder/evm_data_types_test.ts @@ -27,9 +27,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic size; Static elements', async () => { // Create DataType object @@ -46,9 +46,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Fixed size; Dynamic elements', async () => { // Create DataType object @@ -65,9 +65,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic size; Dynamic elements', async () => { // Create DataType object @@ -84,9 +84,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic Size; Multidimensional; Dynamic Elements', async () => { // Create DataType object @@ -106,9 +106,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic Size; Multidimensional; Static Elements', async () => { // Create DataType object @@ -128,9 +128,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static Size; Multidimensional; Static Elements', async () => { // Create DataType object @@ -149,9 +149,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static Size; Multidimensional; Dynamic Elements', async () => { // Create DataType object @@ -170,9 +170,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static size; Too Few Elements', async () => { // Create DataType object @@ -230,9 +230,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args, encodingRules); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args, encodingRules); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Dynamic elements only', async () => { // Create DataType object @@ -254,9 +254,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Static Array', async () => { // Create DataType object @@ -278,9 +278,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Dynamic Array', async () => { // Create DataType object @@ -302,9 +302,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Static Multidimensional Array', async () => { // Create DataType object @@ -328,9 +328,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Nested Dynamic Multidimensional Array', async () => { // Create DataType object @@ -354,9 +354,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Static and dynamic elements mixed', async () => { // Create DataType object @@ -388,9 +388,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs, decodingRules); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Missing Key', async () => { // Create DataType object @@ -424,9 +424,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Invalid Address - input is not valid hex', async () => { // Create DataType object @@ -467,9 +467,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('False', async () => { // Create DataType object @@ -485,9 +485,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); }); @@ -513,9 +513,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Negative Base Case', async () => { // Create DataType object @@ -531,9 +531,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Positive Value', async () => { // Create DataType object @@ -549,9 +549,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Negative Value', async () => { // Create DataType object @@ -567,9 +567,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int256 - Value too large', async () => { // Create DataType object @@ -607,9 +607,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Negative Base Case', async () => { // Create DataType object @@ -625,9 +625,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Positive Value', async () => { // Create DataType object @@ -643,9 +643,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Negative Value', async () => { // Create DataType object @@ -661,9 +661,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Int32 - Value too large', async () => { // Create DataType object @@ -711,9 +711,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt256 - Positive Value', async () => { // Create DataType object @@ -729,9 +729,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt256 - Zero Value', async () => { // Create DataType object @@ -747,9 +747,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt256 - Value too large', async () => { // Create DataType object @@ -787,9 +787,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt32 - Positive Value', async () => { // Create DataType object @@ -805,9 +805,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt32 - Zero Value', async () => { // Create DataType object @@ -823,9 +823,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('UInt32 - Value too large', async () => { // Create DataType object @@ -866,9 +866,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Single Byte (bytes1)', async () => { // Create DataType object @@ -884,9 +884,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('4 Bytes (bytes4)', async () => { // Create DataType object @@ -902,9 +902,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('4 Bytes (bytes4); Encoder must pad input', async () => { // Create DataType object @@ -922,9 +922,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const paddedArgs = '0x1a180000'; expect(decodedArgs).to.be.deep.equal(paddedArgs); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('32 Bytes (bytes32)', async () => { // Create DataType object @@ -940,9 +940,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('32 Bytes (bytes32); Encoder must pad input', async () => { // Create DataType object @@ -960,9 +960,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const paddedArgs = '0x1a18bf6100000000000000000000000000000000000000000000000000000000'; expect(decodedArgs).to.be.deep.equal(paddedArgs); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Should throw when pass in too many bytes (bytes4)', async () => { // Create DataType object @@ -1031,9 +1031,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Spans multiple EVM words', async () => { // Create DataType object @@ -1052,9 +1052,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Input as Buffer', async () => { // Create DataType object @@ -1073,9 +1073,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Should throw when pass in bad hex (no 0x prefix)', async () => { // Create DataType object @@ -1118,9 +1118,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('Spans multiple EVM words', async () => { // Create DataType object @@ -1139,9 +1139,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); it('String that begins with 0x prefix', async () => { // Create DataType object @@ -1160,9 +1160,9 @@ describe('ABI Encoder: EVM Data Type Encoding/Decoding', () => { const decodedArgs = dataType.decode(encodedArgs); expect(decodedArgs).to.be.deep.equal(args); // Validate signature - const dataTypecreate = AbiEncoder.create(dataType.getSignature(true)); - const encodedArgscreate = dataTypecreate.encode(args); - expect(encodedArgscreate).to.be.deep.equal(expectedEncodedArgs); + const dataTypeFromSignature = AbiEncoder.create(dataType.getSignature(true)); + const argsEncodedFromSignature = dataTypeFromSignature.encode(args); + expect(argsEncodedFromSignature).to.be.deep.equal(expectedEncodedArgs); }); }); }); diff --git a/packages/utils/test/abi_encoder/methods_test.ts b/packages/utils/test/abi_encoder/methods_test.ts index 472212e3c..920cb1799 100644 --- a/packages/utils/test/abi_encoder/methods_test.ts +++ b/packages/utils/test/abi_encoder/methods_test.ts @@ -199,7 +199,9 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { it('Unfixed Length Array / Static Members ABI', async () => { // Generate calldata const method = new AbiEncoder.Method(AbiSamples.dynamicArrayStaticMembersAbi); + // tslint:disable custom-no-magic-numbers const args = [[127, 14, 54]]; + // tslint:enable custom-no-magic-numbers const calldata = method.encode(args, encodingRules); // Validate calldata const expectedCalldata = @@ -213,7 +215,9 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { it('Fixed Length Array / Static Members ABI', async () => { // Generate calldata const method = new AbiEncoder.Method(AbiSamples.staticArrayAbi); + // tslint:disable custom-no-magic-numbers const args = [[127, 14, 54]]; + // tslint:enable custom-no-magic-numbers const calldata = method.encode(args, encodingRules); // Validate calldata const expectedCalldata = @@ -310,7 +314,9 @@ describe('ABI Encoder: Method Encoding / Decoding', () => { it('Large, Nested ABI', async () => { // Construct Calldata const method = new AbiEncoder.Method(AbiSamples.largeNestedAbi); + // tslint:disable custom-no-magic-numbers const someStaticArray = [127, 14, 54]; + // tslint:enable custom-no-magic-numbers const someStaticArrayWithDynamicMembers = [ 'the little piping piper piped a piping pipper papper', 'the kid knows how to write poems, what can I say -- I guess theres a lot I could say to try to fill this line with a lot of text.', diff --git a/packages/utils/test/abi_encoder/optimizer_test.ts b/packages/utils/test/abi_encoder/optimizer_test.ts index a7c920678..c0640583d 100644 --- a/packages/utils/test/abi_encoder/optimizer_test.ts +++ b/packages/utils/test/abi_encoder/optimizer_test.ts @@ -232,7 +232,9 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { it('Array Elements Duplicated as Tuple Fields', async () => { // Generate calldata const method = new AbiEncoder.Method(OptimizedAbis.arrayElementsDuplicatedAsTupleFields); + // tslint:disable custom-no-magic-numbers const array = [100, 150, 200, 225]; + // tslint:enable custom-no-magic-numbers const tuple = [ [new BigNumber(array[0])], [new BigNumber(array[1])], |