Update check to exclude bids greater than max price
This commit is contained in:
parent
0cb084e865
commit
71a23c34e9
@ -3,7 +3,7 @@ import Long from 'long';
|
|||||||
import { coin } from '@cosmjs/amino';
|
import { coin } from '@cosmjs/amino';
|
||||||
import { Coin } from '@cosmjs/proto-signing';
|
import { Coin } from '@cosmjs/proto-signing';
|
||||||
|
|
||||||
import { Registry, Account, createBid } from './index';
|
import { Registry, Account, createBid, INVALID_BID_ERROR } from './index';
|
||||||
import { getConfig } from './testing/helper';
|
import { getConfig } from './testing/helper';
|
||||||
import { DENOM } from './constants';
|
import { DENOM } from './constants';
|
||||||
import { Duration } from './proto/google/protobuf/duration';
|
import { Duration } from './proto/google/protobuf/duration';
|
||||||
@ -282,12 +282,18 @@ const providerAuctionTestsWithBids = (bidsAmount: number[], numProviders: number
|
|||||||
return parseInt(a.bid.reveal.bidAmount) - parseInt(b.bid.reveal.bidAmount);
|
return parseInt(a.bid.reveal.bidAmount) - parseInt(b.bid.reveal.bidAmount);
|
||||||
});
|
});
|
||||||
|
|
||||||
const winningBidders = sortedBidders.slice(0, numProviders);
|
const filteredBidders = sortedBidders.filter(bidder => {
|
||||||
const losingBidders = sortedBidders.slice(numProviders);
|
return parseInt(bidder.bid.reveal.bidAmount) <= parseInt(maxPrice.amount);
|
||||||
|
});
|
||||||
|
|
||||||
|
const numWinners = Math.min(filteredBidders.length, numProviders);
|
||||||
|
const winningBidders = filteredBidders.slice(0, numWinners);
|
||||||
|
const losingBidders = bidderAccounts.filter(bidder => !winningBidders.includes(bidder));
|
||||||
|
|
||||||
// Check winner price is equal to highest winning bid
|
// Check winner price is equal to highest winning bid
|
||||||
const winningBidAmount = parseInt(auction.winnerPrice.quantity);
|
const winningBidAmount = parseInt(auction.winnerPrice.quantity);
|
||||||
expect(auction.winnerPrice.quantity).toEqual(bidAmounts[numProviders - 1].amount);
|
const expectedWinningPrice = winningBidders[numWinners - 1].bid.reveal.bidAmount;
|
||||||
|
expect(`${auction.winnerPrice.quantity}${auction.winnerPrice.type}`).toEqual(expectedWinningPrice);
|
||||||
|
|
||||||
// Check balances of auction winners
|
// Check balances of auction winners
|
||||||
for (let i = 0; i < winningBidders.length; i++) {
|
for (let i = 0; i < winningBidders.length; i++) {
|
||||||
@ -332,7 +338,7 @@ const providerAuctionTestsWithBids = (bidsAmount: number[], numProviders: number
|
|||||||
|
|
||||||
// Check whether the balance after deducting locked amount is less than the actual balance
|
// Check whether the balance after deducting locked amount is less than the actual balance
|
||||||
expect(type).toBe(DENOM);
|
expect(type).toBe(DENOM);
|
||||||
expect(parseInt(quantity)).toBe(expectedCreatorBalance);
|
expect(parseInt(quantity)).toBeLessThan(expectedCreatorBalance);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user