Get tx fees from config for auction tests
All checks were successful
Lint / lint (18.x) (pull_request) Successful in 1m8s
Tests / cli_tests (18.x) (pull_request) Successful in 14m49s

This commit is contained in:
Prathamesh Musale 2024-09-25 20:54:58 +05:30
parent 7b5836c9c1
commit 56e9ba1829
2 changed files with 17 additions and 6 deletions

View File

@ -19,7 +19,8 @@ import {
getAuctionObj, getAuctionObj,
getBidObj, getBidObj,
updateGasAndFeesConfig, updateGasAndFeesConfig,
AUCTION_STATUS AUCTION_STATUS,
getFeesConfig
} from './helpers'; } from './helpers';
describe('Test laconic CLI commands', () => { describe('Test laconic CLI commands', () => {
@ -716,12 +717,13 @@ describe('Test laconic CLI commands', () => {
}); });
describe('Provider Auction operations', () => { describe('Provider Auction operations', () => {
const txFees = getFeesConfig();
const commitFee = 1000; const commitFee = 1000;
const revealFee = 1000; const revealFee = 1000;
const maxPrice = 1000000; const maxPrice = 1000000;
const numProviders = 2; const numProviders = 2;
const bidderInitialBlanace = 1000000000; const bidderInitialBlanace = 1000000000;
const txFees = 200000;
testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350'; testAuctionId = '5e9dd5501e965f25db4fa62635d0ce5f6c59d73ab1a2ea999f8c5bf2f6fb6350';
const bidderAccounts = [ const bidderAccounts = [

View File

@ -2,11 +2,15 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { SpawnSyncReturns, spawnSync } from 'child_process'; 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 CHAIN_ID = 'laconic_9000-1';
export const TOKEN_TYPE = 'alnt'; export const TOKEN_TYPE = 'alnt';
export const CONFIG_FILE = 'config.yml';
export enum AUCTION_STATUS { export enum AUCTION_STATUS {
COMMIT = 'commit', COMMIT = 'commit',
@ -133,9 +137,14 @@ export async function delay (ms: number): Promise<any> {
return new Promise((resolve) => setTimeout(resolve, ms)); 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 { export function updateGasAndFeesConfig (gas?: string | null, fees?: string | null, gasPrice?: string | null): void {
const configFilePath = './config.yml'; const config = getConfig(path.resolve(CONFIG_FILE));
const config = getConfig(path.resolve(configFilePath));
if (gas) { if (gas) {
config.services.registry.gas = gas; config.services.registry.gas = gas;
@ -156,7 +165,7 @@ export function updateGasAndFeesConfig (gas?: string | null, fees?: string | nul
} }
try { try {
fs.writeFileSync(configFilePath, yaml.dump(config), 'utf8'); fs.writeFileSync(CONFIG_FILE, yaml.dump(config), 'utf8');
} catch (e) { } catch (e) {
console.error('Error writing config file:', e); console.error('Error writing config file:', e);
throw e; throw e;