Add methods for creating auctions and add auction tests #28

Merged
nabarun merged 32 commits from deep-stack/registry-sdk:iv-create-auction-test into main 2024-09-25 13:21:05 +00:00
Showing only changes of commit 1de1a20852 - Show all commits

View File

@ -89,6 +89,12 @@ const createAuctionTests = () => {
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccounts[i].address, `${bidAmounts[i].quantity}${bidAmounts[i].type}`);
await registry.commitBid({ auctionId, commitHash: bidderAccounts[i].bid.commitHash }, bidderAccounts[i].privateKey, fee);
}
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('commit');
auction.bids.forEach((bid: any) => {
expect(bid.status).toEqual('commit');
});
});
test('Wait for reveal phase.', (done) => {
@ -110,6 +116,9 @@ const createAuctionTests = () => {
test('Check bids are revealed', async () => {
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('reveal');
auction.bids.forEach((bid: any) => {
expect(bid.status).toEqual('reveal');
});
const actualBidAmounts = auction.bids.map((bid: any) => bid.bidAmount);
expect(actualBidAmounts).toEqual(expect.arrayContaining(bidAmounts));
@ -211,6 +220,12 @@ const createProviderAuctionTests = () => {
bidderAccounts[i].bid = await createBid(chainId, auctionId, bidderAccounts[i].address, `${bidAmounts[i].quantity}${bidAmounts[i].type}`);
await registry.commitBid({ auctionId, commitHash: bidderAccounts[i].bid.commitHash }, bidderAccounts[i].privateKey, fee);
}
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('commit');
auction.bids.forEach((bid: any) => {
expect(bid.status).toEqual('commit');
});
});
test('Wait for reveal phase.', (done) => {
@ -232,6 +247,9 @@ const createProviderAuctionTests = () => {
test('Check bids are revealed', async () => {
const [auction] = await registry.getAuctionsByIds([auctionId]);
expect(auction.status).toEqual('reveal');
auction.bids.forEach((bid: any) => {
expect(bid.status).toEqual('reveal');
});
const actualBidAmounts = auction.bids.map((bid: any) => bid.bidAmount);
expect(actualBidAmounts).toEqual(expect.arrayContaining(bidAmounts));