Skip to content

Commit

Permalink
Merge pull request #196 from terra-money/feat/v2.7/tests
Browse files Browse the repository at this point in the history
feat: integration tests
  • Loading branch information
emidev98 committed Nov 2, 2023
2 parents 7fd040f + 3f3531e commit e58bc90
Show file tree
Hide file tree
Showing 16 changed files with 692 additions and 342 deletions.
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,15 @@ install: go.sum
###############################################################################

integration-test-all: init-test-framework \
test-relayer \
test-ica \
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

test-ica:
@echo "Testing ica..."
./scripts/tests/ica/delegate.sh

test-ibc-hooks:
@echo "Testing ibc hooks..."
./scripts/tests/ibc-hooks/increment.sh
Expand All @@ -241,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 ###
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
30 changes: 15 additions & 15 deletions integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.6",
"@terra-money/terra.proto": "^4.0.1",
"moment": "^2.29.4"
}
Expand Down
17 changes: 17 additions & 0 deletions integration-tests/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 5 additions & 4 deletions integration-tests/src/helpers/mnemonics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
// })
Expand All @@ -53,6 +53,7 @@ export function getMnemonics() {
pobMnemonic,
pobMnemonic1,
genesisVesting,
genesisVesting1
genesisVesting1,
icaMnemonic
}
}
24 changes: 8 additions & 16 deletions integration-tests/src/modules/alliance.test.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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 () => {
Expand Down
98 changes: 43 additions & 55 deletions integration-tests/src/modules/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { getMnemonics } from "../helpers/mnemonics";
import { getLCDClient } from "../helpers/lcd.connection";
import { ContinuousVestingAccount, Coins, MnemonicKey, MsgCreateVestingAccount } from "@terra-money/feather.js";
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
Expand All @@ -12,65 +10,55 @@ 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 () => {
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
33 changes: 13 additions & 20 deletions integration-tests/src/modules/feeshare.test.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit e58bc90

Please sign in to comment.