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(v2.8): cw20 and ics20 tests under wasm folder #224

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.vscode
.idea
*.code-workspace
data


# Build
bin
Expand All @@ -35,9 +35,6 @@ coverage.txt
profile.out
sim_log_file

_build
.testnet

# Vagrant
.vagrant/
*.box
Expand All @@ -60,3 +57,5 @@ dependency-graph.png
scripts/tests/ibc-hooks/counter/target
scripts/tests/vesting-accounts/.vesting-periods.json
node_modules
test-data
chain-upgrade-data
35 changes: 0 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,41 +196,6 @@ install: go.sum

.PHONY: build build-linux install


###############################################################################
### Integration Tests ###
###############################################################################

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

init-test-framework: clean-testing-data install
@echo "Initializing both blockchains..."
./scripts/tests/init-test-framework.sh
@echo "Testing relayer..."
./scripts/tests/relayer/interchain-acc-config/rly-init.sh

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

test-chain-upgrade:
@echo "Testing software upgrade..."
bash ./scripts/tests/chain-upgrade/chain-upgrade.sh

clean-testing-data:
@echo "Killing terrad and removing previous data"
-@pkill terrad 2>/dev/null
-@pkill rly 2>/dev/null
-@pkill terrad_new 2>/dev/null
-@pkill terrad_old 2>/dev/null
-@rm -rf ./data
-@rm -rf ./_build


.PHONY: integration-test-all init-test-framework test-ibc-hooks test-tokenfactory clean-testing-data

###############################################################################
### Protobuf ###
###############################################################################
Expand Down
10 changes: 4 additions & 6 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

