From 928616e5da636c9bcc78075a7a9644cc59f01aa3 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Wed, 2 Oct 2024 11:54:23 -0400 Subject: [PATCH] feat: enable faucet on agoric --- multichain-testing/config.yaml | 4 +- multichain-testing/test/tools/wallet.test.ts | 85 +++++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/multichain-testing/config.yaml b/multichain-testing/config.yaml index 8bb75beeeb49..b95a344dadc3 100644 --- a/multichain-testing/config.yaml +++ b/multichain-testing/config.yaml @@ -18,12 +18,14 @@ chains: updateConfig: file: scripts/update-config.sh faucet: - enabled: false + enabled: true + type: starship ports: rest: 1317 rpc: 26657 exposer: 38087 grpc: 9090 + faucet: 8082 resources: cpu: 1 memory: 4Gi diff --git a/multichain-testing/test/tools/wallet.test.ts b/multichain-testing/test/tools/wallet.test.ts index bc76ab8b9931..34308259a24c 100644 --- a/multichain-testing/test/tools/wallet.test.ts +++ b/multichain-testing/test/tools/wallet.test.ts @@ -6,44 +6,51 @@ import { commonSetup } from '../support.js'; const test = anyTest as TestFn>; -const walletScenario = test.macro(async (t, scenario: string) => { - const { useChain, retryUntilCondition } = await commonSetup(t); - - const prefix = useChain(scenario).chain.bech32_prefix; - const wallet = await createWallet(prefix); - const addr = (await wallet.getAccounts())[0].address; - t.regex(addr, new RegExp(`^${prefix}1`)); - t.log('Made temp wallet:', addr); - - const apiUrl = await useChain(scenario).getRestEndpoint(); - const queryClient = makeQueryClient(apiUrl); - t.log('Made query client'); - - const { balances } = await queryClient.queryBalances(addr); - t.log('Beginning balances:', balances); - t.deepEqual(balances, []); - - const { creditFromFaucet } = useChain(scenario); - t.log('Requesting faucet funds'); - - await creditFromFaucet(addr); - // XXX needed to avoid race condition between faucet POST and LCD Query - // see https://github.com/cosmology-tech/starship/issues/417 - const { balances: updatedBalances } = await retryUntilCondition( - () => queryClient.queryBalances(addr), - ({ balances }) => !!balances.length, - `${scenario} balance available from faucet`, - ); - - const expectedDenom = scenario === 'osmosis' ? 'uosmo' : 'uatom'; - t.like(updatedBalances, [{ denom: expectedDenom, amount: '10000000000' }]); - t.log('Updated balances:', updatedBalances); - - const bondDenom = useChain(scenario).chain.staking?.staking_tokens?.[0].denom; - t.truthy(bondDenom, 'bond denom found'); - const { balance } = await queryClient.queryBalance(addr, bondDenom!); - t.deepEqual(balance, { denom: bondDenom, amount: '10000000000' }); +const walletScenario = test.macro({ + title: (_, chainName: string) => + `create a wallet and get tokens on ${chainName}`, + exec: async (t, chainName: string) => { + const { useChain, retryUntilCondition } = await commonSetup(t); + + const { bech32_prefix, staking } = useChain(chainName).chain; + const wallet = await createWallet(bech32_prefix); + const addr = (await wallet.getAccounts())[0].address; + t.regex(addr, new RegExp(`^${bech32_prefix}1`)); + t.log('Made temp wallet:', addr); + + const apiUrl = await useChain(chainName).getRestEndpoint(); + const queryClient = makeQueryClient(apiUrl); + t.log('Made query client'); + + const { balances } = await queryClient.queryBalances(addr); + t.log('Beginning balances:', balances); + t.deepEqual(balances, []); + + const { creditFromFaucet } = useChain(chainName); + t.log('Requesting faucet funds'); + + await creditFromFaucet(addr); + // XXX needed to avoid race condition between faucet POST and LCD Query + // see https://github.com/cosmology-tech/starship/issues/417 + const { balances: updatedBalances } = await retryUntilCondition( + () => queryClient.queryBalances(addr), + ({ balances }) => !!balances.length, + `${chainName} balance available from faucet`, + ); + + const expectedDenom = staking?.staking_tokens?.[0]?.denom; + t.assert(expectedDenom, 'expected denom found in registry'); + t.like(updatedBalances, [{ denom: expectedDenom, amount: '10000000000' }]); + t.log('Updated balances:', updatedBalances); + + const bondDenom = + useChain(chainName).chain.staking?.staking_tokens?.[0].denom; + t.truthy(bondDenom, 'bond denom found'); + const { balance } = await queryClient.queryBalance(addr, bondDenom!); + t.deepEqual(balance, { denom: bondDenom, amount: '10000000000' }); + }, }); -test('create a wallet and get tokens (osmosis)', walletScenario, 'osmosis'); -test('create a wallet and get tokens (cosmoshub)', walletScenario, 'cosmoshub'); +test(walletScenario, 'osmosis'); +test(walletScenario, 'cosmoshub'); +test(walletScenario, 'agoric');