2023-03-31 18:18:31 +00:00
|
|
|
import {cliTest,createAuthority, getAuctionId} from './helper';
|
2023-03-24 11:32:38 +00:00
|
|
|
|
2023-03-27 06:49:33 +00:00
|
|
|
jest.setTimeout(3 * 60 * 1000);
|
|
|
|
|
2023-03-26 20:12:52 +00:00
|
|
|
const args= "auction ";
|
|
|
|
const quantity=25000000
|
|
|
|
const type="aphoton"
|
2023-04-03 07:28:22 +00:00
|
|
|
const name=`laconic-auction-${Date.now()}`
|
2023-03-26 20:12:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
var auctionId: string;
|
|
|
|
var filepath: string;
|
2023-03-24 11:32:38 +00:00
|
|
|
|
2023-03-31 18:18:31 +00:00
|
|
|
if (!process.env.TEST_AUCTIONS_ENABLED) {
|
|
|
|
// Required as jest complains if file has no tests.
|
|
|
|
test('skipping auction tests', () => {});
|
|
|
|
} else {
|
|
|
|
describe("test auction",() => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
// reserve authority
|
|
|
|
createAuthority(name)
|
|
|
|
auctionId = getAuctionId(name)
|
|
|
|
});
|
|
|
|
|
2023-04-03 07:28:22 +00:00
|
|
|
it("get auction",async ()=>{
|
|
|
|
const resp=cliTest(args+"get "+auctionId);
|
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp.length).toEqual(1);
|
|
|
|
expect(resp[0].id).toEqual(auctionId)
|
|
|
|
});
|
|
|
|
|
2023-03-31 18:18:31 +00:00
|
|
|
it("bid commit",async ()=>{
|
|
|
|
const resp=cliTest(args+"bid commit "+auctionId+" "+quantity+" "+type);
|
2023-04-03 07:28:22 +00:00
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp.reveal_file).toBeDefined();
|
2023-03-31 18:18:31 +00:00
|
|
|
|
|
|
|
filepath = resp.reveal_file
|
2023-04-03 07:28:22 +00:00
|
|
|
|
|
|
|
const auction=cliTest(args+"get "+auctionId);
|
|
|
|
expect(auction).toBeDefined;
|
|
|
|
expect(auction.length).toEqual(1);
|
|
|
|
expect(auction[0].bids.length).toEqual(1);
|
|
|
|
expect(auction[0].bids[0].bidAmount.quantity).toEqual("0")
|
2023-03-31 18:18:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Wait for reveal phase.", (done) => {
|
|
|
|
setTimeout(done, 60 * 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("bid reveal", async ()=>{
|
|
|
|
const resp=cliTest(args+"bid reveal "+auctionId+" "+filepath);
|
2023-04-03 07:28:22 +00:00
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp.success).toBeTruthy();
|
|
|
|
|
|
|
|
const auction=cliTest(args+"get "+auctionId);
|
|
|
|
expect(auction).toBeDefined;
|
|
|
|
expect(auction.length).toEqual(1);
|
|
|
|
expect(auction[0].bids.length).toEqual(1);
|
|
|
|
expect(auction[0].bids[0].bidAmount.quantity).toEqual(quantity+"")
|
2023-03-31 18:18:31 +00:00
|
|
|
});
|
2023-03-26 20:12:52 +00:00
|
|
|
});
|
2023-03-31 18:18:31 +00:00
|
|
|
}
|
2023-03-26 20:12:52 +00:00
|
|
|
|