Tests for registry-cli #32
@ -1,11 +1,33 @@
|
||||
import {cliTest} from './helper';
|
||||
import {cliTest,createAuthority} from './helper';
|
||||
|
||||
const args= "auction "
|
||||
const args= "auction ";
|
||||
const quantity=25000000
|
||||
const type="aphoton"
|
||||
|
||||
|
||||
var auctionId: string;
|
||||
var filepath: string;
|
||||
|
||||
describe("test auction",() => {
|
||||
beforeAll(async () => {
|
||||
// get auction id
|
||||
auctionId = createAuthority("laconic-auction")
|
||||
});
|
||||
|
||||
it("bid commit",async ()=>{
|
||||
// const resp=JSON.parse(cliTest(args+" bid commit"));
|
||||
// expect(resp).toBeDefined;
|
||||
expect(0).toEqual(0);
|
||||
const resp=JSON.parse(cliTest(args+"bid commit "+auctionId+" "+quantity+" "+type));
|
||||
expect(resp).toBeDefined;
|
||||
|
||||
filepath = resp.substring(resp.indexOf("./out"))
|
||||
});
|
||||
|
||||
it("bid reveal", async ()=>{
|
||||
const resp=JSON.parse(cliTest(args+"bid reveal "+auctionId+" "+filepath));
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("get auction",async ()=>{
|
||||
const resp=JSON.parse(cliTest(args+"get "+auctionId));
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
});
|
31
test/authority.test.ts
Normal file
31
test/authority.test.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import {cliTest,createBond} from './helper';
|
||||
|
||||
const args= "authority "
|
||||
|
||||
var bondId: string;
|
||||
var name: string;
|
||||
|
||||
describe("test authority",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bond id
|
||||
bondId=createBond("aphoton","1000000000")
|
||||
});
|
||||
|
||||
|
||||
it("reserve authority",async ()=>{
|
||||
name="laconic"
|
||||
const resp=cliTest(args+"reserve "+name);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("lookup authority information.",async ()=>{
|
||||
const resp=cliTest(args+"whois "+ name);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("set authority bond",async ()=>{
|
||||
const resp=cliTest(args+"bond set "+name+" "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
import {cliTest} from './helper';
|
||||
import {cliTest,createBond,createRecord} from './helper';
|
||||
|
||||
const args= "bond "
|
||||
const quantity=1000000000
|
||||
const quantity="1000000000"
|
||||
const refillQuantity=100
|
||||
const withdrawQuantity=100
|
||||
const type="aphoton"
|
||||
@ -15,10 +15,7 @@ describe("test bond",() => {
|
||||
beforeAll(async () => {
|
||||
const resp=JSON.parse(cliTest("account get"));
|
||||
expect(resp).toBeDefined;
|
||||
address=resp[0].address
|
||||
|
||||
// get 2 bondids (old, new)
|
||||
// get record id
|
||||
address=resp[0].address
|
||||
});
|
||||
|
||||
|
||||
@ -59,6 +56,11 @@ describe("test bond",() => {
|
||||
});
|
||||
|
||||
it("associate bond with record",async ()=>{
|
||||
// get new bond Id
|
||||
bondId=createBond(type,quantity)
|
||||
// get record Id
|
||||
recordId=createRecord("./test/examples/watcher.yml",bondId)
|
||||
|
||||
const resp=cliTest(args+"associate --id "+recordId+" --bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
@ -74,6 +76,8 @@ describe("test bond",() => {
|
||||
});
|
||||
|
||||
it("reassociate all records from bond",async ()=>{
|
||||
// TODO: get 2 bondids (old, new)
|
||||
|
||||
const resp=cliTest(args+"records reassociate --old-bond-id "+bondId+" --new-bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
7
test/examples/watcher.yml
Normal file
7
test/examples/watcher.yml
Normal file
@ -0,0 +1,7 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: 'https://cerc.io'
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.35
|
@ -3,3 +3,30 @@ const { execSync } = require("child_process");
|
||||
export const cliTest = (args: any) => {
|
||||
return execSync(`./bin/laconic cns ${args}`).toString();
|
||||
};
|
||||
|
||||
export function createBond(type: string, quantity: string):string{
|
||||
const resp=cliTest("bond create --type aphoton --quantity 1000000000");
|
||||
expect(resp).toBeDefined;
|
||||
|
||||
// refactor to get bondId from create resp
|
||||
const list=cliTest("bond list");
|
||||
const bondId=JSON.parse(list)[0].id
|
||||
expect(resp).toBeDefined;
|
||||
return bondId
|
||||
};
|
||||
|
||||
export function createRecord(filepath: string, bondId: string):string{
|
||||
const resp=cliTest("record publish --filename "+filepath+" --bond-id "+bondId);
|
||||
const recordId = resp.substring(resp.indexOf(":")+3,resp.indexOf("}")-2)
|
||||
return recordId
|
||||
}
|
||||
|
||||
export function createAuthority(name:string):string{
|
||||
const resp=cliTest("authority reserve "+name);
|
||||
expect(resp).toBeDefined;
|
||||
|
||||
const jsonResp = JSON.parse(cliTest("authority whois "+name))
|
||||
expect(jsonResp).toBeDefined;
|
||||
|
||||
return jsonResp[0].auction.id
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import {cliTest} from './helper';
|
||||
import {cliTest,createBond,createRecord} from './helper';
|
||||
|
||||
const args= "name "
|
||||
|
||||
@ -8,7 +8,11 @@ var name: string;
|
||||
describe("test names",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bond id
|
||||
const bondId = createBond("aphoton","10000000")
|
||||
|
||||
// get record id
|
||||
recordId=createRecord("./test/examples/watcher.yml",bondId)
|
||||
});
|
||||
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
import {cliTest} from './helper';
|
||||
import {cliTest,createBond} from './helper';
|
||||
|
||||
const args= "record "
|
||||
const filename = "./test/examples/watcher.yml"
|
||||
|
||||
var recordId: string;
|
||||
var filename: string;
|
||||
var bondId: string;
|
||||
|
||||
describe("test names",() => {
|
||||
describe("test record",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bond id
|
||||
// get bondId
|
||||
bondId=createBond("aphoton","1000000000")
|
||||
});
|
||||
|
||||
it("publish record",async ()=>{
|
||||
|
14
test/status.test.ts
Normal file
14
test/status.test.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "status "
|
||||
|
||||
var recordId: string;
|
||||
var name: string;
|
||||
|
||||
describe("test status",() => {
|
||||
|
||||
it("get status",async ()=>{
|
||||
const resp=cliTest(args);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user