Make getOrderHashHex a non-async function

This commit is contained in:
Leonid Logvinov
2017-06-29 10:34:49 -07:00
parent dd590ca79e
commit e9db532727
2 changed files with 3 additions and 14 deletions

View File

@@ -176,7 +176,7 @@ export class ZeroEx {
* @param order An object that conforms to the Order or SignedOrder interface definitions. * @param order An object that conforms to the Order or SignedOrder interface definitions.
* @return The resulting orderHash from hashing the supplied order. * @return The resulting orderHash from hashing the supplied order.
*/ */
public async getOrderHashHexAsync(order: Order|SignedOrder): Promise<string> { public getOrderHashHex(order: Order|SignedOrder): string {
assert.doesConformToSchema('order', order, orderSchema); assert.doesConformToSchema('order', order, orderSchema);
const orderHashHex = utils.getOrderHashHex(order, order.exchangeContractAddress); const orderHashHex = utils.getOrderHashHex(order, order.exchangeContractAddress);
return orderHashHex; return orderHashHex;

View File

@@ -130,7 +130,7 @@ describe('ZeroEx library', () => {
expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount); expect(baseUnitAmount).to.be.bignumber.equal(expectedUnitAmount);
}); });
}); });
describe('#getOrderHashHexAsync', () => { describe('#getOrderHashHex', () => {
const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83'; const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';
const exchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b'; const exchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b';
const order: Order = { const order: Order = {
@@ -147,22 +147,11 @@ describe('ZeroEx library', () => {
takerTokenAmount: new BigNumber(0), takerTokenAmount: new BigNumber(0),
expirationUnixTimestampSec: new BigNumber(0), expirationUnixTimestampSec: new BigNumber(0),
}; };
let stubs: Sinon.SinonStub[] = [];
afterEach(() => {
// clean up any stubs after the test has completed
_.each(stubs, s => s.restore());
stubs = [];
});
it('calculates the order hash', async () => { it('calculates the order hash', async () => {
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const zeroEx = new ZeroEx(web3.currentProvider); const zeroEx = new ZeroEx(web3.currentProvider);
stubs = [ const orderHash = zeroEx.getOrderHashHex(order);
Sinon.stub((zeroEx as any), '_getExchangeAddressAsync')
.returns(Promise.resolve(exchangeContractAddress)),
];
const orderHash = await zeroEx.getOrderHashHexAsync(order);
expect(orderHash).to.be.equal(expectedOrderHash); expect(orderHash).to.be.equal(expectedOrderHash);
}); });
}); });