diff options
author | Greg Hysen <greg.hysen@gmail.com> | 2018-08-23 05:05:44 +0800 |
---|---|---|
committer | Greg Hysen <greg.hysen@gmail.com> | 2018-08-25 09:18:30 +0800 |
commit | f697814849142a8a98229e17433f942eef5c25d3 (patch) | |
tree | dce78955b9b70785d9fc5d02b055fb358c424861 /packages/contracts/test/exchange | |
parent | ca5c9e77c0f068cf653afc9c8b61bdc25318f8e2 (diff) | |
download | dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.tar dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.tar.gz dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.tar.bz2 dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.tar.lz dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.tar.xz dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.tar.zst dexon-sol-tools-f697814849142a8a98229e17433f942eef5c25d3.zip |
First balance test with intentional values
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r-- | packages/contracts/test/exchange/match_orders.ts | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts index b2ffa31b2..3cffef7ad 100644 --- a/packages/contracts/test/exchange/match_orders.ts +++ b/packages/contracts/test/exchange/match_orders.ts @@ -21,10 +21,11 @@ import { ERC721Wrapper } from '../utils/erc721_wrapper'; import { ExchangeWrapper } from '../utils/exchange_wrapper'; import { MatchOrderTester } from '../utils/match_order_tester'; import { OrderFactory } from '../utils/order_factory'; -import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, OrderInfo, OrderStatus } from '../utils/types'; +import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, OrderInfo, TransferAmountsByMatchOrders as TransferAmounts, OrderStatus } from '../utils/types'; import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); + const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); @@ -212,7 +213,7 @@ describe.only('matchOrders', () => { }); */ - it('Jacobs Example', async () => { + it.only('Jacobs Example', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAddress: makerAddressLeft, @@ -228,6 +229,23 @@ describe.only('matchOrders', () => { takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 0), feeRecipientAddress: feeRecipientAddressRight, }); + // TODO: These values will change after implementation of rounding up has been merged + const expectedTransferAmounts = { + // Left Maker + amountSoldByLeftMaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 0), + amountBoughtByLeftMaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(3), 0), + feePaidByLeftMaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), // 100% + // Right Maker + amountSoldByRightMaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(3), 0), + amountBoughtByRightMaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 0), + feePaidByRightMaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(75), 16), // 75% + // Taker + amountReceivedByTaker: Web3Wrapper.toBaseUnitAmount(new BigNumber(9), 0), + feePaidByTakerLeft: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18), // 100% + feePaidByTakerRight: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 17), // 50% + }; + const expectedEndStateLeft = OrderStatus.FILLABLE; + const expectedEndStateRight = OrderStatus.FULLY_FILLED; // Match signedOrderLeft with signedOrderRight await matchOrderTester.matchOrdersAndVerifyBalancesAsync( signedOrderLeft, @@ -235,15 +253,10 @@ describe.only('matchOrders', () => { takerAddress, erc20BalancesByOwner, erc721TokenIdsByOwner, + expectedTransferAmounts, + expectedEndStateLeft, + expectedEndStateRight ); - // // Verify left order was fully filled - const leftOrderInfo: OrderInfo = await exchangeWrapper.getOrderInfoAsync(signedOrderLeft); - //expect(leftOrderInfo.orderStatus as OrderStatus).to.be.equal(OrderStatus.FULLY_FILLED); - console.log("*** LEFT ORDER INFO ***\n", JSON.stringify(leftOrderInfo), "\n***************"); - // Verify right order was fully filled - const rightOrderInfo: OrderInfo = await exchangeWrapper.getOrderInfoAsync(signedOrderRight); - // expect(rightOrderInfo.orderStatus as OrderStatus).to.be.equal(OrderStatus.FULLY_FILLED); - console.log("*** RIGHT ORDER INFO ***\n", JSON.stringify(rightOrderInfo), "\n***************"); }); @@ -825,6 +838,6 @@ describe.only('matchOrders', () => { // Verify right order was fully filled const rightOrderInfo: OrderInfo = await exchangeWrapper.getOrderInfoAsync(signedOrderRight); expect(rightOrderInfo.orderStatus as OrderStatus).to.be.equal(OrderStatus.FULLY_FILLED); - }); + });*/ }); }); // tslint:disable-line:max-file-line-count |