Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix multichain-testing waitForBlock #10932

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions multichain-testing/tools/e2e-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { makeTracer } from '@agoric/internal';
const trace = makeTracer('E2ET');

// The default of 6 retries was failing.
const SMART_WALLET_PROVISION_RETRIES = 15;
// XXX even 15 wasn't enough
const SMART_WALLET_PROVISION_RETRIES = 30;

const BLD = '000000ubld';

Expand Down Expand Up @@ -65,25 +66,29 @@ const makeBlockTool = ({ rpc, delay }) => {
}
};

let last;
const waitForBlock = async (times = 1, info = {}) => {
/**
* @param {number} [advance] number of blocks to wait for
* @param {object} [info] add to logging
* @returns {Promise<void>}
*/
const waitForBlock = async (advance = 1, info = {}) => {
await null;
for (let time = 0; time < times; time += 1) {
for (;;) {
const cur = await waitForBootstrap(2000, { ...info, last });

if (cur !== last) {
last = cur;
break;
}

await delay(1000, info);
}
time += 1;
const startHeight = await waitForBootstrap();
for (
let latestHeight = startHeight;
latestHeight < startHeight + advance;

) {
// Give some time for a new block
await delay(1000, { ...info, latestHeight });
latestHeight = await waitForBootstrap(2000, {
...info,
startHeight,
});
}
};

return { waitForBootstrap, waitForBlock };
return { waitForBlock };
};
/** @typedef {ReturnType<makeBlockTool>} BlockTool */

Expand Down Expand Up @@ -171,11 +176,13 @@ export const provisionSmartWallet = async (
progress({ send: balances, to: address });

/**
* Submit the `bank send` and wait for the next block.
* (Clients have an obligation not to submit >1 tx/block.)
*
* @param {string} denom
* @param {bigint} value
*/
const sendFromWhale = async (denom, value) => {
trace('sendFromWhale', address, denom, value);
const amount = `${value}${denom}`;
progress({ amount, to: address });
// TODO: refactor agd.tx to support a per-sender object
Expand All @@ -186,7 +193,7 @@ export const provisionSmartWallet = async (
from: whale,
yes: true,
});
await blockTool.waitForBlock(1, { step: 'bank send' });
await blockTool.waitForBlock(1, { address, step: 'bank send' });
};

for await (const [name, qty] of Object.entries(balances)) {
Expand All @@ -206,12 +213,12 @@ export const provisionSmartWallet = async (
{ chainId, from: address, yes: true },
);

trace('waiting for wallet to appear in vstorage', address);
const info = await retryUntilCondition(
() => q.queryData(`published.wallet.${address}.current`),
result => !!result,
`wallet in vstorage ${address}`,
{
log: () => {}, // suppress logs as this is already noisy
maxRetries: SMART_WALLET_PROVISION_RETRIES,
},
);
Expand Down
Loading