diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-11-27 10:00:05 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-11-29 08:38:11 +0800 |
commit | 2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6 (patch) | |
tree | 4c1cceafe09a3b659c3fb7da8d178dd39712dd53 /packages/utils/test/abi_encoder/optimizer_test.ts | |
parent | ad1b5af4e59ba750c019cab1f5ec9584b8645101 (diff) | |
download | dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.tar dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.tar.gz dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.tar.bz2 dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.tar.lz dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.tar.xz dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.tar.zst dexon-0x-contracts-2e79ce26cbeacdeb0ea52b7c2e3da68e8055e7c6.zip |
Tests use to.be.deep.equal instead of JSON
Diffstat (limited to 'packages/utils/test/abi_encoder/optimizer_test.ts')
-rw-r--r-- | packages/utils/test/abi_encoder/optimizer_test.ts | 64 |
1 files changed, 16 insertions, 48 deletions
diff --git a/packages/utils/test/abi_encoder/optimizer_test.ts b/packages/utils/test/abi_encoder/optimizer_test.ts index 304c9cbc2..27443fe48 100644 --- a/packages/utils/test/abi_encoder/optimizer_test.ts +++ b/packages/utils/test/abi_encoder/optimizer_test.ts @@ -23,9 +23,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Dynamic Arrays with Dynamic Elements', async () => { // Generate calldata @@ -40,9 +38,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Static Arrays with Static Elements (should not optimize)', async () => { // Generate calldata @@ -59,9 +55,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(unoptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Static Arrays with Dynamic Elements', async () => { // Generate calldata @@ -76,9 +70,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Array Elements (should optimize)', async () => { // Generate calldata @@ -92,9 +84,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Tuple Fields', async () => { // Generate calldata @@ -108,9 +98,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Strings', async () => { // Description: @@ -127,9 +115,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Bytes', async () => { // Description: @@ -147,9 +133,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Tuples', async () => { // Generate calldata @@ -164,9 +148,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Fields Across Two Tuples', async () => { // Description: @@ -182,9 +164,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Arrays, Nested in Separate Tuples', async () => { // Generate calldata @@ -200,9 +180,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Tuples, Nested in Separate Tuples', async () => { // Generate calldata @@ -218,9 +196,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Two-Dimensional Arrays', async () => { // Generate calldata @@ -235,9 +211,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Duplicate Array, Nested within Separate Two-Dimensional Arrays', async () => { // Generate calldata @@ -252,9 +226,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Array Elements Duplicated as Tuple Fields', async () => { // Generate calldata @@ -269,9 +241,7 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); it('Array Elements Duplicated as Separate Parameter', async () => { // Generate calldata @@ -286,8 +256,6 @@ describe('ABI Encoder: Optimized Method Encoding/Decoding', () => { expect(optimizedCalldata).to.be.equal(expectedOptimizedCalldata); // Validate decoding const decodedArgs = method.decode(optimizedCalldata); - const decodedArgsJson = JSON.stringify(decodedArgs); - const argsJson = JSON.stringify(args); - expect(decodedArgsJson).to.be.equal(argsJson); + expect(decodedArgs).to.be.deep.equal(args); }); }); |