This project is meant to increase the success ratio for new core releases, improve reliability and features for [@terra-money/feather.js](https://github.com/terra-money/feather.js). This tests are written using TypeScript with [jest](https://jestjs.io/) and executed in parallel to improve time execution.


### Development

This set of tests must run out of the box in Linux-based systems installing [GoLang 1.20](https://go.dev/), [jq](https://stedolan.github.io/jq/), [screen](https://www.geeksforgeeks.org/screen-command-in-linux-with-examples/) and [rly](https://github.com/cosmos/relayer).

Keep in mind that tests are executed in paralel when using the same account with two different tests it can misslead test results with errors like "account missmatch sequence" when submitting two transactions with the same nonce, missmatching balances, etc...

Another good practice with this framework is to isolate and assert values within a test considering that the data is not wiped out each time a new test is executed.
Expand All @@ -18,15 +19,12 @@ Folders structure:
├── package-lock.json
├── README.md
└── src
├── setup # Scripts to start the two networks and relayers
├── contracts # WASM Contracts to be used in the tests.
│ └── reflect.wasm
├── helpers # Functions to improve code readability and avoid duplications.
│ ├── const.ts
│ ├── lcd.connection.ts
│ └── mnemonics.ts
└── modules # Tests splited by module that intent to test.
├── auth.test.ts
├── feeshare.test.ts
└── pob.test.ts
└── modules # Tests splited by module

```
4 changes: 2 additions & 2 deletions integration-tests/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
verbose: true,
testTimeout: 30000,
maxConcurrency: 3,
testTimeout: 50000,
globalTeardown: './src/teardown.ts',
};
15 changes: 7 additions & 8 deletions integration-tests/package-lock.json

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

10 changes: 7 additions & 3 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"description": "Integration tests for Core using feather.js",
"main": "index.ts",
"scripts": {
"test": "jest"
"test:init" : "bash src/setup/init-test-framework.sh",
"test:relayer": "bash src/setup/relayer/init-relayer.sh",
"test:chain:upgrade" : "bash src/setup/chain-upgrade/chain-upgrade.sh",
"test:start" : "jest --runInBand --detectOpenHandles",
"start": "npm run test:init && npm run test:relayer && npm run test:start",
"test:clean": "rm -rf src/test-data chain-upgrade-data && pkill terrad && pkill terrad && pkill rly"
},
"repository": {
"type": "git",
Expand All @@ -30,8 +35,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@terra-money/feather.js": "^2.0.0-beta.13",
"@terra-money/terra.proto": "^4.0.1",
"@terra-money/feather.js": "^2.0.0-beta.14",
"moment": "^2.29.4"
}
}
9 changes: 9 additions & 0 deletions integration-tests/src/contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Smart Contracts

This smart contracts are used on the integration tests of the node. Since this are the wasm build there will be a list below for the source code in case at some point the binaries needs to be build again:

- [counter](https://github.com/osmosis-labs/osmosis/tree/d35a36e5ef74119191c47f1ae55944418e96e6f8/x/concentrated-liquidity/testcontracts/contract-sources/counter/src)
- [reflect](https://github.com/CosmosContracts/token-bindings/tree/v0.11.0/contracts/reflect)
- [cw20-base](https://github.com/CosmWasm/cw-plus/tree/v1.1.2/contracts/cw20-base)
- [cw20-ics20](https://github.com/CosmWasm/cw-plus/tree/v1.1.2/contracts/cw20-ics20)
- no100
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion integration-tests/src/helpers/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const SAFE_VOTING_PERIOD_TIME = 4100;
export const SAFE_VOTING_PERIOD_TIME = 2100;
export const SAFE_IBC_TRANSFER = 4100;
export const SAFE_BLOCK_INCLUSION_TIME = 1100;

Expand Down
26 changes: 25 additions & 1 deletion integration-tests/src/helpers/mnemonics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ export function getMnemonics() {
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"
})
let wasmContracts = new MnemonicKey({
mnemonic: "degree under tray object thought mercy mushroom captain bus work faint basic twice cube noble man ripple close flush bunker dish spare hungry arm"
})
let mnemonic2 = new MnemonicKey({
mnemonic: "range struggle season mesh antenna delay sell light yard path risk curve brain nut cabin injury dilemma fun comfort crumble today transfer bring draft"
})
let mnemonic3 = new MnemonicKey({
mnemonic: "giraffe trim element wheel cannon nothing enrich shiver upon output iron recall already fix appear produce fix behind scissors artefact excite tennis into side"
})
let mnemonic4 = new MnemonicKey({
mnemonic: "run turn cup combine sad toast roof already melt chimney arctic save avocado theory bracket cherry cotton fee once favorite swarm ignore dream element"
})
let mnemonic5 = new MnemonicKey({
mnemonic: "script key fold coyote cage squirrel prevent pole auction slide vintage shoot mirror erosion equip goose capable critic test space sketch monkey eight candy"
})
let mnemonic6 = new MnemonicKey({
mnemonic: "work clap clarify edit explain exact depth ramp law hard feel beauty stumble occur prevent crush distance purpose scrap current describe skirt panther skirt"
})

return {
val1,
Expand All @@ -59,6 +77,12 @@ export function getMnemonics() {
genesisVesting1,
icaMnemonic,
tokenFactoryMnemonic,
ibcHooksMnemonic
ibcHooksMnemonic,
wasmContracts,
mnemonic2,
mnemonic3,
mnemonic4,
mnemonic5,
mnemonic6,
}
}
57 changes: 26 additions & 31 deletions integration-tests/src/modules/alliance/alliance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,36 @@ describe("Alliance Module (https://github.com/terra-money/alliance/tree/release/
// the same wallet on both chains and start
// an Alliance creation process
beforeAll(async () => {
try {
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"),
allianceAccountAddress,
allianceAccountAddress,
new Height(2, parseInt(blockHeight) + 100),
undefined,
""
)],
chainID: "test-1",
});
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"),
allianceAccountAddress,
allianceAccountAddress,
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();
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(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/"));
if (_ibcCoin) {
expect(_ibcCoin.denom.startsWith("ibc/")).toBeTruthy();
break;
}
// 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(allianceAccountAddress))[0].find(c => c.denom.startsWith("ibc/"));
if (_ibcCoin) {
expect(_ibcCoin.denom.startsWith("ibc/")).toBeTruthy();
break;
}
}
catch (e) {
expect(e).toBeUndefined();
}
});

test('Must contain the expected module params', async () => {
Expand Down
Loading