Skip to content

Commit

Permalink
test: increase max-retries
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 30, 2024
1 parent 4a07907 commit 4cac5cc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
4 changes: 3 additions & 1 deletion multichain-testing/test/auto-stake-it.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { makeQueryClient } from '../tools/query.js';
import type { SetupContextWithWallets } from './support.js';
import { chainConfig, commonSetup } from './support.js';
import { AUTO_STAKE_IT_DELEGATIONS_TIMEOUT } from './config.js';

const test = anyTest as TestFn<SetupContextWithWallets>;

Expand Down Expand Up @@ -179,7 +180,8 @@ const autoStakeItScenario = test.macro({
const { delegation_responses } = await retryUntilCondition(
() => remoteQueryClient.queryDelegations(icaAddress),
({ delegation_responses }) => !!delegation_responses.length,
`delegations visible on ${chainName}`,
`auto-stake-it delegations visible on ${chainName}`,
AUTO_STAKE_IT_DELEGATIONS_TIMEOUT,
);
t.log('delegation balance', delegation_responses[0]?.balance);
t.like(
Expand Down
32 changes: 32 additions & 0 deletions multichain-testing/test/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { RetryOptions } from '../tools/sleep.js';

/**
* 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 provides 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,
};

/**
* Wait 2 minutes to ensure:
* - IBC Transfer from LocalAccount -> ICA Account Completes
* - Delegation from ICA Account (initiated from SwingSet) Completes
* - Delegations are visible via LCD (API Endpoint)
*
* Most of the time this finishes in <7 seconds, but other times it
* appears to take much longer.
*/
export const AUTO_STAKE_IT_DELEGATIONS_TIMEOUT: RetryOptions = {
retryIntervalMs: 5000,
maxRetries: 24,
};
20 changes: 2 additions & 18 deletions multichain-testing/test/stake-ica.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,13 @@ import {
} from './support.js';
import { makeDoOffer } from '../tools/e2e-tools.js';
import { makeQueryClient } from '../tools/query.js';
import { sleep, type RetryOptions } from '../tools/sleep.js';
import { sleep } from '../tools/sleep.js';
import { STAKING_REWARDS_TIMEOUT } from './config.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
6 changes: 4 additions & 2 deletions multichain-testing/tools/ibc-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ type SimpleChainAddress = {
chainName: string;
};

export const DEFAULT_TIMEOUT_NS = 1893456000000000000n;
// 2030-01-01T00:00:00Z
export const DEFAULT_TIMEOUT_NS =
1893456000n * NANOSECONDS_PER_MILLISECOND * MILLISECONDS_PER_SECOND;

/**
* @param {number} [ms] current time in ms (e.g. Date.now())
* @param {bigint} [minutes=5n] number of minutes in the future
* @returns {bigint} nanosecond timestamp 5 mins in the future */
* @returns {bigint} nanosecond timestamp absolute since Unix epoch */
export const getTimeout = (ms: number = 0, minutes = 5n) => {
// UNTIL #9200. timestamps are getting clobbered somewhere along the way
// and we are observing failed transfers with timeouts years in the past.
Expand Down

0 comments on commit 4cac5cc

Please sign in to comment.