Skip to content

Commit

Permalink
fix(a3p): remove unnecessary waitForBlock calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Sep 25, 2024
1 parent 298654f commit 78de723
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 50 deletions.
3 changes: 1 addition & 2 deletions a3p-integration/proposals/z:acceptance/vaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@agoric/synthetic-chain';
import { getBalance } from './test-lib/utils.js';

test.serial('attempt to open vaults under the minimum amount', async t => {
test.only('attempt to open vaults under the minimum amount', async t => {
const activeVaultsBefore = await agops.vaults('list', '--from', USER1ADDR);
await bankSend(USER1ADDR, `20000000${ATOM_DENOM}`);
t.log('active vaults before:', activeVaultsBefore);
Expand Down Expand Up @@ -44,7 +44,6 @@ test.serial('open new vault', async t => {
const mint = '5.0';
const collateral = '10.0';
await openVault(USER1ADDR, mint, collateral);
await waitForBlock();

const istBalanceAfter = await getISTBalance(USER1ADDR);
const activeVaultsAfter = await agops.vaults('list', '--from', USER1ADDR);
Expand Down
53 changes: 5 additions & 48 deletions a3p-integration/proposals/z:acceptance/wallet.test.js
Original file line number Diff line number Diff line change
@@ -1,59 +1,18 @@
import test from 'ava';
import {
agoric,
makeAgd,
evalBundles,
GOV1ADDR,
GOV2ADDR,
CHAINID,
waitForBlock,
} from '@agoric/synthetic-chain';
import { readFile, writeFile } from 'node:fs/promises';
import {
agd,
getBalance,
replaceTemplateValuesInFile,
} from './test-lib/utils.js';
import { $ } from 'execa';
import { execFileSync } from 'node:child_process';

/**
* @param {string} fileName base file name without .tjs extension
* @param {Record<string, string>} replacements
*/
const replaceTemplateValuesInFile = async (fileName, replacements) => {
let script = await readFile(`${fileName}.tjs`, 'utf-8');
for (const [template, value] of Object.entries(replacements)) {
script = script.replaceAll(`{{${template}}}`, value);
}
await writeFile(`${fileName}.js`, script);
};

const showAndExec = (file, args, opts) => {
console.log('$', file, ...args);
return execFileSync(file, args, opts);
};

// @ts-expect-error string is not assignable to Buffer
const agd = makeAgd({ execFileSync: showAndExec }).withOpts({
keyringBackend: 'test',
});

/**
* @param {string[]} addresses
* @param {string} [targetDenom]
*/
const getBalance = async (addresses, targetDenom = undefined) => {
const balancesList = await Promise.all(
addresses.map(async address => {
const { balances } = await agd.query(['bank', 'balances', address]);

if (targetDenom) {
const balance = balances.find(({ denom }) => denom === targetDenom);
return Number(balance.amount);
}

return balances;
}),
);

return addresses.length === 1 ? balancesList[0] : balancesList;
};

test.serial(`send invitation via namesByAddress`, async t => {
const SUBMISSION_DIR = 'invitation-test-submission';
Expand All @@ -63,8 +22,6 @@ test.serial(`send invitation via namesByAddress`, async t => {
});

await evalBundles(SUBMISSION_DIR);
await waitForBlock(2);

const update = await agoric.follow('-lF', `:published.wallet.${GOV1ADDR}`);

t.is(
Expand Down

0 comments on commit 78de723

Please sign in to comment.