Skip to content

Commit

Permalink
test: increase attempts for rewards available condition
Browse files Browse the repository at this point in the history
- refs: #9815
  • Loading branch information
0xpatrickdev committed Aug 28, 2024
1 parent 12c0dab commit 17a23a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 19 additions & 5 deletions multichain-testing/test/stake-ica.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@ import type { TestFn } from 'ava';
import { commonSetup, SetupContextWithWallets } from './support.js';
import { makeDoOffer } from '../tools/e2e-tools.js';
import { makeQueryClient } from '../tools/query.js';
import { sleep } from '../tools/sleep.js';
import { sleep, type RetryOptions } from '../tools/sleep.js';

const test = anyTest as TestFn<SetupContextWithWallets>;

const accounts = ['user1', 'user2'];

/**
* Wait 90 seconds to ensure staking rewards are available.
*
* While we expect staking rewards to be available after a
* single block (~5-12 seconds for most chains), this provide additional
* padding after observed failures in CI
* (https://github.com/Agoric/agoric-sdk/issues/9934).
*
* A more robust approach might consider Distribution params and the
* {@link FAUCET_POUR} constant to determine how many blocks it should take for
* rewards to be available.
*/
export const STAKING_REWARDS_TIMEOUT: RetryOptions = {
retryIntervalMs: 5000,
maxRetries: 18,
};

test.before(async t => {
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t);
// XXX not necessary for CI, but helpful for unexpected failures in
Expand Down Expand Up @@ -178,10 +195,7 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => {
return Number(total?.[0]?.amount) > 0;
},
`rewards available on ${scenario.chain}`,
{
retryIntervalMs: 5000,
maxRetries: 8,
},
STAKING_REWARDS_TIMEOUT,
);
t.log('reward:', total[0]);
t.log('WithrawReward offer from continuing inv');
Expand Down
2 changes: 1 addition & 1 deletion multichain-testing/tools/sleep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const sleep = (
setTimeout(resolve, ms);
});

type RetryOptions = {
export type RetryOptions = {
maxRetries?: number;
retryIntervalMs?: number;
} & SleepOptions;
Expand Down

0 comments on commit 17a23a7

Please sign in to comment.