diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-25 00:39:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-25 00:39:28 +0800 |
commit | 62431fee8e0c79a61f7ebb7677e6c88f0ae95116 (patch) | |
tree | f7aa155da9dd3a88d531d525f9f26f89b10e0e2a /packages/json-schemas/test | |
parent | 2f7ab3e32d1c54f42c435503426bc421fa89afd8 (diff) | |
parent | 357201869a56f01d33f3b1bf91be18a6029d5d7f (diff) | |
download | dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.gz dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.bz2 dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.lz dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.xz dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.tar.zst dexon-sol-tools-62431fee8e0c79a61f7ebb7677e6c88f0ae95116.zip |
Merge pull request #615 from 0xProject/refactor/json-schemas/for-v2
Refactor order schemas in json-schemas for v2
Diffstat (limited to 'packages/json-schemas/test')
-rw-r--r-- | packages/json-schemas/test/schema_test.ts | 75 |
1 files changed, 19 insertions, 56 deletions
diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index b9574a0c9..379f92442 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -14,8 +14,7 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; const { numberSchema, addressSchema, - ecSignatureSchema, - ecSignatureParameterSchema, + hexSchema, orderCancellationRequestsSchema, orderFillOrKillRequestsSchema, orderFillRequestsSchema, @@ -85,47 +84,15 @@ describe('Schema', () => { validateAgainstSchema(testCases, addressSchema, shouldFail); }); }); - describe('#ecSignatureParameterSchema', () => { - it('should validate valid parameters', () => { - const testCases = [ - '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', - '0X40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - ]; - validateAgainstSchema(testCases, ecSignatureParameterSchema); - }); - it('should fail for invalid parameters', () => { - const testCases = [ - '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter - '0xzzzz9190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // invalid characters - '40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x - ]; - const shouldFail = true; - validateAgainstSchema(testCases, ecSignatureParameterSchema, shouldFail); - }); - }); - describe('#ecSignatureSchema', () => { - it('should validate valid signature', () => { - const signature = { - v: 27, - r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', - s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - }; - const testCases = [ - signature, - { - ...signature, - v: 28, - }, - ]; - validateAgainstSchema(testCases, ecSignatureSchema); + describe('#hexSchema', () => { + it('should validate valid hex string', () => { + const testCases = ['0x8b0292b11a196601ed2ce54b665cafeca0347d42', NULL_ADDRESS]; + validateAgainstSchema(testCases, hexSchema); }); - it('should fail for invalid signature', () => { - const v = 27; - const r = '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33'; - const s = '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254'; - const testCases = [{}, { v }, { r, s, v: 31 }]; + it('should fail for invalid hex string', () => { + const testCases = ['0x', '0', '0xzzzzzzB11a196601eD2ce54B665CaFEca0347D42']; const shouldFail = true; - validateAgainstSchema(testCases, ecSignatureSchema, shouldFail); + validateAgainstSchema(testCases, hexSchema, shouldFail); }); }); describe('#orderHashSchema', () => { @@ -202,18 +169,17 @@ describe('Schema', () => { }); describe('order including schemas', () => { const order = { - maker: NULL_ADDRESS, - taker: NULL_ADDRESS, + makerAddress: NULL_ADDRESS, + takerAddress: NULL_ADDRESS, makerFee: '1', takerFee: '2', - makerTokenAmount: '1', - takerTokenAmount: '2', - makerTokenAddress: NULL_ADDRESS, - takerTokenAddress: NULL_ADDRESS, + makerAssetAmount: '1', + takerAssetAmount: '2', + makerAssetData: NULL_ADDRESS, + takerAssetData: NULL_ADDRESS, salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500', - feeRecipient: NULL_ADDRESS, - exchangeContractAddress: NULL_ADDRESS, - expirationUnixTimestampSec: '42', + feeRecipientAddress: NULL_ADDRESS, + expirationTimeSeconds: '42', }; describe('#orderSchema', () => { it('should validate valid order', () => { @@ -239,11 +205,8 @@ describe('Schema', () => { describe('signed order including schemas', () => { const signedOrder = { ...order, - ecSignature: { - v: 27, - r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', - s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - }, + signature: + '0x031b61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', }; describe('#signedOrdersSchema', () => { it('should validate valid signed orders', () => { @@ -265,7 +228,7 @@ describe('Schema', () => { const testCases = [ { ...signedOrder, - ecSignature: undefined, + signature: undefined, }, ]; const shouldFail = true; |