Skip to content

Commit

Permalink
wip: integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Oct 24, 2023
1 parent 5e63708 commit 548cea2
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 287 deletions.
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ install: go.sum

integration-test-all: init-test-framework \
test-relayer \
test-ica \
test-ibc-hooks \
test-tokenfactory

Expand All @@ -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
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
29 changes: 11 additions & 18 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 { 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,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 () => {
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 548cea2

Please sign in to comment.