Add CLI tests and setup CI #53
@ -76,7 +76,7 @@ describe('Test laconic CLI commands', () => {
|
||||
});
|
||||
|
||||
describe('Bond operations', () => {
|
||||
const bondBalance = 1000000000;
|
||||
let bondBalance = 1000000000;
|
||||
const bondOwner = testAccount;
|
||||
let bondId: string;
|
||||
|
||||
@ -123,16 +123,63 @@ describe('Test laconic CLI commands', () => {
|
||||
expect(outputObj[0]).toEqual(expectedBond);
|
||||
});
|
||||
|
||||
test('laconic cns bond refill --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
||||
// TODO
|
||||
test('laconic cns bond refill --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
||||
const bondRefillAmount = 1000;
|
||||
bondBalance += bondRefillAmount;
|
||||
|
||||
const result = spawnSync('laconic', ['cns', 'bond', 'refill', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondRefillAmount.toString()]);
|
||||
const outputObj = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
expect(outputObj).toEqual({ success: true });
|
||||
|
||||
// Check updated bond
|
||||
const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
||||
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
||||
|
||||
// Expected bond
|
||||
const expectedBond = getBondObj({ id: bondId, owner: bondOwner, balance: bondBalance });
|
||||
|
||||
expect(bondOutputObj.length).toEqual(1);
|
||||
expect(bondOutputObj[0]).toEqual(expectedBond);
|
||||
});
|
||||
|
||||
test('laconic cns bond withdraw --id <bond_id> --type <type> --quantity <quantity>', async () => {
|
||||
// TODO
|
||||
const bondWithdrawAmount = 500;
|
||||
bondBalance -= bondWithdrawAmount;
|
||||
|
||||
const result = spawnSync('laconic', ['cns', 'bond', 'withdraw', '--id', bondId, '--type', TOKEN_TYPE, '--quantity', bondWithdrawAmount.toString()]);
|
||||
const outputObj = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
expect(outputObj).toEqual({ success: true });
|
||||
|
||||
// Check updated bond
|
||||
const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
||||
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
||||
|
||||
// Expected bond
|
||||
const expectedBond = getBondObj({ id: bondId, owner: bondOwner, balance: bondBalance });
|
||||
|
||||
// Expect balance to be deducted (also deducts gas)
|
||||
expect(bondOutputObj.length).toEqual(1);
|
||||
expect(bondOutputObj[0]).toEqual(expectedBond);
|
||||
});
|
||||
|
||||
test('laconic cns bond cancel --id <bond_id>', async () => {
|
||||
// TODO
|
||||
const result = spawnSync('laconic', ['cns', 'bond', 'cancel', '--id', bondId]);
|
||||
const outputObj = checkResultAndRetrieveOutput(result);
|
||||
|
||||
// Expected output
|
||||
expect(outputObj).toEqual({ success: true });
|
||||
|
||||
// Check updated bond
|
||||
const bondResult = spawnSync('laconic', ['cns', 'bond', 'get', '--id', bondId]);
|
||||
const bondOutputObj = checkResultAndRetrieveOutput(bondResult);
|
||||
|
||||
// Expect empty object
|
||||
expect(bondOutputObj.length).toEqual(1);
|
||||
expect(bondOutputObj[0]).toEqual({ id: '', owner: '', balance: [] });
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user