diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-07 20:41:30 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-02-07 20:41:30 +0800 |
commit | 568e4d33f29db2f5c0195585438e18ab4b2aea18 (patch) | |
tree | 4f2372dc040f4354d51cfb2229391cfd7c033264 /packages/contracts/test/exchange/helpers.ts | |
parent | fd004032cb23998184a78ac4a0a486ef1bd04c25 (diff) | |
download | dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.gz dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.tar.zst dexon-sol-tools-568e4d33f29db2f5c0195585438e18ab4b2aea18.zip |
Use Order and SignedOrder type from 0x.js
Diffstat (limited to 'packages/contracts/test/exchange/helpers.ts')
-rw-r--r-- | packages/contracts/test/exchange/helpers.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts index 263a74911..5fe00225e 100644 --- a/packages/contracts/test/exchange/helpers.ts +++ b/packages/contracts/test/exchange/helpers.ts @@ -1,4 +1,4 @@ -import { ZeroEx } from '0x.js'; +import { SignedOrder, ZeroEx } from '0x.js'; import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -8,9 +8,7 @@ import ethUtil = require('ethereumjs-util'); import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange'; import { constants } from '../../util/constants'; import { ExchangeWrapper } from '../../util/exchange_wrapper'; -import { Order } from '../../util/order'; import { OrderFactory } from '../../util/order_factory'; -import { SignedOrder } from '../../util/signed_order'; import { ContractName } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; @@ -59,7 +57,7 @@ describe('Exchange', () => { makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18), }; - orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams); + orderFactory = new OrderFactory(zeroEx, defaultOrderParams); signedOrder = await orderFactory.newSignedOrderAsync(); }); @@ -72,7 +70,7 @@ describe('Exchange', () => { describe('getOrderHash', () => { it('should output the correct orderHash', async () => { const orderHashHex = await exchangeWrapper.getOrderHashAsync(signedOrder); - expect(signedOrder.getOrderHashHex()).to.be.equal(orderHashHex); + expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex); }); }); @@ -83,16 +81,19 @@ describe('Exchange', () => { it('should return true with a valid signature', async () => { const success = await exchangeWrapper.isValidSignatureAsync(signedOrder); - const isValidSignature = signedOrder.isValidSignature(); + const orderHashHex = ZeroEx.getOrderHashHex(signedOrder); + const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker); expect(isValidSignature).to.be.true(); expect(success).to.be.true(); }); it('should return false with an invalid signature', async () => { - signedOrder.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR')); - signedOrder.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS')); + signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR')); + signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS')); const success = await exchangeWrapper.isValidSignatureAsync(signedOrder); - expect(signedOrder.isValidSignature()).to.be.false(); + const orderHashHex = ZeroEx.getOrderHashHex(signedOrder); + const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker); + expect(isValidSignature).to.be.false(); expect(success).to.be.false(); }); }); |