Add methods for creating auctions and add auction tests #28
@ -116,6 +116,19 @@ const auctionTests = () => {
|
||||
const expectedBidAmounts = bidAmounts.map(bidAmount => { return { quantity: bidAmount.amount, type: bidAmount.denom }; });
|
||||
const actualBidAmounts = auction.bids.map((bid: any) => bid.bidAmount);
|
||||
expect(actualBidAmounts).toEqual(expect.arrayContaining(expectedBidAmounts));
|
||||
|
||||
// Check that the bid amounts are locked after reveal phase
|
||||
for (let i = 0; i < numBidders; i++) {
|
||||
const [bidderrAccountObj] = await registry.getAccounts([bidderAccounts[i].address]);
|
||||
expect(bidderrAccountObj).toBeDefined();
|
||||
|
||||
const [{ type, quantity }] = bidderrAccountObj.balance;
|
||||
const actualBalance = parseInt(quantity);
|
||||
const expectedBalance = bidderInitialBalance - parseInt(bidAmounts[i].amount);
|
||||
|
||||
expect(type).toBe(DENOM);
|
||||
expect(actualBalance).toBeLessThan(expectedBalance);
|
||||
}
|
||||
});
|
||||
|
||||
test('Wait for auction completion.', (done) => {
|
||||
@ -202,6 +215,17 @@ const providerAuctionTests = () => {
|
||||
expect(auction.auction?.id).toBeDefined();
|
||||
auctionId = auction.auction?.id || '';
|
||||
expect(auction.auction?.status).toEqual('commit');
|
||||
|
||||
// Check that the total locked amount is deducted from the creator's account
|
||||
const [creatorAccountObj] = await registry.getAccounts([auctionCreatorAccount.address]);
|
||||
expect(creatorAccountObj).toBeDefined();
|
||||
|
||||
const [{ type, quantity }] = creatorAccountObj.balance;
|
||||
const actualBalance = parseInt(quantity);
|
||||
const expectedBalance = creatorInitialBalance - (parseInt(maxPrice.amount) * numProviders);
|
||||
|
||||
expect(type).toBe(DENOM);
|
||||
expect(actualBalance).toBeLessThan(expectedBalance);
|
||||
});
|
||||
|
||||
test('Commit bids.', async () => {
|
||||
@ -308,6 +332,10 @@ const providerAuctionTests = () => {
|
||||
// The balance would be less than expected balance
|
||||
expect(type).toBe(DENOM);
|
||||
expect(parseInt(quantity)).toBeLessThan(expectedCreatorBalance);
|
||||
|
||||
// Check whether the balance after deducting locked amount is less than the actual balance
|
||||
const amountAfterDeduction = creatorInitialBalance - (parseInt(maxPrice.amount) * numProviders);
|
||||
expect(parseInt(quantity)).toBeLessThan(amountAfterDeduction);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user