From 7ae38906926dc09bc10670c361af0d2bf0050426 Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Sat, 19 Jan 2019 18:42:04 +0800 Subject: Update dependency packages --- packages/base-contract/test/base_contract_test.ts | 114 ---------------------- packages/base-contract/test/utils_test.ts | 108 -------------------- 2 files changed, 222 deletions(-) delete mode 100644 packages/base-contract/test/base_contract_test.ts delete mode 100644 packages/base-contract/test/utils_test.ts (limited to 'packages/base-contract/test') diff --git a/packages/base-contract/test/base_contract_test.ts b/packages/base-contract/test/base_contract_test.ts deleted file mode 100644 index 2c31d1f11..000000000 --- a/packages/base-contract/test/base_contract_test.ts +++ /dev/null @@ -1,114 +0,0 @@ -import * as chai from 'chai'; -import 'mocha'; - -import { BaseContract } from '../src'; - -const { expect } = chai; - -describe('BaseContract', () => { - describe('strictArgumentEncodingCheck', () => { - it('works for simple types', () => { - BaseContract.strictArgumentEncodingCheck( - [{ name: 'to', type: 'address' }], - ['0xe834ec434daba538cd1b9fe1582052b880bd7e63'], - ); - }); - it('works for array types', () => { - const inputAbi = [ - { - name: 'takerAssetFillAmounts', - type: 'uint256[]', - }, - ]; - const args = [ - ['9000000000000000000', '79000000000000000000', '979000000000000000000', '7979000000000000000000'], - ]; - BaseContract.strictArgumentEncodingCheck(inputAbi, args); - }); - it('works for tuple/struct types', () => { - const inputAbi = [ - { - components: [ - { - name: 'makerAddress', - type: 'address', - }, - { - name: 'takerAddress', - type: 'address', - }, - { - name: 'feeRecipientAddress', - type: 'address', - }, - { - name: 'senderAddress', - type: 'address', - }, - { - name: 'makerAssetAmount', - type: 'uint256', - }, - { - name: 'takerAssetAmount', - type: 'uint256', - }, - { - name: 'makerFee', - type: 'uint256', - }, - { - name: 'takerFee', - type: 'uint256', - }, - { - name: 'expirationTimeSeconds', - type: 'uint256', - }, - { - name: 'salt', - type: 'uint256', - }, - { - name: 'makerAssetData', - type: 'bytes', - }, - { - name: 'takerAssetData', - type: 'bytes', - }, - ], - name: 'order', - type: 'tuple', - }, - ]; - const args = [ - { - makerAddress: '0x6ecbe1db9ef729cbe972c83fb886247691fb6beb', - takerAddress: '0x0000000000000000000000000000000000000000', - feeRecipientAddress: '0xe834ec434daba538cd1b9fe1582052b880bd7e63', - senderAddress: '0x0000000000000000000000000000000000000000', - makerAssetAmount: '0', - takerAssetAmount: '200000000000000000000', - makerFee: '1000000000000000000', - takerFee: '1000000000000000000', - expirationTimeSeconds: '1532563026', - salt: '59342956082154660870994022243365949771115859664887449740907298019908621891376', - makerAssetData: '0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48', - takerAssetData: '0xf47261b00000000000000000000000001d7022f5b17d2f8b695918fb48fa1089c9f85401', - }, - ]; - BaseContract.strictArgumentEncodingCheck(inputAbi, args); - }); - it('throws for integer overflows', () => { - expect(() => - BaseContract.strictArgumentEncodingCheck([{ name: 'amount', type: 'uint8' }], ['256']), - ).to.throw(); - }); - it('throws for fixed byte array overflows', () => { - expect(() => - BaseContract.strictArgumentEncodingCheck([{ name: 'hash', type: 'bytes8' }], ['0x001122334455667788']), - ).to.throw(); - }); - }); -}); diff --git a/packages/base-contract/test/utils_test.ts b/packages/base-contract/test/utils_test.ts deleted file mode 100644 index 0608b72a2..000000000 --- a/packages/base-contract/test/utils_test.ts +++ /dev/null @@ -1,108 +0,0 @@ -import { BigNumber } from '@0x/utils'; -import * as chai from 'chai'; -import 'mocha'; - -import { formatABIDataItem } from '../src/utils'; - -const { expect } = chai; - -describe('Utils tests', () => { - describe('#formatABIDataItem', () => { - it('correctly handles arrays', () => { - const calls: Array<{ type: string; value: any }> = []; - const abi = { - name: 'values', - type: 'uint256[]', - }; - const val = [1, 2, 3]; - const formatted = formatABIDataItem(abi, val, (type: string, value: any) => { - calls.push({ type, value }); - return value; // no-op - }); - expect(formatted).to.be.deep.equal(val); - expect(calls).to.be.deep.equal([ - { type: 'uint256', value: 1 }, - { type: 'uint256', value: 2 }, - { type: 'uint256', value: 3 }, - ]); - }); - it('correctly handles tuples', () => { - const calls: Array<{ type: string; value: any }> = []; - const abi = { - components: [ - { - name: 'to', - type: 'address', - }, - { - name: 'amount', - type: 'uint256', - }, - ], - name: 'data', - type: 'tuple', - }; - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - const val = { to: ZERO_ADDRESS, amount: new BigNumber(1) }; - const formatted = formatABIDataItem(abi, val, (type: string, value: any) => { - calls.push({ type, value }); - return value; // no-op - }); - expect(formatted).to.be.deep.equal(val); - expect(calls).to.be.deep.equal([ - { - type: 'address', - value: val.to, - }, - { - type: 'uint256', - value: val.amount, - }, - ]); - }); - it('correctly handles nested arrays of tuples', () => { - const calls: Array<{ type: string; value: any }> = []; - const abi = { - components: [ - { - name: 'to', - type: 'address', - }, - { - name: 'amount', - type: 'uint256', - }, - ], - name: 'data', - type: 'tuple[2][]', - }; - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - const val = [ - [{ to: ZERO_ADDRESS, amount: new BigNumber(1) }, { to: ZERO_ADDRESS, amount: new BigNumber(2) }], - ]; - const formatted = formatABIDataItem(abi, val, (type: string, value: any) => { - calls.push({ type, value }); - return value; // no-op - }); - expect(formatted).to.be.deep.equal(val); - expect(calls).to.be.deep.equal([ - { - type: 'address', - value: val[0][0].to, - }, - { - type: 'uint256', - value: val[0][0].amount, - }, - { - type: 'address', - value: val[0][1].to, - }, - { - type: 'uint256', - value: val[0][1].amount, - }, - ]); - }); - }); -}); -- cgit v1.2.3