account, status and token tests

This commit is contained in:
0xmuralik 2023-03-29 13:47:42 +05:30
parent 30861621cf
commit a2237f3559
3 changed files with 46 additions and 3 deletions

View File

@ -1,12 +1,18 @@
import {cliTest} from './helper';
const args= "account "
export var address=""
const type= "aphoton"
const quantity="10"
const address="ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu"
describe("test account",() => {
it("get account should return account details",async ()=>{
const resp=JSON.parse(cliTest(args+"get"));
// send tokens to account to avoid account not found error
const sendResp=cliTest("tokens send --address "+address+" --type "+type+" --quantity "+quantity)
expect(sendResp).toBeDefined;
const resp=cliTest(args+"get --address "+address);
expect(resp).toBeDefined;
address=resp[0].address
expect(resp[0].address).toEqual(address)
});
});

View File

@ -7,5 +7,6 @@ describe("test status",() => {
it("get status",async ()=>{
const resp=cliTest(args);
expect(resp).toBeDefined;
expect(resp.node.network).toContain("laconic")
});
});

36
test/tokens.test.ts Normal file
View File

@ -0,0 +1,36 @@
import {cliTest} from './helper';
const args= "tokens "
const type= "aphoton"
const quantity=10
const address="ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu"
describe("test account",() => {
it("get account should return account details",async ()=>{
// balance before
var balanceBefore;
const beforeResp=cliTest("account get --address "+address);
if (beforeResp.stderr){
expect(beforeResp.stderr.toString()).toContain("account "+address+ " not found")
balanceBefore=0
} else{
balanceBefore=beforeResp[0].balance[0].quantity
}
// send tokens to account
const sendResp=cliTest(args+"send --address "+address+" --type "+type+" --quantity "+quantity)
expect(sendResp).toBeDefined;
// balance after
var balanceAfter;
const afterResp=cliTest("account get --address "+address);
if (afterResp.stderr){
expect(afterResp.stderr.toString()).toContain("account "+address+ " not found")
balanceAfter=0
} else{
balanceAfter=afterResp[0].balance[0].quantity
}
expect(balanceAfter-balanceBefore).toEqual(quantity)
});
});