aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange/helpers.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-07 19:22:22 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-02-07 19:22:22 +0800
commitfd004032cb23998184a78ac4a0a486ef1bd04c25 (patch)
tree90f7e64996ccc0fee1e5428b2ced9b2c2b1c3d4a /packages/contracts/test/exchange/helpers.ts
parent4b6324050da4862f4d8bdb7d6dbd66107929a2b5 (diff)
downloaddexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.tar
dexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.tar.gz
dexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.tar.bz2
dexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.tar.lz
dexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.tar.xz
dexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.tar.zst
dexon-sol-tools-fd004032cb23998184a78ac4a0a486ef1bd04c25.zip
Introduce SignedOrder class and remove type assertions
Diffstat (limited to 'packages/contracts/test/exchange/helpers.ts')
-rw-r--r--packages/contracts/test/exchange/helpers.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts
index e2e35ece8..263a74911 100644
--- a/packages/contracts/test/exchange/helpers.ts
+++ b/packages/contracts/test/exchange/helpers.ts
@@ -10,6 +10,7 @@ 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';
@@ -25,7 +26,7 @@ describe('Exchange', () => {
let maker: string;
let feeRecipient: string;
- let order: Order;
+ let signedOrder: SignedOrder;
let exchangeWrapper: ExchangeWrapper;
let orderFactory: OrderFactory;
@@ -59,7 +60,7 @@ describe('Exchange', () => {
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
});
beforeEach(async () => {
@@ -70,28 +71,28 @@ describe('Exchange', () => {
});
describe('getOrderHash', () => {
it('should output the correct orderHash', async () => {
- const orderHashHex = await exchangeWrapper.getOrderHashAsync(order);
- expect(order.getOrderHashHex()).to.be.equal(orderHashHex);
+ const orderHashHex = await exchangeWrapper.getOrderHashAsync(signedOrder);
+ expect(signedOrder.getOrderHashHex()).to.be.equal(orderHashHex);
});
});
describe('isValidSignature', () => {
beforeEach(async () => {
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should return true with a valid signature', async () => {
- const success = await exchangeWrapper.isValidSignatureAsync(order);
- const isValidSignature = order.isValidSignature();
+ const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
+ const isValidSignature = signedOrder.isValidSignature();
expect(isValidSignature).to.be.true();
expect(success).to.be.true();
});
it('should return false with an invalid signature', async () => {
- order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
- order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
- const success = await exchangeWrapper.isValidSignatureAsync(order);
- expect(order.isValidSignature()).to.be.false();
+ signedOrder.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
+ signedOrder.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
+ const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
+ expect(signedOrder.isValidSignature()).to.be.false();
expect(success).to.be.false();
});
});