Rename constants and helper methods
All checks were successful
Tests / cli_tests (18.x) (pull_request) Successful in 8m53s

This commit is contained in:
Prathamesh Musale 2024-01-29 09:58:58 +05:30
parent 85827c8466
commit a0cd3443c5
3 changed files with 18 additions and 18 deletions

View File

@ -1,4 +1,3 @@
# TODO: Remove
name: Tests
on:
pull_request:

View File

@ -5,8 +5,8 @@ import { spawnSync } from 'child_process';
import {
CHAIN_ID,
TOKEN_TYPE,
COMMIT_DURATION,
REVEAL_DURATION,
AUCTION_COMMIT_DURATION,
AUCTION_REVEAL_DURATION,
delay,
checkResultAndRetrieveOutput,
createBond,
@ -15,7 +15,7 @@ import {
getRecordObj,
getAuthorityObj,
getAuctionObj,
getBidObject
getBidObj
} from './helpers';
describe('Test laconic CLI commands', () => {
@ -45,18 +45,18 @@ describe('Test laconic CLI commands', () => {
expect(errorOutput).toContain('Commands:');
});
// TODO: Break up tests into separate files
// TODO: Add tests for CNS commands with all available flags
describe('laconic CNS commands', () => {
const initialAccountBalance = Number('100000000000000000000000000');
const testAccount = process.env.TEST_ACCOUNT;
const testAccount2 = 'ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu';
assert(testAccount, 'TEST_ACCOUNT not set in env');
const testAccount2 = 'ethm1vc62ysqu504at932jjq8pwrqgjt67rx6ggn5yu';
const initialAccountBalance = Number('100000000000000000000000000');
const testAuthorityName = 'laconic';
let testAuctionId: string;
const testRecordFilePath = 'test/data/watcher-record.yml';
let testRecordId: string, testRecordBondId: string;
let testAuctionId: string, testRecordId: string, testRecordBondId: string;
test('laconic cns status', async () => {
const result = spawnSync('laconic', ['cns', 'status']);
@ -76,8 +76,8 @@ describe('Test laconic CLI commands', () => {
});
describe('Bond operations', () => {
let bondBalance = 1000000000;
const bondOwner = testAccount;
let bondBalance = 1000000000;
let bondId: string;
test('laconic cns bond create --type <type> --quantity <quantity> --gas <gas> --fees <fees>', async () => {
@ -161,7 +161,7 @@ describe('Test laconic CLI commands', () => {
// Expected bond
const expectedBond = getBondObj({ id: bondId, owner: bondOwner, balance: bondBalance });
// Expect balance to be deducted (also deducts gas)
// Expect balance to be deducted
expect(bondOutputObj.length).toEqual(1);
expect(bondOutputObj[0]).toEqual(expectedBond);
});
@ -376,13 +376,13 @@ describe('Test laconic CLI commands', () => {
test('laconic cns auction bid reveal <auction_id> <file_path>', async () => {
// Wait for auction commits duration (60s)
await delay(COMMIT_DURATION * 1000);
await delay(AUCTION_COMMIT_DURATION * 1000);
const auctionResult = spawnSync('laconic', ['cns', 'auction', 'get', testAuctionId]);
const auctionOutputObj = checkResultAndRetrieveOutput(auctionResult);
const expectedAuction = getAuctionObj({ owner: testAccount, status: 'reveal' });
const expectedBid = getBidObject({ bidder: testAccount });
const expectedBid = getBidObj({ bidder: testAccount });
expect(auctionOutputObj[0]).toMatchObject(expectedAuction);
expect(auctionOutputObj[0].bids[0]).toMatchObject(expectedBid);
@ -401,7 +401,7 @@ describe('Test laconic CLI commands', () => {
bidderAddress: testAccount,
bidAmount: `${bidAmount}aphoton`
});
}, (COMMIT_DURATION + 5) * 1000);
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
});
describe('Name authority operations (post auction)', () => {
@ -410,7 +410,7 @@ describe('Test laconic CLI commands', () => {
test('laconic cns authority whois <authority_name>', async () => {
// Wait for auction reveals duration (60s)
await delay(REVEAL_DURATION * 1000);
await delay(AUCTION_REVEAL_DURATION * 1000);
const result = spawnSync('laconic', ['cns', 'authority', 'whois', testAuthorityName]);
const outputObj = checkResultAndRetrieveOutput(result);
@ -420,7 +420,7 @@ describe('Test laconic CLI commands', () => {
expect(outputObj.length).toEqual(1);
expect(outputObj[0]).toMatchObject(expectedAuthority);
}, (REVEAL_DURATION + 5) * 1000);
}, (AUCTION_REVEAL_DURATION + 5) * 1000);
test('laconic cns authority bond set laconic <bond_id>', async () => {
// Create a new bond to be set on the authority

View File

@ -4,13 +4,14 @@ import { SpawnSyncReturns, spawnSync } from 'child_process';
export const CHAIN_ID = 'laconic_9000-1';
export const TOKEN_TYPE = 'aphoton';
export const AUCTION_FEES = {
commit: 1000000,
reveal: 1000000,
minimumBid: 5000000
};
export const COMMIT_DURATION = 60; // 60s
export const REVEAL_DURATION = 60; // 60s
export const AUCTION_COMMIT_DURATION = 60; // 60s
export const AUCTION_REVEAL_DURATION = 60; // 60s
export function checkResultAndRetrieveOutput(result: SpawnSyncReturns<Buffer>): any {
expect(result.status).toBe(0);
@ -96,7 +97,7 @@ export function getAuctionObj(params: { owner: string, status?: string }): any {
};
}
export function getBidObject(params: { bidder: string, status?: string }): any {
export function getBidObj(params: { bidder: string, status?: string }): any {
return {
bidderAddress: params.bidder,
status: params.status || 'commit',