Tests for registry-cli #32

Closed
0xmuralik wants to merge 23 commits from murali/tests into main
2 changed files with 26 additions and 9 deletions
Showing only changes of commit 9a45237b2d - Show all commits

View File

@ -28,7 +28,8 @@
"lint": "eslint .", "lint": "eslint .",
"clean": "rm -rf ./dist", "clean": "rm -rf ./dist",
"build": "tsc", "build": "tsc",
"test": "jest --runInBand --verbose" "test": "jest --runInBand --verbose",
"test:auctions": "TEST_AUCTIONS_ENABLED=1 jest --runInBand --verbose test/auction.test.ts"
}, },
"bin": { "bin": {
"laconic": "bin/laconic" "laconic": "bin/laconic"

View File

@ -5,7 +5,7 @@ jest.setTimeout(3 * 60 * 1000);
const args= "auction "; const args= "auction ";
const quantity=25000000 const quantity=25000000
const type="aphoton" const type="aphoton"
const name="laconic-auction" const name=`laconic-auction-${Date.now()}`
var auctionId: string; var auctionId: string;
@ -22,11 +22,25 @@ if (!process.env.TEST_AUCTIONS_ENABLED) {
auctionId = getAuctionId(name) auctionId = getAuctionId(name)
}); });
it("get auction",async ()=>{
const resp=cliTest(args+"get "+auctionId);
expect(resp).toBeDefined();
expect(resp.length).toEqual(1);
expect(resp[0].id).toEqual(auctionId)
});
it("bid commit",async ()=>{ it("bid commit",async ()=>{
const resp=cliTest(args+"bid commit "+auctionId+" "+quantity+" "+type); const resp=cliTest(args+"bid commit "+auctionId+" "+quantity+" "+type);
expect(resp).toBeDefined; expect(resp).toBeDefined();
expect(resp.reveal_file).toBeDefined();
filepath = resp.reveal_file filepath = resp.reveal_file
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")
}); });
it("Wait for reveal phase.", (done) => { it("Wait for reveal phase.", (done) => {
@ -35,12 +49,14 @@ if (!process.env.TEST_AUCTIONS_ENABLED) {
it("bid reveal", async ()=>{ it("bid reveal", async ()=>{
const resp=cliTest(args+"bid reveal "+auctionId+" "+filepath); const resp=cliTest(args+"bid reveal "+auctionId+" "+filepath);
expect(resp).toBeDefined; expect(resp).toBeDefined();
}); expect(resp.success).toBeTruthy();
it("get auction",async ()=>{ const auction=cliTest(args+"get "+auctionId);
const resp=cliTest(args+"get "+auctionId); expect(auction).toBeDefined;
expect(resp).toBeDefined; expect(auction.length).toEqual(1);
expect(auction[0].bids.length).toEqual(1);
expect(auction[0].bids[0].bidAmount.quantity).toEqual(quantity+"")
}); });
}); });
} }