-
Notifications
You must be signed in to change notification settings - Fork 60
Add tests for tradingPairCutoffs #238
Add tests for tradingPairCutoffs #238
Conversation
test/testLoopringProtocolImpl.ts
Outdated
| await loopringProtocolImpl.setTradingPairCutoff(new BigNumber(1508566125), order.params.amountS, order.params.amountB, {from: order1Owner}); | ||
| const tradingPairCutoff = await loopringProtocolImpl.tradingPairCutoffs(order.params.amountS, order1Owner); | ||
|
|
||
| // TODO: how to implment the assert when getTradingPairId is an internal function? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dong77 Could you help me with the implementation of the assert? Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to reimplement the method using JS. Check out this one:
// var keccak256 = require('js-sha3').keccak256;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also change "setCutoff" to "cancelOrders" and "setTradingPairCutoff" to "cancelOrders" as well if overloading is permitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Truffle does not support function overloading. ConsenSys-archive/truffle#737 So I keep "setCutoff" unchanged and change "setTradingPairCutoff" to "cancelOrders"
| const tradingPairId = web3.toHex(tradingPairIdBigInt.toString(10)); | ||
| const tradingPairCutoff = await loopringProtocolImpl.tradingPairCutoffs(order1Owner, tradingPairId); | ||
|
|
||
| // FIXME: tradingPairCutoff.toNumber() is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dong77 I tried to use keccak256 in the test. Could you help me with the PR? It seems that I didn't implement the method to get trading pair id correctly. Thank you.
…rate tradingPairId in the test.
| const token1_256 = keccak256(order.params.tokenS); | ||
| const token2_256 = keccak256(order.params.tokenB); | ||
| const combinedTokenHash = xor(new Buffer(token1_256), new Buffer(token2_256)); | ||
| const tradingPairCutoff = await loopringProtocolImpl.tradingPairCutoffs(order1Owner, [...combinedTokenHash]); //, combinedTokenHash.toString("hex")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covert a Buffer to bytes array.
No description provided.