From 5e637084745a08a89b7e57366c09f2827e48c1cb Mon Sep 17 00:00:00 2001 From: emidev98 Date: Tue, 24 Oct 2023 14:28:13 +0200 Subject: [PATCH 1/7] feat: ica & icq module params test --- integration-tests/src/modules/auth.test.ts | 69 ++++---- integration-tests/src/modules/ica.test.ts | 179 +++++++++++++++++++++ integration-tests/src/modules/icq.test.ts | 50 ++++++ 3 files changed, 261 insertions(+), 37 deletions(-) create mode 100644 integration-tests/src/modules/ica.test.ts create mode 100644 integration-tests/src/modules/icq.test.ts diff --git a/integration-tests/src/modules/auth.test.ts b/integration-tests/src/modules/auth.test.ts index d3ec2bf3..d1146a5e 100644 --- a/integration-tests/src/modules/auth.test.ts +++ b/integration-tests/src/modules/auth.test.ts @@ -1,6 +1,6 @@ import { getMnemonics } from "../helpers/mnemonics"; import { getLCDClient } from "../helpers/lcd.connection"; -import { ContinuousVestingAccount, Coins, MnemonicKey, MsgCreateVestingAccount } from "@terra-money/feather.js"; +import { ContinuousVestingAccount, Coins, MnemonicKey, MsgCreateVestingAccount, Coin } from "@terra-money/feather.js"; import moment from "moment"; import { blockInclusion } from "../helpers/const"; @@ -31,46 +31,41 @@ describe("Auth Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0 }); test('Must have vesting accounts created on genesis', async () => { - try { - // Query genesis vesting account info - const vestAccAddr = accounts.genesisVesting.accAddress("terra"); - const vestAcc = (await LCD.chain1.auth.accountInfo(vestAccAddr)) as ContinuousVestingAccount; + // Query genesis vesting account info + const vestAccAddr = accounts.genesisVesting.accAddress("terra"); + const vestAcc = (await LCD.chain1.auth.accountInfo(vestAccAddr)) as ContinuousVestingAccount; - // Validate the instance of the object - expect(vestAcc) - .toBeInstanceOf(ContinuousVestingAccount); - // Validate the vesting start has been set in the past - expect(vestAcc.start_time) - .toBeLessThan(moment().unix()); - // Validate the vesting end has been set in the past - expect(vestAcc.base_vesting_account.end_time) - .toBeGreaterThan(moment().unix()); - // Validate the original vesting and delegated vesting - expect(vestAcc.base_vesting_account.original_vesting) - .toStrictEqual(Coins.fromString("10000000000uluna")); - expect(vestAcc.base_vesting_account.delegated_vesting) - .toStrictEqual(Coins.fromString("10000000000uluna")); + // Validate the instance of the object + expect(vestAcc) + .toBeInstanceOf(ContinuousVestingAccount); + // Validate the vesting start has been set in the past + expect(vestAcc.start_time) + .toBeLessThan(moment().unix()); + // Validate the vesting end has been set in the past + expect(vestAcc.base_vesting_account.end_time) + .toBeGreaterThan(moment().unix()); + // Validate the original vesting and delegated vesting + expect(vestAcc.base_vesting_account.original_vesting) + .toStrictEqual(Coins.fromString("10000000000uluna")); + expect(vestAcc.base_vesting_account.delegated_vesting) + .toStrictEqual(Coins.fromString("10000000000uluna")); - // Validate other params from base account - expect(vestAcc.base_vesting_account.base_account.address) - .toBe(vestAccAddr); - expect(vestAcc.getAccountNumber()) - .toBe(3); - expect(vestAcc.getPublicKey()) - .toBeNull(); - expect(vestAcc.getSequenceNumber()) - .toBe(0); + // Validate other params from base account + expect(vestAcc.base_vesting_account.base_account.address) + .toBe(vestAccAddr); + expect(vestAcc.getAccountNumber()) + .toBe(3); + expect(vestAcc.getPublicKey()) + .toBeNull(); + expect(vestAcc.getSequenceNumber()) + .toBe(0); - // Query the non-vested account balance - const vestAccBalance = await LCD.chain1.bank.balance(vestAccAddr); + // Query the non-vested account balance + const vestAccBalance = await LCD.chain1.bank.balance(vestAccAddr); - // Validate the unlocked balance is still available - expect(vestAccBalance[0]) - .toStrictEqual(Coins.fromString("990000000000uluna")); - } - catch (e) { - expect(e).toBeUndefined(); - } + // Validate the unlocked balance is still available + expect(vestAccBalance[0].get("uluna")) + .toStrictEqual(Coin.fromString("990000000000uluna")); }); test('Must create a random vesting account', async () => { diff --git a/integration-tests/src/modules/ica.test.ts b/integration-tests/src/modules/ica.test.ts new file mode 100644 index 00000000..5235924f --- /dev/null +++ b/integration-tests/src/modules/ica.test.ts @@ -0,0 +1,179 @@ +import { getLCDClient } from "../helpers/lcd.connection"; + +describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modules/apps/27-interchain-accounts) ", () => { + // Prepare environment clients, accounts and wallets + const LCD = getLCDClient(); + + test('Must contain the expected module params', async () => { + // Query ica + const res = await LCD.chain2.icqV1.params("test-2"); + + expect(res.params) + .toStrictEqual({ + "host_enabled": true, + "allow_queries": [ + "/alliance.alliance.Query/AllAllianceValidators", + "/alliance.alliance.Query/AllAlliancesDelegations", + "/alliance.alliance.Query/Alliance", + "/alliance.alliance.Query/AllianceDelegation", + "/alliance.alliance.Query/AllianceDelegationRewards", + "/alliance.alliance.Query/AllianceRedelegations", + "/alliance.alliance.Query/AllianceUnbondings", + "/alliance.alliance.Query/AllianceUnbondingsByDenomAndDelegator", + "/alliance.alliance.Query/AllianceValidator", + "/alliance.alliance.Query/Alliances", + "/alliance.alliance.Query/AlliancesDelegation", + "/alliance.alliance.Query/AlliancesDelegationByValidator", + "/alliance.alliance.Query/IBCAlliance", + "/alliance.alliance.Query/IBCAllianceDelegation", + "/alliance.alliance.Query/IBCAllianceDelegationRewards", + "/alliance.alliance.Query/Params", + "/cosmos.auth.v1beta1.Query/Account", + "/cosmos.auth.v1beta1.Query/AccountAddressByID", + "/cosmos.auth.v1beta1.Query/AccountInfo", + "/cosmos.auth.v1beta1.Query/Accounts", + "/cosmos.auth.v1beta1.Query/AddressBytesToString", + "/cosmos.auth.v1beta1.Query/AddressStringToBytes", + "/cosmos.auth.v1beta1.Query/Bech32Prefix", + "/cosmos.auth.v1beta1.Query/ModuleAccountByName", + "/cosmos.auth.v1beta1.Query/ModuleAccounts", + "/cosmos.auth.v1beta1.Query/Params", + "/cosmos.authz.v1beta1.Query/GranteeGrants", + "/cosmos.authz.v1beta1.Query/GranterGrants", + "/cosmos.authz.v1beta1.Query/Grants", + "/cosmos.bank.v1beta1.Query/AllBalances", + "/cosmos.bank.v1beta1.Query/Balance", + "/cosmos.bank.v1beta1.Query/DenomMetadata", + "/cosmos.bank.v1beta1.Query/DenomOwners", + "/cosmos.bank.v1beta1.Query/DenomsMetadata", + "/cosmos.bank.v1beta1.Query/Params", + "/cosmos.bank.v1beta1.Query/SendEnabled", + "/cosmos.bank.v1beta1.Query/SpendableBalanceByDenom", + "/cosmos.bank.v1beta1.Query/SpendableBalances", + "/cosmos.bank.v1beta1.Query/SupplyOf", + "/cosmos.bank.v1beta1.Query/TotalSupply", + "/cosmos.consensus.v1.Query/Params", + "/cosmos.distribution.v1beta1.Query/CommunityPool", + "/cosmos.distribution.v1beta1.Query/DelegationRewards", + "/cosmos.distribution.v1beta1.Query/DelegationTotalRewards", + "/cosmos.distribution.v1beta1.Query/DelegatorValidators", + "/cosmos.distribution.v1beta1.Query/DelegatorWithdrawAddress", + "/cosmos.distribution.v1beta1.Query/Params", + "/cosmos.distribution.v1beta1.Query/ValidatorCommission", + "/cosmos.distribution.v1beta1.Query/ValidatorDistributionInfo", + "/cosmos.distribution.v1beta1.Query/ValidatorOutstandingRewards", + "/cosmos.distribution.v1beta1.Query/ValidatorSlashes", + "/cosmos.evidence.v1beta1.Query/AllEvidence", + "/cosmos.evidence.v1beta1.Query/Evidence", + "/cosmos.feegrant.v1beta1.Query/Allowance", + "/cosmos.feegrant.v1beta1.Query/Allowances", + "/cosmos.feegrant.v1beta1.Query/AllowancesByGranter", + "/cosmos.gov.v1.Query/Deposit", + "/cosmos.gov.v1.Query/Deposits", + "/cosmos.gov.v1.Query/Params", + "/cosmos.gov.v1.Query/Proposal", + "/cosmos.gov.v1.Query/Proposals", + "/cosmos.gov.v1.Query/TallyResult", + "/cosmos.gov.v1.Query/Vote", + "/cosmos.gov.v1.Query/Votes", + "/cosmos.mint.v1beta1.Query/AnnualProvisions", + "/cosmos.mint.v1beta1.Query/Inflation", + "/cosmos.mint.v1beta1.Query/Params", + "/cosmos.params.v1beta1.Query/Params", + "/cosmos.params.v1beta1.Query/Subspaces", + "/cosmos.slashing.v1beta1.Query/Params", + "/cosmos.slashing.v1beta1.Query/SigningInfo", + "/cosmos.slashing.v1beta1.Query/SigningInfos", + "/cosmos.staking.v1beta1.Query/Delegation", + "/cosmos.staking.v1beta1.Query/DelegatorDelegations", + "/cosmos.staking.v1beta1.Query/DelegatorUnbondingDelegations", + "/cosmos.staking.v1beta1.Query/DelegatorValidator", + "/cosmos.staking.v1beta1.Query/DelegatorValidators", + "/cosmos.staking.v1beta1.Query/HistoricalInfo", + "/cosmos.staking.v1beta1.Query/Params", + "/cosmos.staking.v1beta1.Query/Pool", + "/cosmos.staking.v1beta1.Query/Redelegations", + "/cosmos.staking.v1beta1.Query/UnbondingDelegation", + "/cosmos.staking.v1beta1.Query/Validator", + "/cosmos.staking.v1beta1.Query/ValidatorDelegations", + "/cosmos.staking.v1beta1.Query/ValidatorUnbondingDelegations", + "/cosmos.staking.v1beta1.Query/Validators", + "/cosmos.upgrade.v1beta1.Query/AppliedPlan", + "/cosmos.upgrade.v1beta1.Query/Authority", + "/cosmos.upgrade.v1beta1.Query/CurrentPlan", + "/cosmos.upgrade.v1beta1.Query/ModuleVersions", + "/cosmos.upgrade.v1beta1.Query/UpgradedConsensusState", + "/cosmwasm.wasm.v1.Query/AllContractState", + "/cosmwasm.wasm.v1.Query/Code", + "/cosmwasm.wasm.v1.Query/Codes", + "/cosmwasm.wasm.v1.Query/ContractHistory", + "/cosmwasm.wasm.v1.Query/ContractInfo", + "/cosmwasm.wasm.v1.Query/ContractsByCode", + "/cosmwasm.wasm.v1.Query/ContractsByCreator", + "/cosmwasm.wasm.v1.Query/Params", + "/cosmwasm.wasm.v1.Query/PinnedCodes", + "/cosmwasm.wasm.v1.Query/RawContractState", + "/cosmwasm.wasm.v1.Query/SmartContractState", + "/ibc.applications.fee.v1.Query/CounterpartyPayee", + "/ibc.applications.fee.v1.Query/FeeEnabledChannel", + "/ibc.applications.fee.v1.Query/FeeEnabledChannels", + "/ibc.applications.fee.v1.Query/IncentivizedPacket", + "/ibc.applications.fee.v1.Query/IncentivizedPackets", + "/ibc.applications.fee.v1.Query/IncentivizedPacketsForChannel", + "/ibc.applications.fee.v1.Query/Payee", + "/ibc.applications.fee.v1.Query/TotalAckFees", + "/ibc.applications.fee.v1.Query/TotalRecvFees", + "/ibc.applications.fee.v1.Query/TotalTimeoutFees", + "/ibc.applications.interchain_accounts.controller.v1.Query/InterchainAccount", + "/ibc.applications.interchain_accounts.controller.v1.Query/Params", + "/ibc.applications.interchain_accounts.host.v1.Query/Params", + "/ibc.applications.transfer.v1.Query/DenomHash", + "/ibc.applications.transfer.v1.Query/DenomTrace", + "/ibc.applications.transfer.v1.Query/DenomTraces", + "/ibc.applications.transfer.v1.Query/EscrowAddress", + "/ibc.applications.transfer.v1.Query/Params", + "/ibc.applications.transfer.v1.Query/TotalEscrowForDenom", + "/ibc.core.channel.v1.Query/Channel", + "/ibc.core.channel.v1.Query/ChannelClientState", + "/ibc.core.channel.v1.Query/ChannelConsensusState", + "/ibc.core.channel.v1.Query/Channels", + "/ibc.core.channel.v1.Query/ConnectionChannels", + "/ibc.core.channel.v1.Query/NextSequenceReceive", + "/ibc.core.channel.v1.Query/PacketAcknowledgement", + "/ibc.core.channel.v1.Query/PacketAcknowledgements", + "/ibc.core.channel.v1.Query/PacketCommitment", + "/ibc.core.channel.v1.Query/PacketCommitments", + "/ibc.core.channel.v1.Query/PacketReceipt", + "/ibc.core.channel.v1.Query/UnreceivedAcks", + "/ibc.core.channel.v1.Query/UnreceivedPackets", + "/ibc.core.client.v1.Query/ClientParams", + "/ibc.core.client.v1.Query/ClientState", + "/ibc.core.client.v1.Query/ClientStates", + "/ibc.core.client.v1.Query/ClientStatus", + "/ibc.core.client.v1.Query/ConsensusState", + "/ibc.core.client.v1.Query/ConsensusStateHeights", + "/ibc.core.client.v1.Query/ConsensusStates", + "/ibc.core.client.v1.Query/UpgradedClientState", + "/ibc.core.client.v1.Query/UpgradedConsensusState", + "/ibc.core.connection.v1.Query/ClientConnections", + "/ibc.core.connection.v1.Query/Connection", + "/ibc.core.connection.v1.Query/ConnectionClientState", + "/ibc.core.connection.v1.Query/ConnectionConsensusState", + "/ibc.core.connection.v1.Query/ConnectionParams", + "/ibc.core.connection.v1.Query/Connections", + "/icq.v1.Query/Params", + "/juno.feeshare.v1.Query/DeployerFeeShares", + "/juno.feeshare.v1.Query/FeeShare", + "/juno.feeshare.v1.Query/FeeShares", + "/juno.feeshare.v1.Query/Params", + "/juno.feeshare.v1.Query/WithdrawerFeeShares", + "/osmosis.tokenfactory.v1beta1.Query/BeforeSendHookAddress", + "/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata", + "/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator", + "/osmosis.tokenfactory.v1beta1.Query/Params", + "/pob.builder.v1.Query/Params", + "/router.v1.Query/Params" + ] + }); + }); +}); diff --git a/integration-tests/src/modules/icq.test.ts b/integration-tests/src/modules/icq.test.ts new file mode 100644 index 00000000..3cba730e --- /dev/null +++ b/integration-tests/src/modules/icq.test.ts @@ -0,0 +1,50 @@ +import { getLCDClient } from "../helpers/lcd.connection"; + +describe("ICQ Module (https://github.com/cosmos/ibc-apps/tree/main/modules/async-icq) ", () => { + // Prepare environment clients, accounts and wallets + const LCD = getLCDClient(); + + test('Must contain the expected module params', async () => { + // Query ica host module params + const hostResParams = await LCD.chain2.icaV1.hostParams("test-2"); + expect(hostResParams.params) + .toStrictEqual({ + "host_enabled": true, + "allow_messages": [ + "/cosmos.authz.v1beta1.MsgExec", + "/cosmos.authz.v1beta1.MsgGrant", + "/cosmos.authz.v1beta1.MsgRevoke", + "/cosmos.bank.v1beta1.MsgSend", + "/cosmos.bank.v1beta1.MsgMultiSend", + "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", + "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", + "/cosmos.distribution.v1beta1.MsgFundCommunityPool", + "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", + "/cosmos.feegrant.v1beta1.MsgGrantAllowance", + "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", + "/cosmos.gov.v1beta1.MsgVoteWeighted", + "/cosmos.gov.v1beta1.MsgSubmitProposal", + "/cosmos.gov.v1beta1.MsgDeposit", + "/cosmos.gov.v1beta1.MsgVote", + "/cosmos.staking.v1beta1.MsgEditValidator", + "/cosmos.staking.v1beta1.MsgDelegate", + "/cosmos.staking.v1beta1.MsgUndelegate", + "/cosmos.staking.v1beta1.MsgBeginRedelegate", + "/cosmos.staking.v1beta1.MsgCreateValidator", + "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", + "/ibc.applications.transfer.v1.MsgTransfer", + "/cosmwasm.wasm.v1.MsgStoreCode", + "/cosmwasm.wasm.v1.MsgInstantiateContract", + "/cosmwasm.wasm.v1.MsgExecuteContract", + "/cosmwasm.wasm.v1.MsgMigrateContract" + ] + }); + + // Query contoller module params + const controllerResParams = await LCD.chain2.icaV1.controllerParams("test-2"); + expect(controllerResParams.params) + .toStrictEqual({ + controller_enabled: true, + }); + }); +}); From 548cea24db18298af85db665dd964789810ec2aa Mon Sep 17 00:00:00 2001 From: emidev98 Date: Tue, 24 Oct 2023 18:19:32 +0200 Subject: [PATCH 2/7] wip: integration tests --- Makefile | 5 - integration-tests/src/helpers/index.ts | 17 ++ integration-tests/src/helpers/mnemonics.ts | 9 +- .../src/modules/alliance.test.ts | 24 +- integration-tests/src/modules/auth.test.ts | 29 +- .../src/modules/feeshare.test.ts | 33 +-- integration-tests/src/modules/gov.test.ts | 252 +++++++++--------- .../modules/{icq.test.ts => icav1.test.ts} | 38 ++- .../modules/{ica.test.ts => icqv1.test.ts} | 4 +- integration-tests/src/modules/pob.test.ts | 44 ++- integration-tests/tsconfig.json | 3 +- scripts/tests/ica/delegate.sh | 62 ----- 12 files changed, 233 insertions(+), 287 deletions(-) create mode 100644 integration-tests/src/helpers/index.ts rename integration-tests/src/modules/{icq.test.ts => icav1.test.ts} (59%) rename integration-tests/src/modules/{ica.test.ts => icqv1.test.ts} (98%) delete mode 100755 scripts/tests/ica/delegate.sh diff --git a/Makefile b/Makefile index e12ca4d0..d7bbfaa9 100644 --- a/Makefile +++ b/Makefile @@ -203,7 +203,6 @@ install: go.sum integration-test-all: init-test-framework \ test-relayer \ - test-ica \ test-ibc-hooks \ test-tokenfactory @@ -215,10 +214,6 @@ test-relayer: @echo "Testing relayer..." ./scripts/tests/relayer/interchain-acc-config/rly-init.sh -test-ica: - @echo "Testing ica..." - ./scripts/tests/ica/delegate.sh - test-ibc-hooks: @echo "Testing ibc hooks..." ./scripts/tests/ibc-hooks/increment.sh diff --git a/integration-tests/src/helpers/index.ts b/integration-tests/src/helpers/index.ts new file mode 100644 index 00000000..5df186bc --- /dev/null +++ b/integration-tests/src/helpers/index.ts @@ -0,0 +1,17 @@ +import { + SAFE_BLOCK_INCLUSION_TIME, + SAFE_VOTING_PERIOD_TIME, + blockInclusion, + votingPeriod, +} from "./const" +import { getMnemonics } from "./mnemonics" +import { getLCDClient } from "./lcd.connection" + +export { + SAFE_BLOCK_INCLUSION_TIME, + SAFE_VOTING_PERIOD_TIME, + blockInclusion, + votingPeriod, + getMnemonics, + getLCDClient +} \ No newline at end of file diff --git a/integration-tests/src/helpers/mnemonics.ts b/integration-tests/src/helpers/mnemonics.ts index 4a0de791..639daea6 100644 --- a/integration-tests/src/helpers/mnemonics.ts +++ b/integration-tests/src/helpers/mnemonics.ts @@ -36,9 +36,9 @@ export function getMnemonics() { let genesisVesting1 = new MnemonicKey({ mnemonic: "open attitude harsh casino rent attitude midnight debris describe spare cancel crisp olive ride elite gallery leaf buffalo sheriff filter rotate path begin soldier" }) - // let mnemonic = new MnemonicKey({ - // mnemonic: "unit question bulk desk slush answer share bird earth brave book wing special gorilla ozone release permit mercy luxury version advice impact unfair drama" - // }) + let icaMnemonic = new MnemonicKey({ + mnemonic: "unit question bulk desk slush answer share bird earth brave book wing special gorilla ozone release permit mercy luxury version advice impact unfair drama" + }) // let mnemonic = new MnemonicKey({ // mnemonic: "year aim panel oyster sunny faint dress skin describe chair guilt possible venue pottery inflict mass debate poverty multiply pulse ability purse situate inmate" // }) @@ -53,6 +53,7 @@ export function getMnemonics() { pobMnemonic, pobMnemonic1, genesisVesting, - genesisVesting1 + genesisVesting1, + icaMnemonic } } \ No newline at end of file diff --git a/integration-tests/src/modules/alliance.test.ts b/integration-tests/src/modules/alliance.test.ts index a970f1b9..4ff40f31 100644 --- a/integration-tests/src/modules/alliance.test.ts +++ b/integration-tests/src/modules/alliance.test.ts @@ -1,7 +1,5 @@ -import { getMnemonics } from "../helpers/mnemonics"; -import { getLCDClient } from "../helpers/lcd.connection"; +import { getLCDClient, getMnemonics, blockInclusion, votingPeriod } from "../helpers"; import { Coin, MsgTransfer, MsgCreateAlliance, Coins, MsgVote, Fee, MsgAllianceDelegate, MsgClaimDelegationRewards, MsgAllianceUndelegate, MsgDeleteAlliance, MsgSubmitProposal } from "@terra-money/feather.js"; -import { blockInclusion, votingPeriod } from "../helpers/const"; import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; @@ -60,20 +58,14 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/ }); test('Must contain the expected module params', async () => { - try { - // Query Alliance module params - const moduleParams = await LCD.chain2.alliance.params("test-2"); + // Query Alliance module params + const moduleParams = await LCD.chain2.alliance.params("test-2"); - // Validate that the params were set correctly on genesis - expect(moduleParams.params.take_rate_claim_interval) - .toBe("300s"); - expect(moduleParams.params.reward_delay_time) - .toBe("0s"); - } - catch (e) { - console.log(e) - expect(e).toBeUndefined(); - } + // Validate that the params were set correctly on genesis + expect(moduleParams.params.take_rate_claim_interval) + .toBe("300s"); + expect(moduleParams.params.reward_delay_time) + .toBe("0s"); }); test('Must create an alliance', async () => { diff --git a/integration-tests/src/modules/auth.test.ts b/integration-tests/src/modules/auth.test.ts index d1146a5e..45f77625 100644 --- a/integration-tests/src/modules/auth.test.ts +++ b/integration-tests/src/modules/auth.test.ts @@ -1,8 +1,6 @@ -import { getMnemonics } from "../helpers/mnemonics"; -import { getLCDClient } from "../helpers/lcd.connection"; +import { getMnemonics, getLCDClient, blockInclusion } from "../helpers"; import { ContinuousVestingAccount, Coins, MnemonicKey, MsgCreateVestingAccount, Coin } from "@terra-money/feather.js"; import moment from "moment"; -import { blockInclusion } from "../helpers/const"; describe("Auth Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0.47.x/x/auth)", () => { // Prepare environment clients, accounts and wallets @@ -12,22 +10,17 @@ describe("Auth Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0 const vestAccAddr1 = accounts.genesisVesting1.accAddress("terra"); test('Must contain the expected module params', async () => { - try { - // Query Auth module params - const moduleParams = await LCD.chain1.auth.parameters("test-1"); + // Query Auth module params + const moduleParams = await LCD.chain1.auth.parameters("test-1"); - expect(moduleParams) - .toMatchObject({ - "max_memo_characters": 256, - "tx_sig_limit": 7, - "tx_size_cost_per_byte": 10, - "sig_verify_cost_ed25519": 590, - "sig_verify_cost_secp256k1": 1000 - }); - } - catch (e) { - expect(e).toBeUndefined(); - } + expect(moduleParams) + .toMatchObject({ + "max_memo_characters": 256, + "tx_sig_limit": 7, + "tx_size_cost_per_byte": 10, + "sig_verify_cost_ed25519": 590, + "sig_verify_cost_secp256k1": 1000 + }); }); test('Must have vesting accounts created on genesis', async () => { diff --git a/integration-tests/src/modules/feeshare.test.ts b/integration-tests/src/modules/feeshare.test.ts index 2d1543ab..b1db4e19 100644 --- a/integration-tests/src/modules/feeshare.test.ts +++ b/integration-tests/src/modules/feeshare.test.ts @@ -1,7 +1,5 @@ -import { getMnemonics } from "../helpers/mnemonics"; -import { getLCDClient } from "../helpers/lcd.connection"; +import { getMnemonics, blockInclusion, getLCDClient } from "../helpers"; import { Coins, Fee, MnemonicKey, MsgExecuteContract, MsgInstantiateContract, MsgRegisterFeeShare, MsgStoreCode } from "@terra-money/feather.js"; -import { blockInclusion } from "../helpers/const"; import fs from "fs"; import path from 'path'; @@ -58,22 +56,17 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.6 }); test('Must contain the expected module params', async () => { - try { - // Query POB module params - const moduleParams = await LCD.chain1.feeshare.params("test-1"); + // Query feeshare module params + const moduleParams = await LCD.chain1.feeshare.params("test-1"); - expect(moduleParams) - .toMatchObject({ - "params": { - "enable_fee_share": true, - "developer_shares": "0.500000000000000000", - "allowed_denoms": [] - } - }); - } - catch (e) { - expect(e).toBeUndefined(); - } + expect(moduleParams) + .toMatchObject({ + "params": { + "enable_fee_share": true, + "developer_shares": "0.500000000000000000", + "allowed_denoms": [] + } + }); }); test('Must register fee share', async () => { @@ -149,7 +142,7 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.6 }); result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); await blockInclusion(); - + // Check the tx logs have the expected events txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; expect(txResult.logs[0].events) @@ -187,7 +180,7 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.6 }] } ]) - + // Query the random account (new owner of the contract) // and validate that the account has received 50% of the fees const bankAmount = await LCD.chain1.bank.balance(randomAccountAddress); diff --git a/integration-tests/src/modules/gov.test.ts b/integration-tests/src/modules/gov.test.ts index a7cab5ce..79b2a808 100644 --- a/integration-tests/src/modules/gov.test.ts +++ b/integration-tests/src/modules/gov.test.ts @@ -1,7 +1,5 @@ -import { getMnemonics } from "../helpers/mnemonics"; -import { getLCDClient } from "../helpers/lcd.connection"; +import { getLCDClient, blockInclusion, votingPeriod, getMnemonics } from "../helpers"; import { Coins, MsgVote, Fee, MsgSubmitProposal, Proposal, Int } from "@terra-money/feather.js"; -import { blockInclusion, votingPeriod } from "../helpers/const"; import { ProposalStatus, VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov"; describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0.47.x/x/gov) ", () => { @@ -13,140 +11,134 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele let proposalId = 0; // Will be populated on "Must submit a proposal on chain" test('Must contain the expected module params', async () => { - try { - // Query All gov module params - const moduleParams = await LCD.chain2.gov.params("test-2"); - // Validate that the params were set correctly on genesis - expect(moduleParams) - .toStrictEqual({ - "deposit_params": { - "max_deposit_period": "172800s", - "min_deposit": [ - { - "amount": "10000000", - "denom": "uluna", - }, - ], - }, - "tally_params": { - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - }, - "voting_params": { - "voting_period": "4s", - }, - "params": { - "burn_proposal_deposit_prevote": false, - "burn_vote_quorum": false, - "burn_vote_veto": true, - "max_deposit_period": "172800s", - "min_deposit": [{ + // Query All gov module params + const moduleParams = await LCD.chain2.gov.params("test-2"); + // Validate that the params were set correctly on genesis + expect(moduleParams) + .toStrictEqual({ + "deposit_params": { + "max_deposit_period": "172800s", + "min_deposit": [ + { "amount": "10000000", "denom": "uluna", - }], - "min_initial_deposit_ratio": "0.000000000000000000", - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - "voting_period": "4s", - }, - }); + }, + ], + }, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + }, + "voting_params": { + "voting_period": "4s", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); - // Query tally module params - const tallyParams = await LCD.chain2.gov.tallyParams("test-2"); - // Validate that the params were set correctly on genesis - expect(tallyParams) - .toStrictEqual({ - "deposit_params": null, - "voting_params": null, - "tally_params": { - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - }, - "params": { - "burn_proposal_deposit_prevote": false, - "burn_vote_quorum": false, - "burn_vote_veto": true, - "max_deposit_period": "172800s", - "min_deposit": [{ - "amount": "10000000", - "denom": "uluna", - }], - "min_initial_deposit_ratio": "0.000000000000000000", - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - "voting_period": "4s", - }, - }); + // Query tally module params + const tallyParams = await LCD.chain2.gov.tallyParams("test-2"); + // Validate that the params were set correctly on genesis + expect(tallyParams) + .toStrictEqual({ + "deposit_params": null, + "voting_params": null, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); - // Query voting gov module params - const votingParams = await LCD.chain2.gov.votingParams("test-2"); - // Validate that the params were set correctly on genesis - expect(votingParams) - .toStrictEqual({ - "deposit_params": null, - "tally_params": null, - "voting_params": { - "voting_period": "4s", - }, - "params": { - "burn_proposal_deposit_prevote": false, - "burn_vote_quorum": false, - "burn_vote_veto": true, - "max_deposit_period": "172800s", - "min_deposit": [{ - "amount": "10000000", - "denom": "uluna", - }], - "min_initial_deposit_ratio": "0.000000000000000000", - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - "voting_period": "4s", - }, - }); + // Query voting gov module params + const votingParams = await LCD.chain2.gov.votingParams("test-2"); + // Validate that the params were set correctly on genesis + expect(votingParams) + .toStrictEqual({ + "deposit_params": null, + "tally_params": null, + "voting_params": { + "voting_period": "4s", + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); - // Query deposit gov module params - const depositParams = await LCD.chain2.gov.depositParams("test-2"); - // Validate that the params were set correctly on genesis - expect(depositParams) - .toStrictEqual({ - "voting_params": null, - "tally_params": null, - "deposit_params": { - "max_deposit_period": "172800s", - "min_deposit": [ - { - "amount": "10000000", - "denom": "uluna", - }, - ], - }, - "params": { - "burn_proposal_deposit_prevote": false, - "burn_vote_quorum": false, - "burn_vote_veto": true, - "max_deposit_period": "172800s", - "min_deposit": [{ + // Query deposit gov module params + const depositParams = await LCD.chain2.gov.depositParams("test-2"); + // Validate that the params were set correctly on genesis + expect(depositParams) + .toStrictEqual({ + "voting_params": null, + "tally_params": null, + "deposit_params": { + "max_deposit_period": "172800s", + "min_deposit": [ + { "amount": "10000000", "denom": "uluna", - }], - "min_initial_deposit_ratio": "0.000000000000000000", - "quorum": "0.334000000000000000", - "threshold": "0.500000000000000000", - "veto_threshold": "0.334000000000000000", - "voting_period": "4s", - }, - }); - } - catch (e) { - console.log(e) - expect(e).toBeUndefined(); - } + }, + ], + }, + "params": { + "burn_proposal_deposit_prevote": false, + "burn_vote_quorum": false, + "burn_vote_veto": true, + "max_deposit_period": "172800s", + "min_deposit": [{ + "amount": "10000000", + "denom": "uluna", + }], + "min_initial_deposit_ratio": "0.000000000000000000", + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000", + "voting_period": "4s", + }, + }); }); test('Must submit an empty proposal on chain', async () => { @@ -205,7 +197,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele const res = await LCD.chain2.gov.proposals("test-2"); let proposal; for (const prop of res.proposals) { - if (prop.id === proposalId){ + if (prop.id === proposalId) { proposal = prop; } } diff --git a/integration-tests/src/modules/icq.test.ts b/integration-tests/src/modules/icav1.test.ts similarity index 59% rename from integration-tests/src/modules/icq.test.ts rename to integration-tests/src/modules/icav1.test.ts index 3cba730e..a03afa90 100644 --- a/integration-tests/src/modules/icq.test.ts +++ b/integration-tests/src/modules/icav1.test.ts @@ -1,8 +1,14 @@ -import { getLCDClient } from "../helpers/lcd.connection"; +//import { Coin, MsgTransfer } from "@terra-money/feather.js"; +import { blockInclusion, getLCDClient, getMnemonics } from "../helpers"; +//import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; +import { MsgRegisterInterchainAccount } from "@terra-money/feather.js/dist/core/ica/controller/v1/msgs"; -describe("ICQ Module (https://github.com/cosmos/ibc-apps/tree/main/modules/async-icq) ", () => { +describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modules/apps/27-interchain-accounts)", () => { // Prepare environment clients, accounts and wallets const LCD = getLCDClient(); + const { icaMnemonic } = getMnemonics(); + const chain1Wallet = LCD.chain1.wallet(icaMnemonic); + const externalAccAddr = icaMnemonic.accAddress("terra"); test('Must contain the expected module params', async () => { // Query ica host module params @@ -47,4 +53,32 @@ describe("ICQ Module (https://github.com/cosmos/ibc-apps/tree/main/modules/async controller_enabled: true, }); }); + + test('Must create an interchain account from chain1 to chain2', async () => { + try { + + let tx = await chain1Wallet.createAndSignTx({ + msgs: [new MsgRegisterInterchainAccount( + externalAccAddr, + "connection-0", + "" + )], + chainID: "test-1", + }); + console.log(tx); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + console.log("result",JSON.stringify(result)); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult).toBeDefined(); + console.log("txResult",JSON.stringify(txResult)); + + let res = await LCD.chain1.icaV1.controllerAccountAddress(externalAccAddr, "connection-0"); + console.log("Res",JSON.stringify(res)) + } + catch(e) { + console.log("Error",e) + expect(e).toBeUndefined(); + } + }); }); diff --git a/integration-tests/src/modules/ica.test.ts b/integration-tests/src/modules/icqv1.test.ts similarity index 98% rename from integration-tests/src/modules/ica.test.ts rename to integration-tests/src/modules/icqv1.test.ts index 5235924f..82456358 100644 --- a/integration-tests/src/modules/ica.test.ts +++ b/integration-tests/src/modules/icqv1.test.ts @@ -1,6 +1,6 @@ -import { getLCDClient } from "../helpers/lcd.connection"; +import { getLCDClient } from "../helpers"; -describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modules/apps/27-interchain-accounts) ", () => { +describe("ICQ Module (https://github.com/cosmos/ibc-apps/tree/main/modules/async-icq)", () => { // Prepare environment clients, accounts and wallets const LCD = getLCDClient(); diff --git a/integration-tests/src/modules/pob.test.ts b/integration-tests/src/modules/pob.test.ts index e071479d..4e61573d 100644 --- a/integration-tests/src/modules/pob.test.ts +++ b/integration-tests/src/modules/pob.test.ts @@ -1,8 +1,6 @@ import { Coins, Fee, MsgSend } from "@terra-money/feather.js"; -import { getMnemonics } from "../helpers/mnemonics"; -import { getLCDClient } from "../helpers/lcd.connection"; +import { getMnemonics, getLCDClient, blockInclusion } from "../helpers"; import { MsgAuctionBid } from "@terra-money/feather.js/dist/core/pob/MsgAuctionBid"; -import { blockInclusion } from "../helpers/const"; describe("Proposer Builder Module (https://github.com/skip-mev/pob) ", () => { // Prepare environment clients, accounts and wallets @@ -12,31 +10,25 @@ describe("Proposer Builder Module (https://github.com/skip-mev/pob) ", () => { const wallet11 = LCD.chain1.wallet(accounts.pobMnemonic1); test('Must contain the correct module params', async () => { - try { - // Query POB module params - const moduleParams = await LCD.chain1.pob.params("test-1"); + const moduleParams = await LCD.chain1.pob.params("test-1"); - expect(moduleParams) - .toMatchObject({ - "params": { - "escrow_account_address": "32sHF2qbF8xMmvwle9QEcy59Cbc=", - "front_running_protection": true, - "max_bundle_size": 2, - "min_bid_increment": { - "amount": "1", - "denom": "uluna", - }, - "proposer_fee": "0.000000000000000000", - "reserve_fee": { - "amount": "1", - "denom": "uluna", - }, + expect(moduleParams) + .toMatchObject({ + "params": { + "escrow_account_address": "32sHF2qbF8xMmvwle9QEcy59Cbc=", + "front_running_protection": true, + "max_bundle_size": 2, + "min_bid_increment": { + "amount": "1", + "denom": "uluna", }, - }); - } - catch (e) { - expect(e).toBeUndefined(); - } + "proposer_fee": "0.000000000000000000", + "reserve_fee": { + "amount": "1", + "denom": "uluna", + }, + }, + }); }); test('Must create and order two transactions in block', async () => { diff --git a/integration-tests/tsconfig.json b/integration-tests/tsconfig.json index 5ff72e45..4859665e 100644 --- a/integration-tests/tsconfig.json +++ b/integration-tests/tsconfig.json @@ -14,7 +14,7 @@ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ // "outDir": "./dist/", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "rootDir": "./src/", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "removeComments": true, /* Do not emit comments to output. */ "noEmit": false /* Do not emit outputs. */, @@ -37,7 +37,6 @@ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ /* Module Resolution Options */ "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ diff --git a/scripts/tests/ica/delegate.sh b/scripts/tests/ica/delegate.sh deleted file mode 100755 index 25209230..00000000 --- a/scripts/tests/ica/delegate.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -echo "" -echo "###########################################" -echo "# ICA Cross Chain Delegation to Validator #" -echo "###########################################" -echo "" - -BINARY=terrad -CHAIN_DIR=$(pwd)/data - -WALLET_1=$($BINARY keys show wallet1 -a --keyring-backend test --home $CHAIN_DIR/test-1) -WALLET_2=$($BINARY keys show wallet2 -a --keyring-backend test --home $CHAIN_DIR/test-2) - -echo "Registering ICA on chain test-1" -ICA_REGISTER_RESPONSE=$($BINARY tx interchain-accounts controller register connection-0 --from $WALLET_1 --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 --keyring-backend test -y --gas 10000000) - -ICS_TX_RESULT="Error:" -ICS_TX_ERROR="Error:" -while [[ "$ICS_TX_ERROR" == "$ICS_TX_RESULT"* ]]; do - echo "Waiting for the transaction to be relayed..." - sleep 5 - ICS_TX_RESULT=$($BINARY query interchain-accounts controller interchain-account $WALLET_1 connection-0 --node tcp://localhost:16657 -o json | jq -r '.address') -done - -echo "Sending tokens to ICA on chain test-2" -$BINARY tx bank send $WALLET_2 $ICS_TX_RESULT 10000000uluna --chain-id test-2 --home $CHAIN_DIR/test-2 --node tcp://localhost:26657 --keyring-backend test -y &> /dev/null -sleep 5 -ICS_ACCOUNT_BALANCE=$($BINARY query bank balances $ICS_TX_RESULT --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.balances[0].amount') - -if [[ "$ICS_ACCOUNT_BALANCE" != "10000000" ]]; then - echo "Error: ICA Have not received tokens" - exit 1 -fi - -echo "Executing Delegation from test-1 to test-2 via ICA" -VAL_ADDR_1=$(cat $CHAIN_DIR/test-2/config/genesis.json | jq -r '.app_state.genutil.gen_txs[0].body.messages[0].validator_address') - -GENERATED_PACKET=$($BINARY tx interchain-accounts host generate-packet-data '{ - "@type":"/cosmos.staking.v1beta1.MsgDelegate", - "delegator_address": "'"$ICS_TX_RESULT"'", - "validator_address": "'"$VAL_ADDR_1"'", - "amount": { - "denom": "uluna", - "amount": "'"$ICS_ACCOUNT_BALANCE"'" - } -}') - -$BINARY tx interchain-accounts controller send-tx connection-0 $GENERATED_PACKET --from $WALLET_1 --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 --keyring-backend test -y &> /dev/null - -VALIDATOR_DELEGATIONS="" -while [[ "$VALIDATOR_DELEGATIONS" != "$ICS_ACCOUNT_BALANCE" ]]; do - sleep 2 - echo "Waiting for the transaction '/cosmos.bank.v1beta1.MsgDelegate' to be relayed..." - VALIDATOR_DELEGATIONS=$($BINARY query staking delegations-to $VAL_ADDR_1 --home $CHAIN_DIR/test-2 --node tcp://localhost:26657 -o json | jq -r '.delegation_responses[-1].balance.amount') -done - -echo "" -echo "####################################################" -echo "# SUCCESS: ICA Cross Chain Delegation to Validator #" -echo "####################################################" -echo "" From 375d2ab28dba9f48dc3df0ed78fcce827f9616b1 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Wed, 25 Oct 2023 10:40:19 +0200 Subject: [PATCH 3/7] feat: feather.js 2.0.0-beta.2 --- integration-tests/package-lock.json | 30 ++++++++++++++--------------- integration-tests/package.json | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index e7d2dc92..03c3e387 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.7.0", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.1", + "@terra-money/feather.js": "^2.0.0-beta.2", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,13 +1803,13 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "2.0.0-beta.1", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.1.tgz", - "integrity": "sha512-cT8pNNvVEql9vni5SVk4d3+FBqVD9/D+A+qOhXJAvOs0cOG6NFEKmpBbhJlGegqlnr+Gksxp5bJ0YO2XYac2Vw==", + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.2.tgz", + "integrity": "sha512-DzKFauWBMeBpRYHyIozlhy0ju/WSwvhiZORL2wyr9qUJtz2WQzZ2iiMSSI0bTjWiMPShBaW2Ad/Mf9JmusmxBQ==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", - "@terra-money/terra.proto": "^4.0.3", + "@terra-money/terra.proto": "^4.0.4", "assert": "^2.0.0", "axios": "^0.27.2", "bech32": "^2.0.0", @@ -1849,9 +1849,9 @@ "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, "node_modules/@terra-money/terra.proto": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-4.0.3.tgz", - "integrity": "sha512-VSSX8ZA+RB7N1CMSMCIBXh8hoo4ZVAE7DEZ6qr+YPBhWm5Tkdwo4SVestCJouMyPNfp/Kf6ii8U8zAwedOUcNw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-4.0.4.tgz", + "integrity": "sha512-Xju3ObFvMWXCDpeOXwa+WpmcbvUFOgJ4shSSfbgocnX5q3250aTaIAaycxkArUtg1QoqV4B5qoboRAplMHYDZw==", "dependencies": { "@improbable-eng/grpc-web": "^0.14.1", "browser-headers": "^0.4.1", @@ -7008,13 +7008,13 @@ } }, "@terra-money/feather.js": { - "version": "2.0.0-beta.1", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.1.tgz", - "integrity": "sha512-cT8pNNvVEql9vni5SVk4d3+FBqVD9/D+A+qOhXJAvOs0cOG6NFEKmpBbhJlGegqlnr+Gksxp5bJ0YO2XYac2Vw==", + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.2.tgz", + "integrity": "sha512-DzKFauWBMeBpRYHyIozlhy0ju/WSwvhiZORL2wyr9qUJtz2WQzZ2iiMSSI0bTjWiMPShBaW2Ad/Mf9JmusmxBQ==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", - "@terra-money/terra.proto": "^4.0.3", + "@terra-money/terra.proto": "^4.0.4", "assert": "^2.0.0", "axios": "^0.27.2", "bech32": "^2.0.0", @@ -7052,9 +7052,9 @@ } }, "@terra-money/terra.proto": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-4.0.3.tgz", - "integrity": "sha512-VSSX8ZA+RB7N1CMSMCIBXh8hoo4ZVAE7DEZ6qr+YPBhWm5Tkdwo4SVestCJouMyPNfp/Kf6ii8U8zAwedOUcNw==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@terra-money/terra.proto/-/terra.proto-4.0.4.tgz", + "integrity": "sha512-Xju3ObFvMWXCDpeOXwa+WpmcbvUFOgJ4shSSfbgocnX5q3250aTaIAaycxkArUtg1QoqV4B5qoboRAplMHYDZw==", "requires": { "@improbable-eng/grpc-web": "^0.14.1", "browser-headers": "^0.4.1", diff --git a/integration-tests/package.json b/integration-tests/package.json index 48ea7469..c988f3a1 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.1", + "@terra-money/feather.js": "^2.0.0-beta.2", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } From 53c997dbe0afb61606d70df3aa40409d84ea15c5 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Wed, 25 Oct 2023 19:14:51 +0200 Subject: [PATCH 4/7] feat: icav1 test --- Makefile | 5 +- go.mod | 1 + go.sum | 4 +- integration-tests/package-lock.json | 14 +- integration-tests/package.json | 2 +- integration-tests/src/modules/icav1.test.ts | 196 ++++++++++++++++++-- 6 files changed, 190 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index d7bbfaa9..e18b6487 100644 --- a/Makefile +++ b/Makefile @@ -202,15 +202,12 @@ install: go.sum ############################################################################### integration-test-all: init-test-framework \ - test-relayer \ test-ibc-hooks \ test-tokenfactory init-test-framework: clean-testing-data install @echo "Initializing both blockchains..." ./scripts/tests/init-test-framework.sh - -test-relayer: @echo "Testing relayer..." ./scripts/tests/relayer/interchain-acc-config/rly-init.sh @@ -236,7 +233,7 @@ clean-testing-data: -@rm -rf ./_build -.PHONY: integration-test-all init-test-framework test-relayer test-ica test-ibc-hooks test-tokenfactory clean-testing-data +.PHONY: integration-test-all init-test-framework test-ibc-hooks test-tokenfactory clean-testing-data ############################################################################### ### Protobuf ### diff --git a/go.mod b/go.mod index b0f32c08..c981178b 100644 --- a/go.mod +++ b/go.mod @@ -189,6 +189,7 @@ replace ( // This is a temporary fix since the latest version updated some function signatures. To remove when updating to cosmos 47 github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d github.com/cosmos/cosmos-sdk => github.com/terra-money/cosmos-sdk v0.47.5-terra.2 + github.com/cosmos/ibc-go/v7 => github.com/terra-money/ibc-go/v7 v7.0.0-20231025094952-d0d14bc2e7ae github.com/cosmos/ledger-cosmos-go => github.com/terra-money/ledger-terra-go v0.11.2 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index 411d5872..f71b2c52 100644 --- a/go.sum +++ b/go.sum @@ -406,8 +406,6 @@ github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0 h1:mMHedP3Q+mz5gpOWNz0P+X github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0/go.mod h1:/P6l2bWo2AR3rrsfs0DHuFZO3Imzb93sxFD3ihrIgw4= github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230803181732-7c8f814d3b79 h1:pCxyhIxgWTabAQC5UerkITraHG3SwajdLKKMCFDWCv4= github.com/cosmos/ibc-apps/modules/ibc-hooks/v7 v7.0.0-20230803181732-7c8f814d3b79/go.mod h1:JwHFbo1oX/ht4fPpnPvmhZr+dCkYK1Vihw+vZE9umR4= -github.com/cosmos/ibc-go/v7 v7.3.0 h1:QtGeVMi/3JeLWuvEuC60sBHpAF40Oenx/y+bP8+wRRw= -github.com/cosmos/ibc-go/v7 v7.3.0/go.mod h1:mUmaHFXpXrEdcxfdXyau+utZf14pGKVUiXwYftRZZfQ= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= @@ -1133,6 +1131,8 @@ github.com/terra-money/alliance v0.3.2 h1:MuL3RBw+jXFv4io5PhaBn7jRUBvlJLUzgpD6gx github.com/terra-money/alliance v0.3.2/go.mod h1:HDiUexeXRUkLkLRw5jLQcHuVt1Sx43HfyVl0kfwW3JM= github.com/terra-money/cosmos-sdk v0.47.5-terra.2 h1:wMqM+qGsymt/gPnl+51y/ADGXPVVn04rJU7pBia/ut8= github.com/terra-money/cosmos-sdk v0.47.5-terra.2/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= +github.com/terra-money/ibc-go/v7 v7.0.0-20231025094952-d0d14bc2e7ae h1:ICyrA16j5H0E/XNEWa0S2gzSTrq1cfg1G6mAzcQEWe0= +github.com/terra-money/ibc-go/v7 v7.0.0-20231025094952-d0d14bc2e7ae/go.mod h1:wvx4pPBofe5ZdMNV3OFRxSI4auEP5Qfqf8JXLLNV04g= github.com/terra-money/ledger-terra-go v0.11.2 h1:BVXZl+OhJOri6vFNjjVaTabRLApw9MuG7mxWL4V718c= github.com/terra-money/ledger-terra-go v0.11.2/go.mod h1:ClJ2XMj1ptcnONzKH+GhVPi7Y8pXIT+UzJ0TNt0tfZE= github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 03c3e387..3ee109e3 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.7.0", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.2", + "@terra-money/feather.js": "^2.0.0-beta.3", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "2.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.2.tgz", - "integrity": "sha512-DzKFauWBMeBpRYHyIozlhy0ju/WSwvhiZORL2wyr9qUJtz2WQzZ2iiMSSI0bTjWiMPShBaW2Ad/Mf9JmusmxBQ==", + "version": "2.0.0-beta.3", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.3.tgz", + "integrity": "sha512-5yWdL/v9UgN8DuSExl9r71HeksgSpLjO9YPJF2PMqZhzAJEGZmgCXa+H7wDcMfDqLy/kZPI0dbASG0OWa6UApg==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "2.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.2.tgz", - "integrity": "sha512-DzKFauWBMeBpRYHyIozlhy0ju/WSwvhiZORL2wyr9qUJtz2WQzZ2iiMSSI0bTjWiMPShBaW2Ad/Mf9JmusmxBQ==", + "version": "2.0.0-beta.3", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.3.tgz", + "integrity": "sha512-5yWdL/v9UgN8DuSExl9r71HeksgSpLjO9YPJF2PMqZhzAJEGZmgCXa+H7wDcMfDqLy/kZPI0dbASG0OWa6UApg==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index c988f3a1..72f1a947 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.2", + "@terra-money/feather.js": "^2.0.0-beta.3", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/modules/icav1.test.ts b/integration-tests/src/modules/icav1.test.ts index a03afa90..03a1b38b 100644 --- a/integration-tests/src/modules/icav1.test.ts +++ b/integration-tests/src/modules/icav1.test.ts @@ -1,7 +1,10 @@ -//import { Coin, MsgTransfer } from "@terra-money/feather.js"; +import { AccAddress, Coin, MsgTransfer, MsgSend } from "@terra-money/feather.js"; import { blockInclusion, getLCDClient, getMnemonics } from "../helpers"; -//import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; -import { MsgRegisterInterchainAccount } from "@terra-money/feather.js/dist/core/ica/controller/v1/msgs"; +import { MsgRegisterInterchainAccount, MsgSendTx } from "@terra-money/feather.js/dist/core/ica/controller/v1/msgs"; +import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; +import { InterchainAccountPacketData } from "@terra-money/feather.js/dist/core/ica/controller/v1/InterchainAccountPacketData"; +import Long from "long"; +import { MsgSend as MsgSend_pb } from "@terra-money/terra.proto/cosmos/bank/v1beta1/tx"; describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modules/apps/27-interchain-accounts)", () => { // Prepare environment clients, accounts and wallets @@ -9,6 +12,8 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul const { icaMnemonic } = getMnemonics(); const chain1Wallet = LCD.chain1.wallet(icaMnemonic); const externalAccAddr = icaMnemonic.accAddress("terra"); + let ibcCoinDenom: string | undefined; + let intechainAccountAddr: AccAddress | undefined; test('Must contain the expected module params', async () => { // Query ica host module params @@ -54,9 +59,20 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul }); }); - test('Must create an interchain account from chain1 to chain2', async () => { - try { + test('Must query the interchain account to determine its existance', async () => { + let res = await LCD.chain1.icaV1.controllerAccountAddress(externalAccAddr, "connection-0") + .catch(e => { + const expectMsg = "failed to retrieve account address for icacontroller-"; + expect(e.response.data.message.startsWith(expectMsg)).toBeTruthy(); + }) + if (res !== undefined) { + expect(res.address).toBeDefined(); + intechainAccountAddr = res.address; + } + }); + + test('Must creat the interchain account if des not already exist', async () => { let tx = await chain1Wallet.createAndSignTx({ msgs: [new MsgRegisterInterchainAccount( externalAccAddr, @@ -64,21 +80,165 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul "" )], chainID: "test-1", + }).catch(e => { + const expectedMsg = "failed to execute message; message index: 0: existing active channel channel-1 for portID icacontroller-terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6 on connection connection-0: active channel already set for this owner"; + expect(e.response.data.message.startsWith(expectedMsg)) + .toBeTruthy(); }); - console.log(tx); - let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); - console.log("result",JSON.stringify(result)); - await blockInclusion(); - let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; - expect(txResult).toBeDefined(); - console.log("txResult",JSON.stringify(txResult)); - let res = await LCD.chain1.icaV1.controllerAccountAddress(externalAccAddr, "connection-0"); - console.log("Res",JSON.stringify(res)) - } - catch(e) { - console.log("Error",e) - expect(e).toBeUndefined(); + if (tx !== undefined) { + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events) + .toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount" + }, { + "key": "sender", + "value": "terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" + }] + }, + { + "type": "channel_open_init", + "attributes": [{ + "key": "port_id", + "value": "icacontroller-terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" + }, { + "key": "channel_id", + "value": "channel-1" + }, { + "key": "counterparty_port_id", + "value": "icahost" + }, { + "key": "counterparty_channel_id", + "value": "" + }, { + "key": "connection_id", + "value": "connection-0" + }, { + "key": "version", + "value": "{\"fee_version\":\"ics29-1\",\"app_version\":\"{\\\"version\\\":\\\"ics27-1\\\",\\\"controller_connection_id\\\":\\\"connection-0\\\",\\\"host_connection_id\\\":\\\"connection-0\\\",\\\"address\\\":\\\"\\\",\\\"encoding\\\":\\\"proto3\\\",\\\"tx_type\\\":\\\"sdk_multi_msg\\\"}\"}" + }] + }, + { + "type": "message", + "attributes": [{ + "key": "module", + "value": "ibc_channel" + }] + }]) + + // Check during 5 blocks for the receival + // of the IBC coin on chain-2 + for (let i = 0; i <= 5; i++) { + await blockInclusion(); + let res = await LCD.chain1.icaV1.controllerAccountAddress(externalAccAddr, "connection-0") + .catch((e) => { + const expectMsg = "failed to retrieve account address for icacontroller-"; + expect(e.response.data.message.startsWith(expectMsg)).toBeTruthy(); + }) + if (res) { + expect(res.address).toBeDefined(); + intechainAccountAddr = res.address; + break; + } + } } }); + + describe('After assuring the interchain account exists', () => { + test("Must send funds to the interchain account from chain-1 to chain-2", async () => { + if (typeof intechainAccountAddr === "string") { + let blockHeight = (await LCD.chain1.tendermint.blockInfo("test-1")).block.header.height; + let tx = await chain1Wallet.createAndSignTx({ + msgs: [new MsgTransfer( + "transfer", + "channel-0", + Coin.fromString("100000000uluna"), + externalAccAddr, + intechainAccountAddr as string, + new Height(2, parseInt(blockHeight) + 100), + undefined, + "" + )], + chainID: "test-1", + }); + + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult).toBeDefined(); + // Check during 5 blocks for the receival + // of the IBC coin on chain-2 + for (let i = 0; i <= 5; i++) { + await blockInclusion(); + let _ibcCoin = (await LCD.chain2.bank.balance(intechainAccountAddr))[0].find(c => c.denom.startsWith("ibc/")); + if (_ibcCoin) { + expect(_ibcCoin.denom.startsWith("ibc/")).toBeTruthy(); + ibcCoinDenom = _ibcCoin.denom + break; + } + } + } else { + // This case should never happen but if something goes wrong + // this is a check to fail. + expect(intechainAccountAddr).toBeDefined() + } + }); + + test("Must control the interchain account from chain-1 to send funds on chain-2 from the account address to a random account", async () => { + try { + const burnAddress = "terra1zdpgj8am5nqqvht927k3etljyl6a52kwqup0je"; + let msgSend = new MsgSend( + intechainAccountAddr as string, + burnAddress, + [Coin.fromString("100000000" + ibcCoinDenom)], + ) + let ibcPacket = new InterchainAccountPacketData( + MsgSend_pb.encode(msgSend.toProto()).string("base64").finish() as any, + ) + let tx = await chain1Wallet.createAndSignTx({ + msgs: [new MsgSendTx( + externalAccAddr, + "connection-0", + Long.fromString((new Date().getTime() * 1000000 + 600000000).toString()), + ibcPacket, + )], + chainID: "test-1", + }); + + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + const events = txResult.logs[0].events; + expect(events[0]) + .toStrictEqual({ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/ibc.applications.interchain_accounts.controller.v1.MsgSendTx" + }, { + "key": "sender", + "value": "terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" + }] + }); + + expect(events[2]) + .toStrictEqual({ + "type": "message", + "attributes": [{ + "key": "module", + "value": "ibc_channel" + }] + }) + } + catch (e) { + console.log(e) + expect(e).toBeUndefined() + } + }) + }); }); From 09d84196109acb8cd1c87ab59c2a7ebe08d779d3 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Wed, 25 Oct 2023 19:50:11 +0200 Subject: [PATCH 5/7] feat: icav1 testing --- integration-tests/package-lock.json | 14 +++++++------- integration-tests/package.json | 2 +- integration-tests/src/modules/icav1.test.ts | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 3ee109e3..3348b6c7 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.7.0", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.3", + "@terra-money/feather.js": "^2.0.0-beta.4", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "2.0.0-beta.3", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.3.tgz", - "integrity": "sha512-5yWdL/v9UgN8DuSExl9r71HeksgSpLjO9YPJF2PMqZhzAJEGZmgCXa+H7wDcMfDqLy/kZPI0dbASG0OWa6UApg==", + "version": "2.0.0-beta.4", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.4.tgz", + "integrity": "sha512-LUVBi0n5B1gRfP37MFYaNVjVPF5Bzsi1FszwqEOekst+rXYExetXKeL1Jkt6tgv48pI84wFyh7bUSOQV+9d4ug==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "2.0.0-beta.3", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.3.tgz", - "integrity": "sha512-5yWdL/v9UgN8DuSExl9r71HeksgSpLjO9YPJF2PMqZhzAJEGZmgCXa+H7wDcMfDqLy/kZPI0dbASG0OWa6UApg==", + "version": "2.0.0-beta.4", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.4.tgz", + "integrity": "sha512-LUVBi0n5B1gRfP37MFYaNVjVPF5Bzsi1FszwqEOekst+rXYExetXKeL1Jkt6tgv48pI84wFyh7bUSOQV+9d4ug==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index 72f1a947..a889f9f0 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.3", + "@terra-money/feather.js": "^2.0.0-beta.4", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/modules/icav1.test.ts b/integration-tests/src/modules/icav1.test.ts index 03a1b38b..1435be54 100644 --- a/integration-tests/src/modules/icav1.test.ts +++ b/integration-tests/src/modules/icav1.test.ts @@ -1,4 +1,4 @@ -import { AccAddress, Coin, MsgTransfer, MsgSend } from "@terra-money/feather.js"; +import { AccAddress, Coin, MsgTransfer, MsgSend, Coins } from "@terra-money/feather.js"; import { blockInclusion, getLCDClient, getMnemonics } from "../helpers"; import { MsgRegisterInterchainAccount, MsgSendTx } from "@terra-money/feather.js/dist/core/ica/controller/v1/msgs"; import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; @@ -195,10 +195,10 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul let msgSend = new MsgSend( intechainAccountAddr as string, burnAddress, - [Coin.fromString("100000000" + ibcCoinDenom)], + Coins.fromString("1000" + ibcCoinDenom), ) let ibcPacket = new InterchainAccountPacketData( - MsgSend_pb.encode(msgSend.toProto()).string("base64").finish() as any, + MsgSend_pb.encode(msgSend.toProto()).string("base64").finish(), ) let tx = await chain1Wallet.createAndSignTx({ msgs: [new MsgSendTx( @@ -225,7 +225,6 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul "value": "terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" }] }); - expect(events[2]) .toStrictEqual({ "type": "message", From d0427618087b810524ad659189d3533938a9f830 Mon Sep 17 00:00:00 2001 From: emidev98 Date: Thu, 26 Oct 2023 15:50:10 +0200 Subject: [PATCH 6/7] wip: tests --- integration-tests/src/modules/icav1.test.ts | 34 ++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/integration-tests/src/modules/icav1.test.ts b/integration-tests/src/modules/icav1.test.ts index 1435be54..e8ee94f5 100644 --- a/integration-tests/src/modules/icav1.test.ts +++ b/integration-tests/src/modules/icav1.test.ts @@ -2,9 +2,8 @@ import { AccAddress, Coin, MsgTransfer, MsgSend, Coins } from "@terra-money/feat import { blockInclusion, getLCDClient, getMnemonics } from "../helpers"; import { MsgRegisterInterchainAccount, MsgSendTx } from "@terra-money/feather.js/dist/core/ica/controller/v1/msgs"; import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; -import { InterchainAccountPacketData } from "@terra-money/feather.js/dist/core/ica/controller/v1/InterchainAccountPacketData"; import Long from "long"; -import { MsgSend as MsgSend_pb } from "@terra-money/terra.proto/cosmos/bank/v1beta1/tx"; +import { Type } from "@terra-money/terra.proto/ibc/applications/interchain_accounts/v1/packet"; describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modules/apps/27-interchain-accounts)", () => { // Prepare environment clients, accounts and wallets @@ -69,6 +68,17 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul if (res !== undefined) { expect(res.address).toBeDefined(); intechainAccountAddr = res.address; + // Check during 5 blocks for the receival + // of the IBC coin on chain-2 + for (let i = 0; i <= 5; i++) { + await blockInclusion(); + let _ibcCoin = (await LCD.chain2.bank.balance(intechainAccountAddr))[0].find(c => c.denom.startsWith("ibc/")); + if (_ibcCoin) { + expect(_ibcCoin.denom.startsWith("ibc/")).toBeTruthy(); + ibcCoinDenom = _ibcCoin.denom + break; + } + } } }); @@ -197,16 +207,18 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul burnAddress, Coins.fromString("1000" + ibcCoinDenom), ) - let ibcPacket = new InterchainAccountPacketData( - MsgSend_pb.encode(msgSend.toProto()).string("base64").finish(), - ) + let msgSendTx = new MsgSendTx( + externalAccAddr, + "connection-0", + Long.fromString((new Date().getTime() * 1000000 + 600000000).toString()), + { + data: msgSend, + memo: "", + type: Type.TYPE_EXECUTE_TX, + }, + ); let tx = await chain1Wallet.createAndSignTx({ - msgs: [new MsgSendTx( - externalAccAddr, - "connection-0", - Long.fromString((new Date().getTime() * 1000000 + 600000000).toString()), - ibcPacket, - )], + msgs: [msgSendTx], chainID: "test-1", }); From 3f3531e52c0937036048438077c80ffd617bc04a Mon Sep 17 00:00:00 2001 From: emidev98 Date: Fri, 27 Oct 2023 12:03:14 +0200 Subject: [PATCH 7/7] feat: icav1 tests --- integration-tests/package-lock.json | 14 +-- integration-tests/package.json | 2 +- integration-tests/src/modules/icav1.test.ts | 101 +++++++++++--------- 3 files changed, 64 insertions(+), 53 deletions(-) diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 3348b6c7..5042da70 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.7.0", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.4", + "@terra-money/feather.js": "^2.0.0-beta.6", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "2.0.0-beta.4", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.4.tgz", - "integrity": "sha512-LUVBi0n5B1gRfP37MFYaNVjVPF5Bzsi1FszwqEOekst+rXYExetXKeL1Jkt6tgv48pI84wFyh7bUSOQV+9d4ug==", + "version": "2.0.0-beta.6", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.6.tgz", + "integrity": "sha512-bZIyzCM2IRnh8fbhc5XEW4LY+5Wr0Aiw59L5e3Tr5Qyy/cP+Og5kWmTKBblvjk9G1XsEdeV/KdxR5/vsLI3lgQ==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "2.0.0-beta.4", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.4.tgz", - "integrity": "sha512-LUVBi0n5B1gRfP37MFYaNVjVPF5Bzsi1FszwqEOekst+rXYExetXKeL1Jkt6tgv48pI84wFyh7bUSOQV+9d4ug==", + "version": "2.0.0-beta.6", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.6.tgz", + "integrity": "sha512-bZIyzCM2IRnh8fbhc5XEW4LY+5Wr0Aiw59L5e3Tr5Qyy/cP+Og5kWmTKBblvjk9G1XsEdeV/KdxR5/vsLI3lgQ==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index a889f9f0..8f199d3f 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.4", + "@terra-money/feather.js": "^2.0.0-beta.6", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/modules/icav1.test.ts b/integration-tests/src/modules/icav1.test.ts index e8ee94f5..8e9d5ffd 100644 --- a/integration-tests/src/modules/icav1.test.ts +++ b/integration-tests/src/modules/icav1.test.ts @@ -3,7 +3,8 @@ import { blockInclusion, getLCDClient, getMnemonics } from "../helpers"; import { MsgRegisterInterchainAccount, MsgSendTx } from "@terra-money/feather.js/dist/core/ica/controller/v1/msgs"; import { Height } from "@terra-money/feather.js/dist/core/ibc/core/client/Height"; import Long from "long"; -import { Type } from "@terra-money/terra.proto/ibc/applications/interchain_accounts/v1/packet"; +import { InterchainAccountPacketData } from "@terra-money/feather.js/dist/core/ica/controller/v1/InterchainAccountPacketData"; +import { CosmosTx } from "@terra-money/feather.js/dist/core/ica/controller/v1/CosmosTx"; describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modules/apps/27-interchain-accounts)", () => { // Prepare environment clients, accounts and wallets @@ -59,12 +60,15 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul }); test('Must query the interchain account to determine its existance', async () => { + // Query the account address of the interchain account let res = await LCD.chain1.icaV1.controllerAccountAddress(externalAccAddr, "connection-0") .catch(e => { + // assert that the expected error is that it failed to retreive the account const expectMsg = "failed to retrieve account address for icacontroller-"; expect(e.response.data.message.startsWith(expectMsg)).toBeTruthy(); }) + // if res is defined then the account exists if (res !== undefined) { expect(res.address).toBeDefined(); intechainAccountAddr = res.address; @@ -199,56 +203,63 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul } }); - test("Must control the interchain account from chain-1 to send funds on chain-2 from the account address to a random account", async () => { - try { - const burnAddress = "terra1zdpgj8am5nqqvht927k3etljyl6a52kwqup0je"; - let msgSend = new MsgSend( + test("Must control the interchain account from chain-1 to send funds on chain-2 from the account address to a burnAddress", async () => { + const burnAddress = "terra1zdpgj8am5nqqvht927k3etljyl6a52kwqup0je"; + let interchainAccountPacketData = new InterchainAccountPacketData( + new CosmosTx([new MsgSend( intechainAccountAddr as string, burnAddress, Coins.fromString("1000" + ibcCoinDenom), - ) - let msgSendTx = new MsgSendTx( - externalAccAddr, - "connection-0", - Long.fromString((new Date().getTime() * 1000000 + 600000000).toString()), - { - data: msgSend, - memo: "", - type: Type.TYPE_EXECUTE_TX, - }, - ); - let tx = await chain1Wallet.createAndSignTx({ - msgs: [msgSendTx], - chainID: "test-1", + )]) + ) + let msgSendTx = new MsgSendTx( + externalAccAddr, + "connection-0", + Long.fromString((new Date().getTime() * 1000000 + 600000000).toString()), + interchainAccountPacketData, + ); + let tx = await chain1Wallet.createAndSignTx({ + msgs: [msgSendTx], + chainID: "test-1", + }); + + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + const events = txResult.logs[0].events; + expect(events[0]) + .toStrictEqual({ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/ibc.applications.interchain_accounts.controller.v1.MsgSendTx" + }, { + "key": "sender", + "value": "terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" + }] }); + expect(events[2]) + .toStrictEqual({ + "type": "message", + "attributes": [{ + "key": "module", + "value": "ibc_channel" + }] + }) - let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + + // Check during 5 blocks for the receival + // of the IBC coin on chain-2 + for (let i = 0; i <= 5; i++) { await blockInclusion(); - let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; - const events = txResult.logs[0].events; - expect(events[0]) - .toStrictEqual({ - "type": "message", - "attributes": [{ - "key": "action", - "value": "/ibc.applications.interchain_accounts.controller.v1.MsgSendTx" - }, { - "key": "sender", - "value": "terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" - }] - }); - expect(events[2]) - .toStrictEqual({ - "type": "message", - "attributes": [{ - "key": "module", - "value": "ibc_channel" - }] - }) - } - catch (e) { - console.log(e) - expect(e).toBeUndefined() + const bankRes = await LCD.chain2.bank.balance(burnAddress); + const coins = bankRes[0].find(c => c.denom === ibcCoinDenom); + if (coins) { + expect(coins).toBeDefined(); + expect(coins?.denom).toStrictEqual(ibcCoinDenom); + expect(coins?.amount.toNumber()).toBeGreaterThanOrEqual(1000); + break; + } } }) });