Add tests for name authority operations commands
Some checks failed
Tests / cli_tests (18.x) (pull_request) Failing after 3m39s
Some checks failed
Tests / cli_tests (18.x) (pull_request) Failing after 3m39s
This commit is contained in:
parent
f8dee0d8d4
commit
19ac893020
@ -82,7 +82,7 @@ describe('Test laconic CLI commands', () => {
|
||||
expect(output.length).toBeGreaterThan(0);
|
||||
const outputObj = JSON.parse(output);
|
||||
|
||||
// Expect output object to resultant bond id
|
||||
// Expect output object to have resultant bond id
|
||||
expect(outputObj).toHaveProperty('bondId');
|
||||
|
||||
bondId = outputObj.bondId;
|
||||
@ -294,6 +294,47 @@ describe('Test laconic CLI commands', () => {
|
||||
expect(outputObj[0]).toMatchObject(expectedRecord);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Name authority operations', () => {
|
||||
const authorityName = 'laconic';
|
||||
|
||||
test('laconic cns authority reserve <authority_name>', async () => {
|
||||
const result = spawnSync('laconic', ['cns', 'authority', 'reserve', authorityName]);
|
||||
|
||||
const output = result.stdout.toString().trim();
|
||||
const errorOutput = result.stderr.toString().trim();
|
||||
|
||||
expect(errorOutput).toBe('');
|
||||
expect(result.status).toBe(0);
|
||||
|
||||
expect(output.length).toBeGreaterThan(0);
|
||||
const outputObj = JSON.parse(output);
|
||||
|
||||
// Expect result
|
||||
expect(outputObj).toEqual({ success: true });
|
||||
});
|
||||
|
||||
test('laconic cns authority whois <authority_name>', async () => {
|
||||
const result = spawnSync('laconic', ['cns', 'authority', 'whois', authorityName]);
|
||||
|
||||
const output = result.stdout.toString().trim();
|
||||
const errorOutput = result.stderr.toString().trim();
|
||||
|
||||
expect(errorOutput).toBe('');
|
||||
expect(result.status).toBe(0);
|
||||
|
||||
expect(output.length).toBeGreaterThan(0);
|
||||
const outputObj = Array.from<any>(JSON.parse(output));
|
||||
|
||||
// Expected authority (still in auction)
|
||||
const expectedAuthority = getAuthority({ status: 'auction', auction: getAuction({ owner: existingAccount }) });
|
||||
|
||||
expect(outputObj.length).toEqual(1);
|
||||
expect(outputObj[0]).toMatchObject(expectedAuthority);
|
||||
expect(outputObj[0]).toHaveProperty('expiryTime');
|
||||
expect(outputObj[0].height).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -329,3 +370,40 @@ function getRecord(recordFilePath: string, params: { bondId: string, recordId: s
|
||||
attributes: recordContent.record
|
||||
};
|
||||
}
|
||||
|
||||
function getAuthority(params: { status: string, auction: any }): any {
|
||||
return {
|
||||
ownerAddress: '',
|
||||
ownerPublicKey: '',
|
||||
status: params.status,
|
||||
bondId: '',
|
||||
auction: params.auction || null
|
||||
};
|
||||
}
|
||||
|
||||
function getAuction(params: { owner: string, status?: string, bids?: any[] }): any {
|
||||
const auctionFees = {
|
||||
commit: 1000000,
|
||||
reveal: 1000000,
|
||||
minimumBid: 5000000
|
||||
};
|
||||
|
||||
return {
|
||||
status: params.status || 'commit',
|
||||
ownerAddress: params.owner,
|
||||
commitFee: {
|
||||
type: TOKEN_TYPE,
|
||||
quantity: auctionFees.commit
|
||||
},
|
||||
revealFee: {
|
||||
type: TOKEN_TYPE,
|
||||
quantity: auctionFees.reveal
|
||||
},
|
||||
minimumBid: {
|
||||
type: TOKEN_TYPE,
|
||||
quantity: auctionFees.minimumBid
|
||||
},
|
||||
winnerAddress: '',
|
||||
bids: params.bids || []
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user