Tests for registry-cli #32

Closed
0xmuralik wants to merge 23 commits from murali/tests into main
Showing only changes of commit b76f52013b - Show all commits

View File

@ -1,26 +1,32 @@
import {cliTest,createAuthority} from './helper'; import {cliTest,createAuthority, getAuctionId} from './helper';
jest.setTimeout(3 * 60 * 1000); 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"
var auctionId: string; var auctionId: string;
var filepath: string; var filepath: string;
if (!process.env.TEST_AUCTIONS_ENABLED) {
// Required as jest complains if file has no tests.
test('skipping auction tests', () => {});
} else {
describe("test auction",() => { describe("test auction",() => {
beforeAll(async () => { beforeAll(async () => {
// get auction id // reserve authority
auctionId = createAuthority("laconic-auction") createAuthority(name)
auctionId = getAuctionId(name)
}); });
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;
filepath = "."+resp.substring(resp.indexOf("/out/")) filepath = resp.reveal_file
}); });
it("Wait for reveal phase.", (done) => { it("Wait for reveal phase.", (done) => {
@ -28,12 +34,14 @@ describe("test auction",() => {
}); });
it("bid reveal", async ()=>{ it("bid reveal", async ()=>{
const resp=JSON.parse(cliTest(args+"bid reveal "+auctionId+" "+filepath)); const resp=cliTest(args+"bid reveal "+auctionId+" "+filepath);
expect(resp).toBeDefined; expect(resp).toBeDefined;
}); });
it("get auction",async ()=>{ it("get auction",async ()=>{
const resp=JSON.parse(cliTest(args+"get "+auctionId)); const resp=cliTest(args+"get "+auctionId);
expect(resp).toBeDefined; expect(resp).toBeDefined;
}); });
}); });
}