Add tests for bonds-records association commands

This commit is contained in:
Prathamesh Musale 2024-01-25 17:05:21 +05:30
parent 16cd3dedf9
commit 85827c8466

View File

@ -80,7 +80,7 @@ describe('Test laconic CLI commands', () => {
const bondOwner = testAccount;
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 outputObj = checkResultAndRetrieveOutput(result);
@ -265,16 +265,61 @@ describe('Test laconic CLI commands', () => {
});
describe('Bond records operations', () => {
test('laconic cns bond associate --id <record_id> --bond-id <bond_id>', async () => {
// TODO
});
let testRecordBondId2: string;
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 () => {
// 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);
});
});
});