From 1cadbeed88d2e5f413c8f7e39aaee6efcff89831 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 30 Jan 2018 12:38:44 +0100 Subject: Add shouldAddPersonalMessagePrefix param to signOrderHashAsync instead of trying to infer whether to add it or not from the nodeVersion --- packages/0x.js/test/0x.js_test.ts | 20 +++++++++++++++++--- packages/0x.js/test/utils/order_factory.ts | 4 +++- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'packages/0x.js/test') diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts index 5bc2c149c..927fe20be 100644 --- a/packages/0x.js/test/0x.js_test.ts +++ b/packages/0x.js/test/0x.js_test.ts @@ -16,6 +16,8 @@ const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL); chaiSetup.configure(); const expect = chai.expect; +const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false; + describe('ZeroEx library', () => { const web3 = web3Factory.create(); const config = { @@ -198,7 +200,11 @@ describe('ZeroEx library', () => { r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', }; - const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress); + const ecSignature = await zeroEx.signOrderHashAsync( + orderHash, + makerAddress, + SHOULD_ADD_PERSONAL_MESSAGE_PREFIX, + ); expect(ecSignature).to.deep.equal(expectedECSignature); }); it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => { @@ -215,7 +221,11 @@ describe('ZeroEx library', () => { Sinon.stub(ZeroEx, 'isValidSignature').returns(true), ]; - const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress); + const ecSignature = await zeroEx.signOrderHashAsync( + orderHash, + makerAddress, + SHOULD_ADD_PERSONAL_MESSAGE_PREFIX, + ); expect(ecSignature).to.deep.equal(expectedECSignature); }); it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => { @@ -232,7 +242,11 @@ describe('ZeroEx library', () => { Sinon.stub(ZeroEx, 'isValidSignature').returns(true), ]; - const ecSignature = await zeroEx.signOrderHashAsync(orderHash, makerAddress); + const ecSignature = await zeroEx.signOrderHashAsync( + orderHash, + makerAddress, + SHOULD_ADD_PERSONAL_MESSAGE_PREFIX, + ); expect(ecSignature).to.deep.equal(expectedECSignature); }); }); diff --git a/packages/0x.js/test/utils/order_factory.ts b/packages/0x.js/test/utils/order_factory.ts index 60a7c5fb2..08f2081a4 100644 --- a/packages/0x.js/test/utils/order_factory.ts +++ b/packages/0x.js/test/utils/order_factory.ts @@ -3,6 +3,8 @@ import * as _ from 'lodash'; import { SignedOrder, ZeroEx } from '../../src'; +const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false; + export const orderFactory = { async createSignedOrderAsync( zeroEx: ZeroEx, @@ -37,7 +39,7 @@ export const orderFactory = { expirationUnixTimestampSec, }; const orderHash = ZeroEx.getOrderHashHex(order); - const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker); + const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker, SHOULD_ADD_PERSONAL_MESSAGE_PREFIX); const signedOrder: SignedOrder = _.assign(order, { ecSignature }); return signedOrder; }, -- cgit v1.2.3