Add tests for post auction name authority operations
This commit is contained in:
parent
d8a5b93a23
commit
74a5183ad8
@ -6,6 +6,7 @@ import {
|
|||||||
CHAIN_ID,
|
CHAIN_ID,
|
||||||
TOKEN_TYPE,
|
TOKEN_TYPE,
|
||||||
COMMIT_DURATION,
|
COMMIT_DURATION,
|
||||||
|
REVEAL_DURATION,
|
||||||
delay,
|
delay,
|
||||||
checkResultAndRetrieveOutput,
|
checkResultAndRetrieveOutput,
|
||||||
createBond,
|
createBond,
|
||||||
@ -246,7 +247,7 @@ describe('Test laconic CLI commands', () => {
|
|||||||
const outputObj = checkResultAndRetrieveOutput(result);
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
// Expected authority (still in auction)
|
// Expected authority (still in auction)
|
||||||
const expectedAuthority = getAuthorityObj({ status: 'auction', auction: getAuctionObj({ owner: testAccount }) });
|
const expectedAuthority = getAuthorityObj({ owner: '', status: 'auction', auction: getAuctionObj({ owner: testAccount }) });
|
||||||
|
|
||||||
expect(outputObj.length).toEqual(1);
|
expect(outputObj.length).toEqual(1);
|
||||||
expect(outputObj[0]).toMatchObject(expectedAuthority);
|
expect(outputObj[0]).toMatchObject(expectedAuthority);
|
||||||
@ -283,7 +284,7 @@ describe('Test laconic CLI commands', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns auction bid reveal <auction_id> <file_path>', async () => {
|
test('laconic cns auction bid reveal <auction_id> <file_path>', async () => {
|
||||||
// Wait for commits duration (60s)
|
// Wait for auction commits duration (60s)
|
||||||
await delay(COMMIT_DURATION * 1000);
|
await delay(COMMIT_DURATION * 1000);
|
||||||
|
|
||||||
const auctionResult = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]);
|
const auctionResult = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]);
|
||||||
@ -313,16 +314,79 @@ describe('Test laconic CLI commands', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Name authority operations (post auction)', () => {
|
describe('Name authority operations (post auction)', () => {
|
||||||
|
const testSubAuthorityName = 'echo.laconic';
|
||||||
|
const testSubAuthorityName2 = 'kube.laconic';
|
||||||
|
|
||||||
|
test('laconic cns authority whois <authority_name>', async () => {
|
||||||
|
// Wait for auction reveals duration (60s)
|
||||||
|
await delay(REVEAL_DURATION * 1000);
|
||||||
|
|
||||||
|
const result = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]);
|
||||||
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
|
// Expected authority (active)
|
||||||
|
const expectedAuthority = getAuthorityObj({ owner: testAccount, status: 'active', auction: null });
|
||||||
|
|
||||||
|
expect(outputObj.length).toEqual(1);
|
||||||
|
expect(outputObj[0]).toMatchObject(expectedAuthority);
|
||||||
|
}, (REVEAL_DURATION + 5) * 1000);
|
||||||
|
|
||||||
test('laconic cns authority bond set laconic <bond_id>', async () => {
|
test('laconic cns authority bond set laconic <bond_id>', async () => {
|
||||||
// TODO
|
// Create a new bond to be set on the authority
|
||||||
|
const bondBalance = 1000000000;
|
||||||
|
const { bondId } = createBond(bondBalance);
|
||||||
|
|
||||||
|
const result = spawnSync('laconic', ['cns', 'authority', 'bond', 'set', testAuthorityName, bondId]);
|
||||||
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
|
// Expected output
|
||||||
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
|
// Check updated authority
|
||||||
|
const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]);
|
||||||
|
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
||||||
|
|
||||||
|
// Expected authority (active with bond)
|
||||||
|
const expectedAuthority = getAuthorityObj({ owner: testAccount, status: 'active', auction: null, bondId: bondId });
|
||||||
|
|
||||||
|
expect(authorityOutputObj.length).toEqual(1);
|
||||||
|
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns authority reserve <sub_authority> (same owner)', async () => {
|
test('laconic cns authority reserve <sub_authority> (same owner)', async () => {
|
||||||
// TODO
|
const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testSubAuthorityName]);
|
||||||
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
|
// Expected output
|
||||||
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
|
// Check updated authority
|
||||||
|
const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testSubAuthorityName]);
|
||||||
|
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
||||||
|
|
||||||
|
// Expected authority (active with bond)
|
||||||
|
const expectedAuthority = getAuthorityObj({ owner: testAccount, status: 'active', auction: null });
|
||||||
|
|
||||||
|
expect(authorityOutputObj.length).toEqual(1);
|
||||||
|
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('laconic cns authority reserve <sub_authority> --owner <owner_address> (different owner)', async () => {
|
test('laconic cns authority reserve <sub_authority> --owner <owner_address> (different owner)', async () => {
|
||||||
// TODO
|
const result = spawnSync('laconic', ['cns', 'authority', 'reserve', testSubAuthorityName2, '--owner', testAccount2]);
|
||||||
|
const outputObj = checkResultAndRetrieveOutput(result);
|
||||||
|
|
||||||
|
// Expected output
|
||||||
|
expect(outputObj).toEqual({ success: true });
|
||||||
|
|
||||||
|
// Check updated authority
|
||||||
|
const authorityResult = spawnSync('laconic', ['cns', 'authority', 'whois', testSubAuthorityName2]);
|
||||||
|
const authorityOutputObj = checkResultAndRetrieveOutput(authorityResult);
|
||||||
|
|
||||||
|
// Expected authority (active with bond)
|
||||||
|
const expectedAuthority = getAuthorityObj({ owner: testAccount2, status: 'active', auction: null });
|
||||||
|
|
||||||
|
expect(authorityOutputObj.length).toEqual(1);
|
||||||
|
expect(authorityOutputObj[0]).toMatchObject(expectedAuthority);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ export const AUCTION_FEES = {
|
|||||||
minimumBid: 5000000
|
minimumBid: 5000000
|
||||||
};
|
};
|
||||||
export const COMMIT_DURATION = 60; // 60s
|
export const COMMIT_DURATION = 60; // 60s
|
||||||
|
export const REVEAL_DURATION = 60; // 60s
|
||||||
|
|
||||||
export function checkResultAndRetrieveOutput(result: SpawnSyncReturns<Buffer>): any {
|
export function checkResultAndRetrieveOutput(result: SpawnSyncReturns<Buffer>): any {
|
||||||
expect(result.status).toBe(0);
|
expect(result.status).toBe(0);
|
||||||
@ -66,13 +67,12 @@ export function getRecordObj(recordFilePath: string, params: { bondId: string, r
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAuthorityObj(params: { status: string, auction: any }): any {
|
export function getAuthorityObj(params: { owner: string, status: string, auction: any, bondId?: string }): any {
|
||||||
return {
|
return {
|
||||||
ownerAddress: '',
|
ownerAddress: params.owner,
|
||||||
ownerPublicKey: '',
|
|
||||||
status: params.status,
|
status: params.status,
|
||||||
bondId: '',
|
bondId: params.bondId || '',
|
||||||
auction: params.auction || null
|
auction: params.auction
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user