Skip to content

Commit

Permalink
Get tx fees from config for auction tests (#84)
Browse files Browse the repository at this point in the history
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: https://git.vdb.to/cerc-io/laconic-registry-cli/pulls/84
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
  • Loading branch information
2 people authored and nabarun committed Sep 25, 2024
1 parent 0342254 commit c770d14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
8 changes: 5 additions & 3 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
getAuctionObj,
getBidObj,
updateGasAndFeesConfig,
AUCTION_STATUS
AUCTION_STATUS,
getFeesConfig
} from './helpers';

describe('Test laconic CLI commands', () => {
Expand Down Expand Up @@ -715,13 +716,14 @@ describe('Test laconic CLI commands', () => {
}, (AUCTION_COMMIT_DURATION + 5) * 1000);
});

describe.only('Provider Auction operations', () => {
describe('Provider Auction operations', () => {
const txFees = getFeesConfig();

const commitFee = 1000;
const revealFee = 1000;
const maxPrice = 1000000;
const numProviders = 2;
const bidderInitialBlanace = 1000000000;
const txFees = 200000;
testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350';

const bidderAccounts = [
Expand Down
17 changes: 13 additions & 4 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { SpawnSyncReturns, spawnSync } from 'child_process';
import { Arguments } from 'yargs';

import { getConfig } from '../src/util';
import { StdFee } from '@cosmjs/stargate';

import { getConfig, getGasAndFees } from '../src/util';

export const CHAIN_ID = 'laconic_9000-1';
export const TOKEN_TYPE = 'alnt';
export const CONFIG_FILE = 'config.yml';

export enum AUCTION_STATUS {
COMMIT = 'commit',
Expand Down Expand Up @@ -133,9 +137,14 @@ export async function delay (ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

export function getFeesConfig (): number {
const { services: { registry: registryConfig } } = getConfig(CONFIG_FILE);
const fee = getGasAndFees({} as Arguments, registryConfig);
return Number((fee as StdFee).amount[0].amount);
}

export function updateGasAndFeesConfig (gas?: string | null, fees?: string | null, gasPrice?: string | null): void {
const configFilePath = './config.yml';
const config = getConfig(path.resolve(configFilePath));
const config = getConfig(path.resolve(CONFIG_FILE));

if (gas) {
config.services.registry.gas = gas;
Expand All @@ -156,7 +165,7 @@ export function updateGasAndFeesConfig (gas?: string | null, fees?: string | nul
}

try {
fs.writeFileSync(configFilePath, yaml.dump(config), 'utf8');
fs.writeFileSync(CONFIG_FILE, yaml.dump(config), 'utf8');
} catch (e) {
console.error('Error writing config file:', e);
throw e;
Expand Down

0 comments on commit c770d14

Please sign in to comment.