diff options
Diffstat (limited to 'packages/contract-wrappers/test')
-rw-r--r-- | packages/contract-wrappers/test/dutch_auction_wrapper_test.ts | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts b/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts index ad8b3bd31..bfc4e0a58 100644 --- a/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts +++ b/packages/contract-wrappers/test/dutch_auction_wrapper_test.ts @@ -16,6 +16,7 @@ import { provider, web3Wrapper } from './utils/web3_wrapper'; import { getLatestBlockTimestampAsync } from '@0x/contracts-test-utils'; import { DutchAuction } from '@0x/contract-artifacts'; import { DutchAuctionWrapper } from '../src/contract_wrappers/dutch_auction_wrapper'; +import { Web3Wrapper } from '@0x/web3-wrapper'; chaiSetup.configure(); const expect = chai.expect; @@ -23,7 +24,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); // tslint:disable:custom-no-magic-numbers describe.only('DutchAuctionWrapper', () => { - const fillableAmount = new BigNumber(5); + const fillableAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18); const tenMinutesInSeconds = 10 * 60; let contractWrappers: ContractWrappers; let fillScenarios: FillScenarios; @@ -32,10 +33,9 @@ describe.only('DutchAuctionWrapper', () => { let userAddresses: string[]; let makerAddress: string; let takerAddress: string; + let buyerAddress: string; let makerTokenAddress: string; let takerTokenAddress: string; - let makerAssetData: string; - let takerAssetData: string; let buyOrder: SignedOrder; let sellOrder: SignedOrder; let makerTokenAssetData: string; @@ -63,40 +63,44 @@ describe.only('DutchAuctionWrapper', () => { contractWrappers.erc20Proxy.address, contractWrappers.erc721Proxy.address, ); - [, makerAddress, takerAddress] = userAddresses; + [, makerAddress, takerAddress, buyerAddress] = userAddresses; [makerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); takerTokenAddress = contractWrappers.forwarder.etherTokenAddress; + console.log(`B`); // construct asset data for tokens being swapped [makerTokenAssetData, takerTokenAssetData] = [ assetDataUtils.encodeERC20AssetData(makerTokenAddress), assetDataUtils.encodeERC20AssetData(takerTokenAddress), ]; + console.log(`C`); // encode auction details in maker asset data const auctionBeginAmount = fillableAmount; const currentBlockTimestamp = await getLatestBlockTimestampAsync(); const auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds); - makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( + /* makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData( makerTokenAssetData, auctionBeginTimeSeconds, auctionBeginAmount - ); - takerAssetData = takerTokenAssetData; + );*/ + console.log(`C2`); // create sell / buy orders for auction // note that the maker/taker asset datas are swapped in the `buyOrder` - sellOrder = await fillScenarios.createFillableSignedOrderAsync( - makerAssetData, - takerAssetData, - makerAddress, - constants.NULL_ADDRESS, + sellOrder = await contractWrappers.dutchAuction.createSignedSellOrderAsync( + auctionBeginTimeSeconds, + fillableAmount.times(2), fillableAmount, - ); - buyOrder = await fillScenarios.createFillableSignedOrderAsync( - takerAssetData, - makerAssetData, + new BigNumber(currentBlockTimestamp + tenMinutesInSeconds), + makerTokenAssetData, + takerTokenAssetData, makerAddress, constants.NULL_ADDRESS, fillableAmount, ); + buyOrder = await contractWrappers.dutchAuction.createSignedBuyOrderAsync( + sellOrder, + buyerAddress, + ); + console.log(`CD`); }); after(async () => { await blockchainLifecycle.revertAsync(); @@ -109,8 +113,10 @@ describe.only('DutchAuctionWrapper', () => { }); describe('#matchOrdersAsync', () => { it('should match two orders', async () => { - const txHash = await contractWrappers.dutchAuction.matchOrdersAsync(buyOrder, sellOrder, takerAddress); - await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + console.log(await contractWrappers.dutchAuction.getAuctionDetailsAsync(sellOrder)); + + // const txHash = await contractWrappers.dutchAuction.matchOrdersAsync(buyOrder, sellOrder, takerAddress, {gasLimit: 1000000}); + //await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); }); it('should throw when invalid transaction and shouldValidate is true', async () => { // request match with bad buy/sell orders @@ -130,7 +136,7 @@ describe.only('DutchAuctionWrapper', () => { }); describe('#getAuctionDetailsAsync', () => { - it('should be worth the begin price at the begining of the auction', async () => { + /*it('should be worth the begin price at the begining of the auction', async () => { // setup auction details const auctionBeginAmount = fillableAmount; const currentBlockTimestamp = await getLatestBlockTimestampAsync(); @@ -151,6 +157,6 @@ describe.only('DutchAuctionWrapper', () => { expect(auctionDetails.currentTimeSeconds).to.be.bignumber.lte(auctionBeginTimeSeconds); expect(auctionDetails.currentAmount).to.be.bignumber.equal(auctionBeginAmount); expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount); - }); + });*/ }); }); |