Skip to content

Commit

Permalink
feat: ica & icq module params test
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Oct 24, 2023
1 parent 2198e18 commit 5e63708
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 37 deletions.
69 changes: 32 additions & 37 deletions integration-tests/src/modules/auth.test.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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 () => {
Expand Down
179 changes: 179 additions & 0 deletions integration-tests/src/modules/ica.test.ts
Original file line number Diff line number Diff line change
@@ -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"
]
});
});
});
50 changes: 50 additions & 0 deletions integration-tests/src/modules/icq.test.ts
Original file line number Diff line number Diff line change
@@ -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,
});
});
});

0 comments on commit 5e63708

Please sign in to comment.