diff --git a/src/testcases/run_in_band/interchaintx.test.ts b/src/testcases/run_in_band/interchaintx.test.ts index 28eec88a..e925c0bc 100644 --- a/src/testcases/run_in_band/interchaintx.test.ts +++ b/src/testcases/run_in_band/interchaintx.test.ts @@ -178,7 +178,7 @@ describe('Neutron / Interchain TXs', () => { validator: ( testState.wallets.cosmos.val1.address as cosmosclient.ValAddress ).toString(), - amount: '2000', + amount: '1000', denom: gaiaChain.denom, }, }), @@ -208,6 +208,79 @@ describe('Neutron / Interchain TXs', () => { async (delegations) => delegations.data.delegation_responses?.length == 1, ); + expect(res1.data.delegation_responses).toEqual([ + { + balance: { amount: '1000', denom: gaiaChain.denom }, + delegation: { + delegator_address: icaAddress1, + shares: '1000.000000000000000000', + validator_address: + 'cosmosvaloper18hl5c9xn5dze2g50uaw0l2mr02ew57zk0auktn', + }, + }, + ]); + const res2 = await rest.staking.delegatorDelegations( + gaiaChain.sdk as CosmosSDK, + icaAddress2 as unknown as AccAddress, + ); + expect(res2.data.delegation_responses).toEqual([]); + }); + test('check contract balance', async () => { + const res = await neutronChain.queryBalances(contractAddress); + const balance = res.balances.find( + (b) => b.denom === neutronChain.denom, + )?.amount; + expect(balance).toEqual('98000'); + }); + }); + + describe('DOUBLE ACK - Send Interchain TX', () => { + test('delegate from first ICA', async () => { + // it will delegate two times of passed amount - first from contract call, and second from successful sudo IBC response + const res = await neutronAccount.executeContract( + contractAddress, + JSON.stringify({ + delegate_double_ack: { + interchain_account_id: icaId1, + validator: ( + testState.wallets.cosmos.val1.address as cosmosclient.ValAddress + ).toString(), + amount: '500', + denom: gaiaChain.denom, + }, + }), + ); + expect(res.code).toEqual(0); + const sequenceId = getSequenceId(res.raw_log); + + await waitForAck(neutronChain, contractAddress, icaId1, sequenceId); + const qres = await getAck( + neutronChain, + contractAddress, + icaId1, + sequenceId, + ); + expect(qres).toMatchObject({ + success: ['/cosmos.staking.v1beta1.MsgDelegate'], + }); + + const ackSequenceId = sequenceId + 1; + await waitForAck(neutronChain, contractAddress, icaId1, ackSequenceId); + expect(qres).toMatchObject({ + success: ['/cosmos.staking.v1beta1.MsgDelegate'], + }); + }); + test('check validator state', async () => { + const res1 = await getWithAttempts( + gaiaChain.blockWaiter, + () => + rest.staking.delegatorDelegations( + gaiaChain.sdk as CosmosSDK, + icaAddress1 as unknown as AccAddress, + ), + async (delegations) => + delegations.data.delegation_responses?.length === 1, + ); expect(res1.data.delegation_responses).toEqual([ { balance: { amount: '2000', denom: gaiaChain.denom }, @@ -230,9 +303,11 @@ describe('Neutron / Interchain TXs', () => { const balance = res.balances.find( (b) => b.denom === neutronChain.denom, )?.amount; - expect(balance).toEqual('98000'); + // two interchain txs inside (2000 * 2 = 4000) + expect(balance).toEqual('94000'); }); }); + describe('Error cases', () => { test('delegate for unknown validator from second ICA', async () => { const res = await neutronAccount.executeContract(