Tests for registry-cli #32
5
jest.config.js
Normal file
5
jest.config.js
Normal file
@ -0,0 +1,5 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
@ -7,15 +7,18 @@
|
||||
"license": "UNLICENSED",
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/jest": "^29.5.0",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/lodash": "^4.14.182",
|
||||
"@types/node": "^17.0.25",
|
||||
"@types/yargs": "^17.0.10",
|
||||
"jest": "^29.5.0",
|
||||
"ts-jest": "^29.0.5",
|
||||
"typescript": "^4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs-extra": "^10.1.0",
|
||||
"@cerc-io/laconic-sdk": "0.1.6",
|
||||
"fs-extra": "^10.1.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-clean": "^2.2.3",
|
||||
@ -24,7 +27,8 @@
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"clean": "rm -rf ./dist",
|
||||
"build": "tsc"
|
||||
"build": "tsc",
|
||||
"test": "jest --runInBand --verbose"
|
||||
},
|
||||
"bin": {
|
||||
"laconic": "bin/laconic"
|
||||
|
12
test/account.test.ts
Normal file
12
test/account.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "account "
|
||||
export var address=""
|
||||
|
||||
describe("test account",() => {
|
||||
it("get account should return account details",async ()=>{
|
||||
const resp=JSON.parse(cliTest(args+"get"));
|
||||
expect(resp).toBeDefined;
|
||||
address=resp[0].address
|
||||
});
|
||||
});
|
11
test/auction.test.ts
Normal file
11
test/auction.test.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "auction "
|
||||
|
||||
describe("test auction",() => {
|
||||
it("bid commit",async ()=>{
|
||||
// const resp=JSON.parse(cliTest(args+" bid commit"));
|
||||
// expect(resp).toBeDefined;
|
||||
expect(0).toEqual(0);
|
||||
});
|
||||
});
|
80
test/bond.test.ts
Normal file
80
test/bond.test.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "bond "
|
||||
const quantity=1000000000
|
||||
const refillQuantity=100
|
||||
const withdrawQuantity=100
|
||||
const type="aphoton"
|
||||
|
||||
var bondId: string;
|
||||
var address: string;
|
||||
var recordId: string;
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
|
||||
it("create bond",async ()=>{
|
||||
const resp=cliTest(args+"create --type "+type+" --quantity "+quantity);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("list bond",async ()=>{
|
||||
const resp=cliTest(args+"list");
|
||||
bondId=JSON.parse(resp)[0].id
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("get bond",async ()=>{
|
||||
const resp=cliTest(args+"get --id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("list bonds by owner",async ()=>{
|
||||
const resp=cliTest(args+"list --owner "+address);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("refill bond",async ()=>{
|
||||
const resp=cliTest(args+"refill --id "+bondId+" --type "+type+" --quantity "+refillQuantity);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("withdraw funds from bond",async ()=>{
|
||||
const resp=cliTest(args+"withdraw --id "+bondId+" --type "+type+" --quantity "+withdrawQuantity);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("cancel bond",async ()=>{
|
||||
const resp=cliTest(args+"cancel --id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("associate bond with record",async ()=>{
|
||||
const resp=cliTest(args+"associate --id "+recordId+" --bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("dissociate bond from record",async ()=>{
|
||||
const resp=cliTest(args+"dissociate --id "+recordId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("dissociate all records from bond",async ()=>{
|
||||
const resp=cliTest(args+"records dissociate --bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("reassociate all records from bond",async ()=>{
|
||||
const resp=cliTest(args+"records reassociate --old-bond-id "+bondId+" --new-bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
});
|
5
test/helper.ts
Normal file
5
test/helper.ts
Normal file
@ -0,0 +1,5 @@
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
export const cliTest = (args: any) => {
|
||||
return execSync(`./bin/laconic cns ${args}`).toString();
|
||||
};
|
34
test/name.test.ts
Normal file
34
test/name.test.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "name "
|
||||
|
||||
var recordId: string;
|
||||
var name: string;
|
||||
|
||||
describe("test names",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get record id
|
||||
});
|
||||
|
||||
|
||||
it("set name",async ()=>{
|
||||
const resp=cliTest(args+"set "+name+" "+recordId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("lookup name",async ()=>{
|
||||
const resp=cliTest(args+"lookup "+ name);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("resolve name",async ()=>{
|
||||
const resp=cliTest(args+"resolve "+name);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("delelte name",async ()=>{
|
||||
const resp=cliTest(args+"delete "+name);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
});
|
29
test/record.test.ts
Normal file
29
test/record.test.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {cliTest} from './helper';
|
||||
|
||||
const args= "record "
|
||||
|
||||
var recordId: string;
|
||||
var filename: string;
|
||||
var bondId: string;
|
||||
|
||||
describe("test names",() => {
|
||||
|
||||
beforeAll(async () => {
|
||||
// get bond id
|
||||
});
|
||||
|
||||
it("publish record",async ()=>{
|
||||
const resp=cliTest(args+"publish --filename "+filename+" --bond-id "+bondId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("get record",async ()=>{
|
||||
const resp=cliTest(args+"get --id "+recordId);
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
|
||||
it("list records",async ()=>{
|
||||
const resp=cliTest(args+"list");
|
||||
expect(resp).toBeDefined;
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user