chore: Work around for Ganache timestamp bug
This commit is contained in:
@@ -244,11 +244,11 @@ describe.only(ContractName.DutchAuction, () => {
|
|||||||
expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount);
|
expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount);
|
||||||
});
|
});
|
||||||
it('should match orders at current amount and send excess to buyer', async () => {
|
it('should match orders at current amount and send excess to buyer', async () => {
|
||||||
let auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||||
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
||||||
makerAssetAmount: auctionDetails.currentAmount.times(2),
|
makerAssetAmount: auctionDetails.currentAmount.times(2),
|
||||||
});
|
});
|
||||||
const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||||
buyOrder,
|
buyOrder,
|
||||||
sellOrder,
|
sellOrder,
|
||||||
@@ -259,16 +259,14 @@ describe.only(ContractName.DutchAuction, () => {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(
|
|
||||||
sellOrder,
|
|
||||||
{},
|
|
||||||
parseInt(receipt.blockNumber as any, 16),
|
|
||||||
);
|
|
||||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||||
expect(newBalances[dutchAuctionContract.address][wethContract.address]).to.be.bignumber.equal(
|
expect(newBalances[dutchAuctionContract.address][wethContract.address]).to.be.bignumber.equal(
|
||||||
constants.ZERO_AMOUNT,
|
constants.ZERO_AMOUNT,
|
||||||
);
|
);
|
||||||
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.equal(
|
// HACK gte used here due to a bug in ganache where the timestamp can change
|
||||||
|
// between multiple calls to the same block. Which can move the amount in our case
|
||||||
|
// ref: https://github.com/trufflesuite/ganache-core/issues/111
|
||||||
|
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte(
|
||||||
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[takerAddress][wethContract.address]).to.be.bignumber.equal(
|
expect(newBalances[takerAddress][wethContract.address]).to.be.bignumber.equal(
|
||||||
@@ -317,7 +315,7 @@ describe.only(ContractName.DutchAuction, () => {
|
|||||||
);
|
);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||||
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.equal(
|
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte(
|
||||||
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
|
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
|
||||||
@@ -340,7 +338,7 @@ describe.only(ContractName.DutchAuction, () => {
|
|||||||
);
|
);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||||
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.equal(
|
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte(
|
||||||
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
||||||
);
|
);
|
||||||
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
|
expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal(
|
||||||
@@ -434,7 +432,8 @@ describe.only(ContractName.DutchAuction, () => {
|
|||||||
takerAssetAmount: new BigNumber(1),
|
takerAssetAmount: new BigNumber(1),
|
||||||
takerAssetData: sellOrder.makerAssetData,
|
takerAssetData: sellOrder.makerAssetData,
|
||||||
});
|
});
|
||||||
const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||||
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||||
buyOrder,
|
buyOrder,
|
||||||
sellOrder,
|
sellOrder,
|
||||||
@@ -445,13 +444,11 @@ describe.only(ContractName.DutchAuction, () => {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(
|
|
||||||
sellOrder,
|
|
||||||
{},
|
|
||||||
parseInt(receipt.blockNumber as any, 16),
|
|
||||||
);
|
|
||||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||||
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.equal(
|
// HACK gte used here due to a bug in ganache where the timestamp can change
|
||||||
|
// between multiple calls to the same block. Which can move the amount in our case
|
||||||
|
// ref: https://github.com/trufflesuite/ganache-core/issues/111
|
||||||
|
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte(
|
||||||
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
erc20Balances[makerAddress][wethContract.address].plus(auctionDetails.currentAmount),
|
||||||
);
|
);
|
||||||
const newOwner = await erc721Token.ownerOf.callAsync(makerAssetId);
|
const newOwner = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||||
|
|||||||
Reference in New Issue
Block a user