Add CLI tests and setup CI #53

Merged
ashwin merged 23 commits from deep-stack/laconic-registry-cli:pm-add-tests into main 2024-01-29 04:46:32 +00:00
Showing only changes of commit 85827c8466 - Show all commits

View File

@ -80,7 +80,7 @@ describe('Test laconic CLI commands', () => {
const bondOwner = testAccount; const bondOwner = testAccount;
let bondId: string; let bondId: string;
test('laconic cns bond create --type <type> --quantity <quantity>', async () => { test('laconic cns bond create --type <type> --quantity <quantity> --gas <gas> --fees <fees>', async () => {
const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]); const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', TOKEN_TYPE, '--quantity', bondBalance.toString(), '--gas', '200000', '--fees', `200000${TOKEN_TYPE}`]);
const outputObj = checkResultAndRetrieveOutput(result); const outputObj = checkResultAndRetrieveOutput(result);
@ -265,16 +265,61 @@ describe('Test laconic CLI commands', () => {
}); });
describe('Bond records operations', () => { describe('Bond records operations', () => {
test('laconic cns bond associate --id <record_id> --bond-id <bond_id>', async () => { let testRecordBondId2: string;
// TODO
});
test('laconic cns bond dissociate --id <record_id>', async () => { test('laconic cns bond dissociate --id <record_id>', async () => {
// TODO const result = spawnSync('laconic', ['cns', 'bond', 'dissociate', '--id', testRecordId]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj).toEqual({ success: true });
const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
// Expected record
const expectedRecord = getRecordObj(testRecordFilePath, { bondId: '', recordId: testRecordId, names: null });
expect(recordOutputObj.length).toEqual(1);
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
});
test('laconic cns bond associate --id <record_id> --bond-id <bond_id>', async () => {
// Create a new bond to be associated with the record
({ bondId: testRecordBondId2 } = createBond(bondBalance));
const result = spawnSync('laconic', ['cns', 'bond', 'associate', '--id', testRecordId, '--bond-id', testRecordBondId2]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj).toEqual({ success: true });
const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
// Expected record
const expectedRecord = getRecordObj(testRecordFilePath, { bondId: testRecordBondId2, recordId: testRecordId, names: null });
expect(recordOutputObj.length).toEqual(1);
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
}); });
test('laconic cns bond records reassociate --old-bond-id <old_bond_id> --new-bond-id <new_bond_id>', async () => { test('laconic cns bond records reassociate --old-bond-id <old_bond_id> --new-bond-id <new_bond_id>', async () => {
// TODO const result = spawnSync('laconic', ['cns', 'bond', 'records', 'reassociate', '--old-bond-id', testRecordBondId2, '--new-bond-id', testRecordBondId]);
const outputObj = checkResultAndRetrieveOutput(result);
// Expected output
expect(outputObj).toEqual({ success: true });
const recordResult = spawnSync('laconic', ['cns', 'record', 'get', '--id', testRecordId]);
const recordOutputObj = checkResultAndRetrieveOutput(recordResult);
// Expected record
const expectedRecord = getRecordObj(testRecordFilePath, { bondId: testRecordBondId, recordId: testRecordId, names: null });
expect(recordOutputObj.length).toEqual(1);
expect(recordOutputObj[0]).toMatchObject(expectedRecord);
}); });
}); });
}); });