Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(2.8): ibc hooks #212

Merged
merged 8 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -211,10 +211,6 @@ init-test-framework: clean-testing-data install
@echo "Testing relayer..."
./scripts/tests/relayer/interchain-acc-config/rly-init.sh

test-ibc-hooks:
@echo "Testing ibc hooks..."
./scripts/tests/ibc-hooks/increment.sh

test-tokenfactory:
@echo "Testing tokenfactory..."
./scripts/tests/tokenfactory/tokenfactory.sh
1 change: 1 addition & 0 deletions integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -5,4 +5,5 @@ module.exports = {
testMatch: ['**/*.test.ts'],
verbose: true,
testTimeout: 30000,
maxConcurrency: 4,
};
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"description": "Integration tests for Core using feather.js",
"main": "index.ts",
"scripts": {
"test": "jest --maxConcurrency=4"
"test": "jest"
},
"repository": {
"type": "git",
5 changes: 4 additions & 1 deletion integration-tests/src/helpers/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const SAFE_VOTING_PERIOD_TIME = 4100;
export const SAFE_IBC_TRANSFER = 4100;
export const SAFE_BLOCK_INCLUSION_TIME = 1100;

export const blockInclusion = () => new Promise((resolve) => setTimeout(() => resolve(SAFE_BLOCK_INCLUSION_TIME), SAFE_BLOCK_INCLUSION_TIME));
export const votingPeriod = () => new Promise((resolve) => setTimeout(() => resolve(SAFE_VOTING_PERIOD_TIME), SAFE_VOTING_PERIOD_TIME));
export const ibcTransfer = () => new Promise((resolve) => setTimeout(() => resolve(SAFE_IBC_TRANSFER), SAFE_IBC_TRANSFER));
export const votingPeriod = () => new Promise((resolve) => setTimeout(() => resolve(SAFE_VOTING_PERIOD_TIME), SAFE_VOTING_PERIOD_TIME));
2 changes: 2 additions & 0 deletions integration-tests/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import {
SAFE_VOTING_PERIOD_TIME,
blockInclusion,
votingPeriod,
ibcTransfer,
} from "./const"
import { getMnemonics } from "./mnemonics"
import { getLCDClient } from "./lcd.connection"
@@ -12,6 +13,7 @@ export {
SAFE_VOTING_PERIOD_TIME,
blockInclusion,
votingPeriod,
ibcTransfer,
getMnemonics,
getLCDClient
}
6 changes: 5 additions & 1 deletion integration-tests/src/helpers/mnemonics.ts
Original file line number Diff line number Diff line change
@@ -42,6 +42,9 @@ export function getMnemonics() {
let tokenFactoryMnemonic = 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"
})
let ibcHooksMnemonic = new MnemonicKey({
mnemonic: "leave side blue panel curve ancient suspect slide seminar neutral doctor boring only curious spell surround remind obtain slogan hire giant soccer crunch system"
})

return {
val1,
@@ -55,6 +58,7 @@ export function getMnemonics() {
genesisVesting,
genesisVesting1,
icaMnemonic,
tokenFactoryMnemonic
tokenFactoryMnemonic,
ibcHooksMnemonic
}
}
110 changes: 110 additions & 0 deletions integration-tests/src/modules/ibc-hooks/ibc-hooks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { Coin, Coins, MsgInstantiateContract, MsgStoreCode, MsgTransfer } from "@terra-money/feather.js";
import { ibcTransfer, getMnemonics, getLCDClient, blockInclusion } from "../../helpers";
import fs from "fs";
import path from 'path';
import moment from "moment";

describe("IbcHooks Module (github.com/cosmos/ibc-apps/modules/ibc-hooks/v7) ", () => {
// Prepare the LCD and wallets. chain1Wallet is the one that will
// deploy the contract on chain 1 and chain2Wallet will be used
// to send IBC messages from chain 2 to interact with the contract.
const LCD = getLCDClient();
const accounts = getMnemonics();
const chain1Wallet = LCD.chain1.wallet(accounts.ibcHooksMnemonic);
const chain2Wallet = LCD.chain2.wallet(accounts.ibcHooksMnemonic);
const walletAddress = accounts.ibcHooksMnemonic.accAddress("terra");
let contractAddress: string;

// Read the counter contract, store on chain,
// instantiate to be used in the following tests
// and finally save the contract address.
beforeAll(async () => {
let tx = await chain1Wallet.createAndSignTx({
msgs: [new MsgStoreCode(
walletAddress,
fs.readFileSync(path.join(__dirname, "/../../contracts/counter.wasm")).toString("base64"),
)],
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;
let codeId = Number(txResult.logs[0].events[1].attributes[1].value);
expect(codeId).toBeDefined();

const msgInstantiateContract = new MsgInstantiateContract(
walletAddress,
walletAddress,
codeId,
{ count: 0 },
Coins.fromString("1uluna"),
"counter contract " + Math.random(),
);

tx = await chain1Wallet.createAndSignTx({
msgs: [msgInstantiateContract],
chainID: "test-1",
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
contractAddress = txResult.logs[0].events[4].attributes[0].value;
expect(contractAddress).toBeDefined();
})

describe("Must send IBC messages from chain 2 to chain 1", () => {
test('must incrementing the counter', async () => {
try {
const resw = await LCD.chain1.wasm.contractQuery(
contractAddress,
{
"get_count": {
"addr": walletAddress
}
}
);
console.log(JSON.stringify(resw));
let tx = await chain2Wallet.createAndSignTx({
msgs: [
new MsgTransfer(
"transfer",
"channel-0",
Coin.fromString("10000000uluna"),
walletAddress,
contractAddress,
undefined,
moment.utc().add(1.5, "day").unix().toString() + "000000000",
`{"wasm":{"contract": "${contractAddress}" ,"msg": {"increment": {}}}}`
),
],
chainID: "test-2",
});
let result = await LCD.chain2.tx.broadcastSync(tx, "test-2");
await ibcTransfer();
let txResult = await LCD.chain2.tx.txInfo(result.txhash, "test-2") as any;
expect(txResult.logs[0].eventsByType.ibc_transfer)
.toStrictEqual({
"sender": [walletAddress],
"receiver": [contractAddress],
"amount": ["10000000"],
"denom": ["uluna"],
"memo": [`{"wasm":{"contract": "${contractAddress}" ,"msg": {"increment": {}}}}`]
});

const res = await LCD.chain1.wasm.contractQuery(
contractAddress,
{
"get_count": {
"addr": walletAddress
}
}
);
console.log(JSON.stringify(res));
}
catch (e) {
console.log(e)
}
})
})
});
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { getMnemonics, getLCDClient, blockInclusion } from "../../helpers";
import fs from "fs";
import path from 'path';

describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.7/x/feeshare) ", () => {
describe("TokenFactory Module (https://github.com/terra-money/core/tree/release/v2.7/x/tokenfactory) ", () => {
// Prepare environment clients, accounts and wallets
const LCD = getLCDClient();
const accounts = getMnemonics();
43 changes: 0 additions & 43 deletions scripts/tests/ibc-hooks/counter/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/tests/ibc-hooks/counter/README.md

This file was deleted.

1 change: 0 additions & 1 deletion scripts/tests/ibc-hooks/counter/artifacts/checksums.txt

This file was deleted.

This file was deleted.

395 changes: 0 additions & 395 deletions scripts/tests/ibc-hooks/counter/src/contract.rs

This file was deleted.

16 changes: 0 additions & 16 deletions scripts/tests/ibc-hooks/counter/src/error.rs

This file was deleted.

48 changes: 0 additions & 48 deletions scripts/tests/ibc-hooks/counter/src/helpers.rs

This file was deleted.

71 changes: 0 additions & 71 deletions scripts/tests/ibc-hooks/counter/src/integration_tests.rs

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/tests/ibc-hooks/counter/src/lib.rs

This file was deleted.

63 changes: 0 additions & 63 deletions scripts/tests/ibc-hooks/counter/src/msg.rs

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/tests/ibc-hooks/counter/src/state.rs

This file was deleted.

80 changes: 0 additions & 80 deletions scripts/tests/ibc-hooks/increment.sh

This file was deleted.

7 changes: 6 additions & 1 deletion scripts/tests/init-test-framework.sh
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ WALLET_MNEMONIC_5="same heavy travel border destroy catalog music manual love fe
WALLET_MNEMONIC_6="broken title little open demand ladder mimic keen execute word couple door relief rule pulp demand believe cactus swing fluid tired what crop purse"
WALLET_MNEMONIC_7="unit question bulk desk slush answer share bird earth brave book wing special gorilla ozone release permit mercy luxury version advice impact unfair drama"
WALLET_MNEMONIC_8="year aim panel oyster sunny faint dress skin describe chair guilt possible venue pottery inflict mass debate poverty multiply pulse ability purse situate inmate"

WALLET_MNEMONIC_9="leave side blue panel curve ancient suspect slide seminar neutral doctor boring only curious spell surround remind obtain slogan hire giant soccer crunch system"

# Chain2
VAL_MNEMONIC_2="angry twist harsh drastic left brass behave host shove marriage fall update business leg direct reward object ugly security warm tuna model broccoli choice"
@@ -73,6 +73,7 @@ echo $WALLET_MNEMONIC_5 | $BINARY keys add wallet5 --home $CHAIN_DIR/$CHAINID_1
echo $WALLET_MNEMONIC_6 | $BINARY keys add wallet6 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_7 | $BINARY keys add wallet7 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_8 | $BINARY keys add wallet8 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_9 | $BINARY keys add wallet9 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test

echo $WALLET_MNEMONIC_1 | $BINARY keys add wallet1 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_2 | $BINARY keys add wallet2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
@@ -82,6 +83,7 @@ echo $WALLET_MNEMONIC_5 | $BINARY keys add wallet5 --home $CHAIN_DIR/$CHAINID_2
echo $WALLET_MNEMONIC_6 | $BINARY keys add wallet6 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_7 | $BINARY keys add wallet7 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_8 | $BINARY keys add wallet8 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
echo $WALLET_MNEMONIC_9 | $BINARY keys add wallet9 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test

echo $VAL_MNEMONIC_2 | $BINARY keys add val2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
echo $RLY_MNEMONIC_2 | $BINARY keys add rly2 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test
@@ -91,6 +93,7 @@ WALLET1_ADDR=$($BINARY keys show wallet1 --home $CHAIN_DIR/$CHAINID_1 --keyring-
WALLET3_ADDR=$($BINARY keys show wallet3 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a)
WALLET5_ADDR=$($BINARY keys show wallet5 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a)
WALLET7_ADDR=$($BINARY keys show wallet7 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a)
WALLET9_ADDR=$($BINARY keys show wallet9 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a)
RLY1_ADDR=$($BINARY keys show rly1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a)

VAL2_ADDR=$($BINARY keys show val2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a)
@@ -109,6 +112,7 @@ $BINARY genesis add-genesis-account $WALLET5_ADDR 1000000000000uluna --home $CHA
$BINARY genesis add-genesis-account $WALLET6_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1
$BINARY genesis add-genesis-account $WALLET7_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1
$BINARY genesis add-genesis-account $WALLET8_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1
$BINARY genesis add-genesis-account $WALLET9_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1
$BINARY genesis add-genesis-account $RLY1_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1

$BINARY genesis add-genesis-account $VAL2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2
@@ -120,6 +124,7 @@ $BINARY genesis add-genesis-account $WALLET5_ADDR 1000000000000uluna --home $CHA
$BINARY genesis add-genesis-account $WALLET6_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2
$BINARY genesis add-genesis-account $WALLET7_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2
$BINARY genesis add-genesis-account $WALLET8_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2
$BINARY genesis add-genesis-account $WALLET9_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2
$BINARY genesis add-genesis-account $RLY2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2

echo "Creating and collecting gentx..."
324 changes: 0 additions & 324 deletions x/wasmd/types/executed_contracts.pb.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emidev98 is this deletion expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiersuweijie yes because the folder structure was created by mistake as wasmd instead of wasm

This file was deleted.