diff --git a/.gitignore b/.gitignore index a9ffeb50..840c3aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ .vscode .idea *.code-workspace -data + # Build bin @@ -35,9 +35,6 @@ coverage.txt profile.out sim_log_file -_build -.testnet - # Vagrant .vagrant/ *.box @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index dbc0e6b7..9b8953e7 100644 --- a/Makefile +++ b/Makefile @@ -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 ### ############################################################################### diff --git a/integration-tests/README.md b/integration-tests/README.md index b61b8bc6..9eec00bd 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -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. @@ -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 ``` \ No newline at end of file diff --git a/integration-tests/jest.config.js b/integration-tests/jest.config.js index bbf2be55..c60b7339 100644 --- a/integration-tests/jest.config.js +++ b/integration-tests/jest.config.js @@ -4,6 +4,6 @@ module.exports = { testEnvironment: 'node', testMatch: ['**/*.test.ts'], verbose: true, - testTimeout: 30000, - maxConcurrency: 3, + testTimeout: 50000, + globalTeardown: './src/teardown.ts', }; \ No newline at end of file diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 465e7b51..ce5c4316 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,8 +9,7 @@ "version": "v2.8.0", "license": "MIT", "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" }, "devDependencies": { @@ -1803,9 +1802,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "2.0.0-beta.13", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.13.tgz", - "integrity": "sha512-r4/BsFCGsWKnOil0iMe8ZyquqAoZbbFlcKLNWb72lbBvkUAfzHjJA/WBBy13vuGuS7Y80jsDbFBditBMaV7cvA==", + "version": "2.0.0-beta.14", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.14.tgz", + "integrity": "sha512-imb/Pi6Y3+8lAiLODAYU0PQ5Pygugc3QLrf1wpL8VsQFKu8sJAFsL4k/UUGnR0h0iR3GSAtq+kebcX8NwxhsJA==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7007,9 @@ } }, "@terra-money/feather.js": { - "version": "2.0.0-beta.13", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.13.tgz", - "integrity": "sha512-r4/BsFCGsWKnOil0iMe8ZyquqAoZbbFlcKLNWb72lbBvkUAfzHjJA/WBBy13vuGuS7Y80jsDbFBditBMaV7cvA==", + "version": "2.0.0-beta.14", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.14.tgz", + "integrity": "sha512-imb/Pi6Y3+8lAiLODAYU0PQ5Pygugc3QLrf1wpL8VsQFKu8sJAFsL4k/UUGnR0h0iR3GSAtq+kebcX8NwxhsJA==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index 80e28ddc..882f2ba9 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -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", @@ -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" } } diff --git a/integration-tests/src/contracts/README.md b/integration-tests/src/contracts/README.md new file mode 100644 index 00000000..3b17a073 --- /dev/null +++ b/integration-tests/src/contracts/README.md @@ -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 \ No newline at end of file diff --git a/integration-tests/src/contracts/cw20_base.wasm b/integration-tests/src/contracts/cw20_base.wasm new file mode 100644 index 00000000..b27ef84d Binary files /dev/null and b/integration-tests/src/contracts/cw20_base.wasm differ diff --git a/integration-tests/src/contracts/cw20_ics20.wasm b/integration-tests/src/contracts/cw20_ics20.wasm new file mode 100644 index 00000000..561c9166 Binary files /dev/null and b/integration-tests/src/contracts/cw20_ics20.wasm differ diff --git a/integration-tests/src/helpers/const.ts b/integration-tests/src/helpers/const.ts index d023245c..28aafa77 100644 --- a/integration-tests/src/helpers/const.ts +++ b/integration-tests/src/helpers/const.ts @@ -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; diff --git a/integration-tests/src/helpers/mnemonics.ts b/integration-tests/src/helpers/mnemonics.ts index 6d8c82a9..47a68fbc 100644 --- a/integration-tests/src/helpers/mnemonics.ts +++ b/integration-tests/src/helpers/mnemonics.ts @@ -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, @@ -59,6 +77,12 @@ export function getMnemonics() { genesisVesting1, icaMnemonic, tokenFactoryMnemonic, - ibcHooksMnemonic + ibcHooksMnemonic, + wasmContracts, + mnemonic2, + mnemonic3, + mnemonic4, + mnemonic5, + mnemonic6, } } \ No newline at end of file diff --git a/integration-tests/src/modules/alliance/alliance.test.ts b/integration-tests/src/modules/alliance/alliance.test.ts index 8c266e70..35935e22 100644 --- a/integration-tests/src/modules/alliance/alliance.test.ts +++ b/integration-tests/src/modules/alliance/alliance.test.ts @@ -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 () => { diff --git a/integration-tests/src/modules/auth/auth.test.ts b/integration-tests/src/modules/auth/auth.test.ts index 5f7139a3..2739aadd 100644 --- a/integration-tests/src/modules/auth/auth.test.ts +++ b/integration-tests/src/modules/auth/auth.test.ts @@ -47,7 +47,7 @@ describe("Auth Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0 expect(vestAcc.base_vesting_account.base_account.address) .toBe(vestAccAddr); expect(vestAcc.getAccountNumber()) - .toBe(3); + .toBe(4); expect(vestAcc.getPublicKey()) .toBeNull(); expect(vestAcc.getSequenceNumber()) @@ -62,81 +62,75 @@ describe("Auth Module (https://github.com/terra-money/cosmos-sdk/tree/release/v0 }); test('Must create a random vesting account', async () => { - try { - const randomAccountAddress = new MnemonicKey().accAddress("terra"); - // Register a new vesting account - let tx = await wallet.createAndSignTx({ - msgs: [new MsgCreateVestingAccount( - vestAccAddr1, - randomAccountAddress, - Coins.fromString("100uluna"), - moment().add(1, "minute").unix(), - false, - )], - chainID: "test-1", - }); + const randomAccountAddress = new MnemonicKey().accAddress("terra"); + // Register a new vesting account + let tx = await wallet.createAndSignTx({ + msgs: [new MsgCreateVestingAccount( + vestAccAddr1, + randomAccountAddress, + Coins.fromString("100uluna"), + moment().add(1, "minute").unix(), + false, + )], + 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"); - expect(JSON.parse(txResult.raw_log)[0].events) - .toEqual([{ - "type": "message", - "attributes": [{ - "key": "action", - "value": "/cosmos.vesting.v1beta1.MsgCreateVestingAccount" - }, { - "key": "sender", - "value": vestAccAddr1 - }, { - "key": "module", - "value": "vesting" - }] - }, - { - "type": "coin_spent", - "attributes": [{ - "key": "spender", - "value": vestAccAddr1 - }, { - "key": "amount", - "value": "100uluna" - }] - }, - { - "type": "coin_received", - "attributes": [{ - "key": "receiver", - "value": randomAccountAddress - }, { - "key": "amount", - "value": "100uluna" - }] - }, - { - "type": "transfer", - "attributes": [{ - "key": "recipient", - "value": randomAccountAddress - }, { - "key": "sender", - "value": vestAccAddr1 - }, { - "key": "amount", - "value": "100uluna" - }] - }, - { - "type": "message", - "attributes": [{ - "key": "sender", - "value": vestAccAddr1 - }] - } - ]) - } - catch (e) { - expect(e).toBeUndefined(); - } + 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.logs[0].events) + .toEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/cosmos.vesting.v1beta1.MsgCreateVestingAccount" + }, { + "key": "sender", + "value": vestAccAddr1 + }, { + "key": "module", + "value": "vesting" + }] + }, + { + "type": "coin_spent", + "attributes": [{ + "key": "spender", + "value": vestAccAddr1 + }, { + "key": "amount", + "value": "100uluna" + }] + }, + { + "type": "coin_received", + "attributes": [{ + "key": "receiver", + "value": randomAccountAddress + }, { + "key": "amount", + "value": "100uluna" + }] + }, + { + "type": "transfer", + "attributes": [{ + "key": "recipient", + "value": randomAccountAddress + }, { + "key": "sender", + "value": vestAccAddr1 + }, { + "key": "amount", + "value": "100uluna" + }] + }, + { + "type": "message", + "attributes": [{ + "key": "sender", + "value": vestAccAddr1 + }] + }]) }); }); \ No newline at end of file diff --git a/integration-tests/src/modules/feeshare/feeshare.test.ts b/integration-tests/src/modules/feeshare/feeshare.test.ts index 4dacfe5d..054dfbdf 100644 --- a/integration-tests/src/modules/feeshare/feeshare.test.ts +++ b/integration-tests/src/modules/feeshare/feeshare.test.ts @@ -16,43 +16,38 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.6 // instantiate to be used in the following tests // and finally save the contract address. beforeAll(async () => { - try { - let tx = await wallet.createAndSignTx({ - msgs: [new MsgStoreCode( - feeshareAccountAddress, - fs.readFileSync(path.join(__dirname, "/../../contracts/reflect.wasm")).toString("base64"), - )], - chainID: "test-1", - }); + let tx = await wallet.createAndSignTx({ + msgs: [new MsgStoreCode( + feeshareAccountAddress, + fs.readFileSync(path.join(__dirname, "/../../contracts/reflect.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(); + 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( - feeshareAccountAddress, - feeshareAccountAddress, - codeId, - {}, - Coins.fromString("1uluna"), - "Reflect contract " + Math.random(), - ); + const msgInstantiateContract = new MsgInstantiateContract( + feeshareAccountAddress, + feeshareAccountAddress, + codeId, + {}, + Coins.fromString("1uluna"), + "Reflect contract " + Math.random(), + ); - tx = await wallet.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(); - } - catch (e) { - expect(e).toBeUndefined(); - } + tx = await wallet.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(); }); test('Must contain the expected module params', async () => { @@ -70,127 +65,122 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.6 }); test('Must register fee share', async () => { - try { - // Register feeshare - let tx = await wallet.createAndSignTx({ - msgs: [new MsgRegisterFeeShare( - contractAddress, - feeshareAccountAddress, - randomAccountAddress, - )], - chainID: "test-1", - }); + // Register feeshare + let tx = await wallet.createAndSignTx({ + msgs: [new MsgRegisterFeeShare( + contractAddress, + feeshareAccountAddress, + randomAccountAddress, + )], + chainID: "test-1", + }); - let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); - await blockInclusion(); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); - // Check the tx logs - let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; - expect(txResult.logs[0].events) - .toMatchObject([{ - "type": "message", - "attributes": [{ - "key": "action", - "value": "/juno.feeshare.v1.MsgRegisterFeeShare" - }, { - "key": "sender", - "value": feeshareAccountAddress, - }, { - "key": "module", - "value": "feeshare" - }] - }, - { - "type": "register_feeshare", - "attributes": [{ - "key": "contract", - "value": contractAddress - }, { - "key": "withdrawer_address", - "value": randomAccountAddress, - }] - }]) + // Check the tx logs + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events) + .toMatchObject([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/juno.feeshare.v1.MsgRegisterFeeShare" + }, { + "key": "sender", + "value": feeshareAccountAddress, + }, { + "key": "module", + "value": "feeshare" + }] + }, + { + "type": "register_feeshare", + "attributes": [{ + "key": "contract", + "value": contractAddress + }, { + "key": "withdrawer_address", + "value": randomAccountAddress, + }] + }]) - // Check the registered feeshares by contractAddress - let feesharesBy = await LCD.chain1.feeshare.feeshares("test-1", contractAddress); - expect(feesharesBy) - .toMatchObject({ - "feeshare": { - "contract_address": contractAddress, - "deployer_address": feeshareAccountAddress, - "withdrawer_address": randomAccountAddress, - } - }) - // Check that querying all feeshares returns at least one feeshares - let feesharesByWallet = await LCD.chain1.feeshare.feeshares("test-1"); - expect(feesharesByWallet.feeshare.length).toBeGreaterThan(0); - await blockInclusion(); - - // Send an execute message to the reflect contract - let msgExecute = new MsgExecuteContract( - feeshareAccountAddress, - contractAddress, - { - change_owner: { - owner: randomAccountAddress, - } - }, - ); - tx = await wallet.createAndSignTx({ - msgs: [msgExecute], - chainID: "test-1", - fee: new Fee(200_000, "400000uluna"), - }); - result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); - await blockInclusion(); + // Check the registered feeshares by contractAddress + let feesharesBy = await LCD.chain1.feeshare.feeshares("test-1", contractAddress); + expect(feesharesBy) + .toMatchObject({ + "feeshare": { + "contract_address": contractAddress, + "deployer_address": feeshareAccountAddress, + "withdrawer_address": randomAccountAddress, + } + }) + // Check that querying all feeshares returns at least one feeshares + let feesharesByWallet = await LCD.chain1.feeshare.feeshares("test-1"); + expect(feesharesByWallet.feeshare.length).toBeGreaterThan(0); + 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) - .toMatchObject([{ - "type": "message", - "attributes": [{ - "key": "action", - "value": "/cosmwasm.wasm.v1.MsgExecuteContract" - }, { - "key": "sender", - "value": feeshareAccountAddress - }, { - "key": "module", - "value": "wasm" - }] - }, - { - "type": "execute", - "attributes": [{ - "key": "_contract_address", - "value": contractAddress - }] - }, - { - "type": "wasm", - "attributes": [{ - "key": "_contract_address", - "value": contractAddress - }, { - "key": "action", - "value": "change_owner" - }, { - "key": "owner", - "value": randomAccountAddress - }] + // Send an execute message to the reflect contract + let msgExecute = new MsgExecuteContract( + feeshareAccountAddress, + contractAddress, + { + change_owner: { + owner: randomAccountAddress, } - ]) - await blockInclusion() - - // 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); - expect(bankAmount[0]) - .toMatchObject(Coins.fromString("200000uluna")) - } - catch (e) { - expect(e).toBeUndefined(); - } + }, + ); + tx = await wallet.createAndSignTx({ + msgs: [msgExecute], + chainID: "test-1", + fee: new Fee(200_000, "400000uluna"), + }); + 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) + .toMatchObject([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/cosmwasm.wasm.v1.MsgExecuteContract" + }, { + "key": "sender", + "value": feeshareAccountAddress + }, { + "key": "module", + "value": "wasm" + }] + }, + { + "type": "execute", + "attributes": [{ + "key": "_contract_address", + "value": contractAddress + }] + }, + { + "type": "wasm", + "attributes": [{ + "key": "_contract_address", + "value": contractAddress + }, { + "key": "action", + "value": "change_owner" + }, { + "key": "owner", + "value": randomAccountAddress + }] + } + ]) + await blockInclusion() + + // 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); + expect(bankAmount[0]) + .toMatchObject(Coins.fromString("200000uluna")) }); }); \ No newline at end of file diff --git a/integration-tests/src/modules/gov/gov.test.ts b/integration-tests/src/modules/gov/gov.test.ts index e5f271d9..ae9f9345 100644 --- a/integration-tests/src/modules/gov/gov.test.ts +++ b/integration-tests/src/modules/gov/gov.test.ts @@ -31,7 +31,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele "veto_threshold": "0.334000000000000000", }, "voting_params": { - "voting_period": "4s", + "voting_period": "2s", }, "params": { "burn_proposal_deposit_prevote": false, @@ -46,7 +46,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele "quorum": "0.334000000000000000", "threshold": "0.500000000000000000", "veto_threshold": "0.334000000000000000", - "voting_period": "4s", + "voting_period": "2s", }, }); @@ -75,7 +75,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele "quorum": "0.334000000000000000", "threshold": "0.500000000000000000", "veto_threshold": "0.334000000000000000", - "voting_period": "4s", + "voting_period": "2s", }, }); @@ -87,7 +87,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele "deposit_params": null, "tally_params": null, "voting_params": { - "voting_period": "4s", + "voting_period": "2s", }, "params": { "burn_proposal_deposit_prevote": false, @@ -102,7 +102,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele "quorum": "0.334000000000000000", "threshold": "0.500000000000000000", "veto_threshold": "0.334000000000000000", - "voting_period": "4s", + "voting_period": "2s", }, }); @@ -136,7 +136,7 @@ describe("Governance Module (https://github.com/terra-money/cosmos-sdk/tree/rele "quorum": "0.334000000000000000", "threshold": "0.500000000000000000", "veto_threshold": "0.334000000000000000", - "voting_period": "4s", + "voting_period": "2s", }, }); }); diff --git a/integration-tests/src/modules/ibc-hooks/ibc-hooks.test.ts b/integration-tests/src/modules/ibc-hooks/ibc-hooks.test.ts index 5dcd2236..fcfe1d02 100644 --- a/integration-tests/src/modules/ibc-hooks/ibc-hooks.test.ts +++ b/integration-tests/src/modules/ibc-hooks/ibc-hooks.test.ts @@ -195,6 +195,7 @@ describe("IbcHooks Module (github.com/cosmos/ibc-apps/modules/ibc-hooks/v7) ", ( }); await LCD.chain1.tx.broadcastSync(tx, "test-1") await ibcTransfer(); + await ibcTransfer(); let res = await LCD.chain1.wasm.contractQuery( contractAddress, { "get_count": { "addr": contractAddress } } diff --git a/integration-tests/src/modules/ica/icav1.test.ts b/integration-tests/src/modules/ica/icav1.test.ts index e7b657c5..365cb59a 100644 --- a/integration-tests/src/modules/ica/icav1.test.ts +++ b/integration-tests/src/modules/ica/icav1.test.ts @@ -104,8 +104,10 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul 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.logs[0].events) - .toStrictEqual([{ + let events = txResult.logs[0].events; + + expect(events[0]) + .toStrictEqual({ "type": "message", "attributes": [{ "key": "action", @@ -114,36 +116,15 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul "key": "sender", "value": "terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" }] - }, - { - "type": "channel_open_init", - "attributes": [{ - "key": "port_id", - "value": "icacontroller-terra1p4kcrttuxj9kyyvv5px5ccgwf0yrw74yp7jqm6" - }, { - "key": "channel_id", - "value": "channel-1" - }, { - "key": "counterparty_port_id", - "value": "icahost" - }, { - "key": "counterparty_channel_id", - "value": "" - }, { - "key": "connection_id", - "value": "connection-0" - }, { - "key": "version", - "value": "{\"fee_version\":\"ics29-1\",\"app_version\":\"{\\\"version\\\":\\\"ics27-1\\\",\\\"controller_connection_id\\\":\\\"connection-0\\\",\\\"host_connection_id\\\":\\\"connection-0\\\",\\\"address\\\":\\\"\\\",\\\"encoding\\\":\\\"proto3\\\",\\\"tx_type\\\":\\\"sdk_multi_msg\\\"}\"}" - }] - }, - { + }); + expect(events[2]) + .toStrictEqual({ "type": "message", "attributes": [{ "key": "module", "value": "ibc_channel" }] - }]) + }) // Check during 5 blocks for the receival // of the IBC coin on chain-2 @@ -247,7 +228,7 @@ describe("ICA Module (https://github.com/cosmos/ibc-go/tree/release/v7.3.x/modul }] }) - + // Check during 5 blocks for the receival // of the IBC coin on chain-2 for (let i = 0; i <= 5; i++) { diff --git a/integration-tests/src/modules/pob/pob.test.ts b/integration-tests/src/modules/pob/pob.test.ts index 020de85b..f99ae5bc 100644 --- a/integration-tests/src/modules/pob/pob.test.ts +++ b/integration-tests/src/modules/pob/pob.test.ts @@ -32,91 +32,86 @@ describe("Proposer Builder Module (https://github.com/skip-mev/pob) ", () => { }); test('Must create and order two transactions in block', async () => { - try { - // Query block height and assert that the value is greater than 1. - // This blockHeight will be used later on timeoutHeight - const blockHeight = (await LCD.chain1.tendermint.blockInfo("test-1")).block.header.height; - expect(parseInt(blockHeight)).toBeGreaterThan(1); + // Query block height and assert that the value is greater than 1. + // This blockHeight will be used later on timeoutHeight + const blockHeight = (await LCD.chain1.tendermint.blockInfo("test-1")).block.header.height; + expect(parseInt(blockHeight)).toBeGreaterThan(1); - // Query account info to sign the transactions offline - // to be included in the MsgAuctionBid - const accInfo = await LCD.chain1.auth.accountInfo(wallet.key.accAddress("terra")); + // Query account info to sign the transactions offline + // to be included in the MsgAuctionBid + const accInfo = await LCD.chain1.auth.accountInfo(wallet.key.accAddress("terra")); - // **First** message to be signed using **wallet** - const firstMsg = MsgSend.fromData({ - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from_address": accounts.pobMnemonic.accAddress("terra"), - "to_address": accounts.pobMnemonic1.accAddress("terra"), - "amount": [{ "denom": "uluna", "amount": "1" }] - }); - const firstSignedSendTx = await wallet.createAndSignTx({ - msgs: [firstMsg], - memo: "First signed tx", - chainID: "test-1", - accountNumber: accInfo.getAccountNumber(), - sequence: accInfo.getSequenceNumber() + 1, - fee: new Fee(100000, new Coins({ uluna: 100000 })), - timeoutHeight: parseInt(blockHeight) + 20, - }); + // **First** message to be signed using **wallet** + const firstMsg = MsgSend.fromData({ + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": accounts.pobMnemonic.accAddress("terra"), + "to_address": accounts.pobMnemonic1.accAddress("terra"), + "amount": [{ "denom": "uluna", "amount": "1" }] + }); + const firstSignedSendTx = await wallet.createAndSignTx({ + msgs: [firstMsg], + memo: "First signed tx", + chainID: "test-1", + accountNumber: accInfo.getAccountNumber(), + sequence: accInfo.getSequenceNumber() + 1, + fee: new Fee(100000, new Coins({ uluna: 100000 })), + timeoutHeight: parseInt(blockHeight) + 20, + }); - // **Second** message to be signed using **wallet** - const secondMsg = MsgSend.fromData({ - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from_address": accounts.pobMnemonic.accAddress("terra"), - "to_address": accounts.pobMnemonic1.accAddress("terra"), - "amount": [{ "denom": "uluna", "amount": "2" }] - }); - const secondSignedSendTx = await wallet.createAndSignTx({ - msgs: [secondMsg], - memo: "Second signed tx", - chainID: "test-1", - accountNumber: accInfo.getAccountNumber(), - sequence: accInfo.getSequenceNumber(), - fee: new Fee(100000, new Coins({ uluna: 100000 })), - timeoutHeight: parseInt(blockHeight) + 20, - }); + // **Second** message to be signed using **wallet** + const secondMsg = MsgSend.fromData({ + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": accounts.pobMnemonic.accAddress("terra"), + "to_address": accounts.pobMnemonic1.accAddress("terra"), + "amount": [{ "denom": "uluna", "amount": "2" }] + }); + const secondSignedSendTx = await wallet.createAndSignTx({ + msgs: [secondMsg], + memo: "Second signed tx", + chainID: "test-1", + accountNumber: accInfo.getAccountNumber(), + sequence: accInfo.getSequenceNumber(), + fee: new Fee(100000, new Coins({ uluna: 100000 })), + timeoutHeight: parseInt(blockHeight) + 20, + }); - // Create the **MsgAuctionBid** with **wallet11**. - // - // The two signed transactions included in MsgAuctionBid - // ordered as the **secondSingedTransaction** in the first position - // and the **firstSignedTransaction** in the second position - let buildTx = await wallet11.createAndSignTx({ - msgs: [MsgAuctionBid.fromData({ - "@type": "/pob.builder.v1.MsgAuctionBid", - bid: { amount: "100000", denom: "uluna" }, - bidder: accounts.pobMnemonic1.accAddress("terra"), - transactions: [secondSignedSendTx.toBytes(), firstSignedSendTx.toBytes()] - })], - memo: "Build block", - chainID: "test-1", - fee: new Fee(100000, new Coins({ uluna: 100000 })), - timeoutHeight: parseInt(blockHeight) + 20, - }); - const result = await LCD.chain1.tx.broadcastSync(buildTx, "test-1"); - await blockInclusion(); - const txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1"); - expect(txResult.logs).toBeDefined(); - // Recover the transactions hashes from the bundled transactions - // to query the respective transaction data and check there are two - const txHashes = (txResult.logs as any)[0].eventsByType.auction_bid.bundled_txs[0].split(","); - expect(txHashes.length).toBe(2); + // Create the **MsgAuctionBid** with **wallet11**. + // + // The two signed transactions included in MsgAuctionBid + // ordered as the **secondSingedTransaction** in the first position + // and the **firstSignedTransaction** in the second position + let buildTx = await wallet11.createAndSignTx({ + msgs: [MsgAuctionBid.fromData({ + "@type": "/pob.builder.v1.MsgAuctionBid", + bid: { amount: "100000", denom: "uluna" }, + bidder: accounts.pobMnemonic1.accAddress("terra"), + transactions: [secondSignedSendTx.toBytes(), firstSignedSendTx.toBytes()] + })], + memo: "Build block", + chainID: "test-1", + fee: new Fee(100000, new Coins({ uluna: 100000 })), + timeoutHeight: parseInt(blockHeight) + 20, + }); + const result = await LCD.chain1.tx.broadcastSync(buildTx, "test-1"); + await blockInclusion(); + const txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1"); + expect(txResult.logs).toBeDefined(); + // Recover the transactions hashes from the bundled transactions + // to query the respective transaction data and check there are two + const txHashes = (txResult.logs as any)[0].eventsByType.auction_bid.bundled_txs[0].split(","); + expect(txHashes.length).toBe(2); - // Define index to check the order of the transactions - let index = 0; - for await (const txHash of txHashes) { - const txResult = await LCD.chain1.tx.txInfo(txHash, "test-1"); - const dataMsg = txResult.tx.body.messages[0].toData(); - // When the index is 0 the expected message is the secondMsg - // because the MsgAuctionBid orders the transactions that way - const expectedMsg = index === 0 ? secondMsg : firstMsg; - expect(dataMsg).toMatchObject(expectedMsg.toData()); + // Define index to check the order of the transactions + let index = 0; + for await (const txHash of txHashes) { + const txResult = await LCD.chain1.tx.txInfo(txHash, "test-1"); + const dataMsg = txResult.tx.body.messages[0].toData(); + // When the index is 0 the expected message is the secondMsg + // because the MsgAuctionBid orders the transactions that way + const expectedMsg = index === 0 ? secondMsg : firstMsg; + expect(dataMsg).toMatchObject(expectedMsg.toData()); - index++; - } - } - catch (e) { - expect(e).toBeUndefined(); + index++; } }); }); \ No newline at end of file diff --git a/integration-tests/src/modules/wasm/ics20.test.ts b/integration-tests/src/modules/wasm/ics20.test.ts new file mode 100644 index 00000000..6987a3c1 --- /dev/null +++ b/integration-tests/src/modules/wasm/ics20.test.ts @@ -0,0 +1,249 @@ + +import { MnemonicKey, MsgExecuteContract, MsgInstantiateContract, MsgStoreCode } from "@terra-money/feather.js"; +import { getMnemonics, getLCDClient, blockInclusion, ibcTransfer } from "../../helpers"; +import fs from "fs"; +import path from 'path'; +import { execSync, exec } from 'child_process'; + +describe("Wasm Module (https://github.com/CosmWasm/wasmd/releases/tag/v0.45.0) ", () => { + // Prepare environment clients, accounts and wallets + const LCD = getLCDClient(); + const accounts = getMnemonics(); + const wallet = LCD.chain1.wallet(accounts.wasmContracts); + const walletAddress = accounts.wasmContracts.accAddress("terra"); + const randomWalletAddress = new MnemonicKey().accAddress("terra"); + let cw20BaseCodeId: number; + let ics20CodeId: number; + let cw20ContractAddr: string; + let ics20ContractAddr: string; + let ics20ContractChannelId: string; + + // Validate that wasm module has the correct params + test('Must have the correct module params', async () => { + const moduleParams = await LCD.chain1.wasm.params("test-1"); + + expect(moduleParams) + .toStrictEqual({ + params: { + "code_upload_access": { + "addresses": [], + "permission": "Everybody" + }, + "instantiate_default_permission": "Everybody", + } + }); + }) + + // Validate that wasm module has the correct params + test('Must deploy *cw20_base* and *cw20_ics20* contracts', async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgStoreCode(walletAddress, fs.readFileSync(path.join(__dirname, "/../../contracts/cw20_base.wasm")).toString("base64")), + new MsgStoreCode(walletAddress, fs.readFileSync(path.join(__dirname, "/../../contracts/cw20_ics20.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; + cw20BaseCodeId = Number(txResult.logs[0].events[1].attributes[1].value); + expect(cw20BaseCodeId).toBeDefined(); + ics20CodeId = Number(txResult.logs[1].events[1].attributes[1].value); + expect(ics20CodeId).toBeDefined(); + }) + + describe("after contracts has been deployed", () => { + test("Must instantiate *cw20_base* and *cw20_ics20* contract", async () => { + let tx = await wallet.createAndSignTx({ + msgs: [new MsgInstantiateContract( + walletAddress, + walletAddress, + cw20BaseCodeId, + { + name: "Bitcoin", + symbol: "BTC", + decimals: 8, + initial_balances: [{ + address: walletAddress, + amount: "100000000", + }] + }, + undefined, + "A cw20 contract" + Math.random(), + )], + 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; + cw20ContractAddr = txResult.logs[0].events[1].attributes[0].value; + expect(cw20ContractAddr).toBeDefined(); + + tx = await wallet.createAndSignTx({ + msgs: [new MsgInstantiateContract( + walletAddress, + walletAddress, + ics20CodeId, + { + default_timeout: 60, + gov_contract: cw20ContractAddr, + allowlist: [{ + contract: cw20ContractAddr, + gas_limit: 1000000, + }], + default_gas_limit: 1000000 + }, + undefined, + "A cw20 contract" + Math.random(), + )], + 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; + ics20ContractAddr = txResult.logs[0].events[1].attributes[0].value; + expect(ics20ContractAddr).toBeDefined(); + }) + + test("must create the channel for the ICS20 contract", async () => { + // Stop the relayer to don't create conflicts + try { + execSync("pkill rly") + } + catch (e) { + console.log(e) + } + + // Create the path + const pathToRelayDir = path.join(__dirname, "/../../test-data/relayer"); + execSync(`rly tx link "test1-test2" --src-port="wasm.${ics20ContractAddr}" --dst-port="transfer" --version="ics20-1" --home="${pathToRelayDir}"`, { stdio: "ignore" }) + await blockInclusion(); + + // Start the relayer again + const rlyStart = exec(`rly start "test1-test2" -p="events" -b=100 --flush-interval="1s" --time-threshold="1s" --home="${pathToRelayDir}" > ${pathToRelayDir}/relayer.log 2>&1`) + rlyStart.unref(); + + const res = await LCD.chain1.ibc.channels("test-1", { + "pagination.limit": 1, + "pagination.reverse": "true", + }); + + expect(res.channels[0]).toBeDefined(); + expect(res.channels[0].channel_id).toBeDefined(); + ics20ContractChannelId = res.channels[0].channel_id; + }) + + + + describe("after channel has been created", () => { + test("Must send funds from test-1 to test-2", async () => { + // SubMessage to Transfer the funds thoguht the IBC channel + // which must be parsed to base64 and embeded into the "send" + // message. (we're not using JSON.stringify(object) because it causes and error) + let subMsg = Buffer.from(`{ + "channel": "${ics20ContractChannelId}", + "remote_address":"${randomWalletAddress}" + }`).toString("base64"); + + let tx = await wallet.createAndSignTx({ + msgs: [new MsgExecuteContract( + walletAddress, + cw20ContractAddr, + { + send: { + contract: ics20ContractAddr, + amount: "100000", + msg: subMsg + } + }, + )], + 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 events = txResult.logs[0].events; + + // Asser the order of events execution on chain + expect(events[0]).toStrictEqual({ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/cosmwasm.wasm.v1.MsgExecuteContract" + }, { + "key": "sender", + "value": walletAddress + }, { + "key": "module", + "value": "wasm" + }] + }); + expect(events[1]).toStrictEqual({ + "type": "execute", + "attributes": [{ + "key": "_contract_address", + "value": cw20ContractAddr + }] + }); + expect(events[2]).toStrictEqual({ + "type": "wasm", + "attributes": [{ + "key": "_contract_address", + "value": cw20ContractAddr + }, { + "key": "action", + "value": "send" + }, { + "key": "from", + "value": walletAddress + }, { + "key": "to", + "value": ics20ContractAddr + }, { + "key": "amount", + "value": "100000" + }] + }); + expect(events[3]).toStrictEqual({ + "type": "execute", + "attributes": [{ + "key": "_contract_address", + "value": ics20ContractAddr + }] + }); + expect(events[4]).toStrictEqual({ + "type": "wasm", + "attributes": [{ + "key": "_contract_address", + "value": ics20ContractAddr + }, { + "key": "action", + "value": "transfer" + }, { + "key": "amount", + "value": "100000" + }, { + "key": "denom", + "value": "cw20:" + cw20ContractAddr + }, { + "key": "receiver", + "value": randomWalletAddress + }, { + "key": "sender", + "value": walletAddress + }] + }); + + // Assert the assets reach the other chain with the correct amount + await ibcTransfer(); + await ibcTransfer(); + const queryRes = await LCD.chain2.bank.balance(randomWalletAddress); + let ibcCoin = queryRes[0].find(coin => coin.denom.startsWith("ibc/")); + expect(ibcCoin).toBeDefined(); + expect(ibcCoin?.amount?.toString()).toStrictEqual("100000"); + }) + }) + }) +}); \ No newline at end of file diff --git a/scripts/tests/chain-upgrade/chain-upgrade.sh b/integration-tests/src/setup/chain-upgrade/chain-upgrade.sh similarity index 87% rename from scripts/tests/chain-upgrade/chain-upgrade.sh rename to integration-tests/src/setup/chain-upgrade/chain-upgrade.sh index ce7b78be..73fa4ea8 100755 --- a/scripts/tests/chain-upgrade/chain-upgrade.sh +++ b/integration-tests/src/setup/chain-upgrade/chain-upgrade.sh @@ -1,23 +1,22 @@ #!/bin/bash OLD_VERSION=release/v2.7 -UPGRADE_HEIGHT=30 +UPGRADE_HEIGHT=20 CHAIN_ID=pisco-1 -ROOT=$(pwd) -CHAIN_HOME=$ROOT/_build/.testnet +CHAIN_HOME=$(pwd)/chain-upgrade-data DENOM=uluna SOFTWARE_UPGRADE_NAME="v2.8" -GOV_PERIOD="10s" +GOV_PERIOD="5s" VAL_MNEMONIC_1="clock post desk civil pottery foster expand merit dash seminar song memory figure uniform spice circle try happy obvious trash crime hybrid hood cushion" WALLET_MNEMONIC_1="banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" -export OLD_BINARY=$ROOT/_build/terrad_old -export NEW_BINARY=$ROOT/_build/terrad_new +export OLD_BINARY=$CHAIN_HOME/terrad_old +export NEW_BINARY=$CHAIN_HOME/terrad_new rm -rf /tmp/terra -rm -r $ROOT/_build -mkdir $ROOT/_build +rm -r $CHAIN_HOME +mkdir $CHAIN_HOME # install old binary if ! command -v $OLD_BINARY &> /dev/null @@ -28,15 +27,16 @@ then cd core git checkout $OLD_VERSION make build - cp /tmp/terra/core/build/terrad $ROOT/_build/terrad_old - cd $ROOT + cp /tmp/terra/core/build/terrad $CHAIN_HOME/terrad_old + cd $CHAIN_HOME fi # install new binary if ! command -v $NEW_BINARY &> /dev/null then + cd ../.. make build - cp build/terrad $ROOT/_build/terrad_new + cp build/terrad $NEW_BINARY fi # init genesis @@ -89,10 +89,10 @@ echo '{ "deposit": "550000000'$DENOM'", "title": "Upgrade to '$SOFTWARE_UPGRADE_NAME'", "summary": "Source Code Version https://github.com/terra-money/core" -}' > $PWD/_build/software-upgrade.json +}' > $CHAIN_HOME/software-upgrade.json # -$OLD_BINARY tx gov submit-proposal $ROOT/_build/software-upgrade.json --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y +$OLD_BINARY tx gov submit-proposal $CHAIN_HOME/software-upgrade.json --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y sleep 2 $OLD_BINARY tx gov vote 1 yes --from val1 --keyring-backend test --chain-id $CHAIN_ID --home $CHAIN_HOME -y # @@ -107,11 +107,11 @@ while true; do else $OLD_BINARY query gov proposal 1 --output=json | jq ".status" echo "BLOCK_HEIGHT = $BLOCK_HEIGHT" - sleep 5 + sleep 1 fi done # -sleep 5 +sleep 1 # ## run new node $NEW_BINARY start --home $CHAIN_HOME diff --git a/scripts/tests/init-test-framework.sh b/integration-tests/src/setup/init-test-framework.sh similarity index 72% rename from scripts/tests/init-test-framework.sh rename to integration-tests/src/setup/init-test-framework.sh index e49f3540..640074fc 100755 --- a/scripts/tests/init-test-framework.sh +++ b/integration-tests/src/setup/init-test-framework.sh @@ -1,7 +1,7 @@ #!/bin/bash BINARY=terrad -CHAIN_DIR=$(pwd)/data +CHAIN_DIR=$(pwd)/src/test-data CHAINID_1=test-1 CHAINID_2=test-2 @@ -18,6 +18,12 @@ WALLET_MNEMONIC_6="broken title little open demand ladder mimic keen execute wor 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" +WALLET_MNEMONIC_10="degree under tray object thought mercy mushroom captain bus work faint basic twice cube noble man ripple close flush bunker dish spare hungry arm" +WALLET_MNEMONIC_11="range struggle season mesh antenna delay sell light yard path risk curve brain nut cabin injury dilemma fun comfort crumble today transfer bring draft" +WALLET_MNEMONIC_12="giraffe trim element wheel cannon nothing enrich shiver upon output iron recall already fix appear produce fix behind scissors artefact excite tennis into side" +WALLET_MNEMONIC_13="run turn cup combine sad toast roof already melt chimney arctic save avocado theory bracket cherry cotton fee once favorite swarm ignore dream element" +WALLET_MNEMONIC_14="script key fold coyote cage squirrel prevent pole auction slide vintage shoot mirror erosion equip goose capable critic test space sketch monkey eight candy" +WALLET_MNEMONIC_15="work clap clarify edit explain exact depth ramp law hard feel beauty stumble occur prevent crush distance purpose scrap current describe skirt panther skirt" # 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" @@ -43,8 +49,12 @@ if pgrep -x "$BINARY" >/dev/null; then fi echo "Removing previous data..." -rm -rf $CHAIN_DIR/$CHAINID_1 &> /dev/null -rm -rf $CHAIN_DIR/$CHAINID_2 &> /dev/null +rm -rf $CHAIN_DIR + +echo "Stopping any processes related with the tests..." +pkill terrad +pkill terrad +pkill rly # Add directories for both chains, exit if an error occurs if ! mkdir -p $CHAIN_DIR/$CHAINID_1 2>/dev/null; then @@ -62,9 +72,13 @@ $BINARY init test --home $CHAIN_DIR/$CHAINID_1 --chain-id=$CHAINID_1 &> /dev/nul $BINARY init test --home $CHAIN_DIR/$CHAINID_2 --chain-id=$CHAINID_2 &> /dev/null echo "Adding genesis accounts..." +## Special wallets for validator and relayer echo $VAL_MNEMONIC_1 | $BINARY keys add val1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test -echo $RLY_MNEMONIC_1 | $BINARY keys add rly1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $RLY_MNEMONIC_1 | $BINARY keys add rly1 --home $CHAIN_DIR/$CHAINID_1 --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 +## Other wallets with funds at genesis echo $WALLET_MNEMONIC_1 | $BINARY keys add wallet1 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test echo $WALLET_MNEMONIC_2 | $BINARY keys add wallet2 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test echo $WALLET_MNEMONIC_3 | $BINARY keys add wallet3 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test @@ -74,6 +88,12 @@ echo $WALLET_MNEMONIC_6 | $BINARY keys add wallet6 --home $CHAIN_DIR/$CHAINID_1 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_10 | $BINARY keys add wallet10 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_11 | $BINARY keys add wallet11 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_12 | $BINARY keys add wallet12 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_13 | $BINARY keys add wallet13 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_14 | $BINARY keys add wallet14 --home $CHAIN_DIR/$CHAINID_1 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_15 | $BINARY keys add wallet15 --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 @@ -84,26 +104,43 @@ echo $WALLET_MNEMONIC_6 | $BINARY keys add wallet6 --home $CHAIN_DIR/$CHAINID_2 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 - +echo $WALLET_MNEMONIC_10 | $BINARY keys add wallet10 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_11 | $BINARY keys add wallet11 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_12 | $BINARY keys add wallet12 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_13 | $BINARY keys add wallet13 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_14 | $BINARY keys add wallet14 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test +echo $WALLET_MNEMONIC_15 | $BINARY keys add wallet15 --home $CHAIN_DIR/$CHAINID_2 --recover --keyring-backend=test + +## Special Wallets VAL1_ADDR=$($BINARY keys show val1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +VAL2_ADDR=$($BINARY keys show val2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) +RLY1_ADDR=$($BINARY keys show rly1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +RLY2_ADDR=$($BINARY keys show rly2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) + +## Other wallets with funds at genesis WALLET1_ADDR=$($BINARY keys show wallet1 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET2_ADDR=$($BINARY keys show wallet2 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) WALLET3_ADDR=$($BINARY keys show wallet3 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET4_ADDR=$($BINARY keys show wallet4 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) WALLET5_ADDR=$($BINARY keys show wallet5 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET6_ADDR=$($BINARY keys show wallet6 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) WALLET7_ADDR=$($BINARY keys show wallet7 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET8_ADDR=$($BINARY keys show wallet8 --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) +WALLET10_ADDR=$($BINARY keys show wallet10 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET11_ADDR=$($BINARY keys show wallet11 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET12_ADDR=$($BINARY keys show wallet12 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET13_ADDR=$($BINARY keys show wallet13 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET14_ADDR=$($BINARY keys show wallet14 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) +WALLET15_ADDR=$($BINARY keys show wallet15 --home $CHAIN_DIR/$CHAINID_1 --keyring-backend test -a) -VAL2_ADDR=$($BINARY keys show val2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) -WALLET2_ADDR=$($BINARY keys show wallet2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) -WALLET4_ADDR=$($BINARY keys show wallet4 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) -WALLET6_ADDR=$($BINARY keys show wallet6 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) -WALLET8_ADDR=$($BINARY keys show wallet8 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) -RLY2_ADDR=$($BINARY keys show rly2 --home $CHAIN_DIR/$CHAINID_2 --keyring-backend test -a) $BINARY genesis add-genesis-account $VAL1_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $VAL2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 +$BINARY genesis add-genesis-account $RLY1_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $RLY2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 + + $BINARY genesis add-genesis-account $WALLET1_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 $BINARY genesis add-genesis-account $WALLET2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 $BINARY genesis add-genesis-account $WALLET3_ADDR 1000000000000uluna --vesting-amount 10000000000uluna --vesting-start-time $(date +%s) --vesting-end-time $(($(date '+%s') + 100000023)) --home $CHAIN_DIR/$CHAINID_1 @@ -113,9 +150,13 @@ $BINARY genesis add-genesis-account $WALLET6_ADDR 1000000000000uluna --home $CHA $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 $WALLET10_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $WALLET11_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $WALLET12_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $WALLET13_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $WALLET14_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 +$BINARY genesis add-genesis-account $WALLET15_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_1 -$BINARY genesis add-genesis-account $VAL2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 $BINARY genesis add-genesis-account $WALLET1_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 $BINARY genesis add-genesis-account $WALLET2_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 $BINARY genesis add-genesis-account $WALLET3_ADDR 1000000000000uluna --vesting-amount 10000000000uluna --vesting-start-time $(date +%s) --vesting-end-time $(($(date '+%s') + 100000023)) --home $CHAIN_DIR/$CHAINID_2 @@ -125,7 +166,12 @@ $BINARY genesis add-genesis-account $WALLET6_ADDR 1000000000000uluna --home $CHA $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 +$BINARY genesis add-genesis-account $WALLET10_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 +$BINARY genesis add-genesis-account $WALLET11_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 +$BINARY genesis add-genesis-account $WALLET12_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 +$BINARY genesis add-genesis-account $WALLET13_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 +$BINARY genesis add-genesis-account $WALLET14_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 +$BINARY genesis add-genesis-account $WALLET15_ADDR 1000000000000uluna --home $CHAIN_DIR/$CHAINID_2 echo "Creating and collecting gentx..." $BINARY genesis gentx val1 7000000000uluna --home $CHAIN_DIR/$CHAINID_1 --chain-id $CHAINID_1 --keyring-backend test @@ -157,8 +203,8 @@ sed -i -e 's#"tcp://localhost:1317"#"tcp://localhost:'"$RESTPORT_2"'"#g' $CHAIN_ sed -i -e 's#":8080"#":'"$ROSETTA_2"'"#g' $CHAIN_DIR/$CHAINID_2/config/app.toml echo "Chaning genesis.json..." -sed -i -e 's/"voting_period": "172800s"/"voting_period": "4s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json -sed -i -e 's/"voting_period": "172800s"/"voting_period": "4s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json +sed -i -e 's/"voting_period": "172800s"/"voting_period": "2s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json +sed -i -e 's/"voting_period": "172800s"/"voting_period": "2s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json sed -i -e 's/"reward_delay_time": "604800s"/"reward_delay_time": "0s"/g' $CHAIN_DIR/$CHAINID_1/config/genesis.json sed -i -e 's/"reward_delay_time": "604800s"/"reward_delay_time": "0s"/g' $CHAIN_DIR/$CHAINID_2/config/genesis.json diff --git a/scripts/tests/relayer/interchain-acc-config/chains/test-1.json b/integration-tests/src/setup/relayer/chains/test-1.json similarity index 87% rename from scripts/tests/relayer/interchain-acc-config/chains/test-1.json rename to integration-tests/src/setup/relayer/chains/test-1.json index f75d3ac4..8c0ba886 100644 --- a/scripts/tests/relayer/interchain-acc-config/chains/test-1.json +++ b/integration-tests/src/setup/relayer/chains/test-1.json @@ -4,7 +4,7 @@ "key": "testkey", "chain-id": "test-1", "rpc-addr": "http://localhost:16657", - "grpc-addr": "", + "grpc-addr": "http://localhost:8090", "account-prefix": "terra", "keyring-backend": "test", "default-denom": "uluna", @@ -12,7 +12,7 @@ "gas-prices": "0.025uluna", "coin-type": 330, "debug": true, - "timeout": "10s", + "timeout": "4s", "output-format": "json", "sign-mode": "direct", "trusting-period": "330h", diff --git a/scripts/tests/relayer/interchain-acc-config/chains/test-2.json b/integration-tests/src/setup/relayer/chains/test-2.json similarity index 87% rename from scripts/tests/relayer/interchain-acc-config/chains/test-2.json rename to integration-tests/src/setup/relayer/chains/test-2.json index 3900b4a6..dee25158 100644 --- a/scripts/tests/relayer/interchain-acc-config/chains/test-2.json +++ b/integration-tests/src/setup/relayer/chains/test-2.json @@ -4,7 +4,7 @@ "key": "testkey", "chain-id": "test-2", "rpc-addr": "http://localhost:26657", - "grpc-addr": "", + "grpc-addr": "http://localhost:8090", "account-prefix": "terra", "keyring-backend": "test", "default-denom": "uluna", @@ -12,7 +12,7 @@ "gas-prices": "0.025uluna", "coin-type": 330, "debug": true, - "timeout": "10s", + "timeout": "4s", "output-format": "json", "sign-mode": "direct", "trusting-period": "330h", diff --git a/scripts/tests/relayer/interchain-acc-config/rly-init.sh b/integration-tests/src/setup/relayer/init-relayer.sh similarity index 65% rename from scripts/tests/relayer/interchain-acc-config/rly-init.sh rename to integration-tests/src/setup/relayer/init-relayer.sh index 9eba9c52..6d871736 100755 --- a/scripts/tests/relayer/interchain-acc-config/rly-init.sh +++ b/integration-tests/src/setup/relayer/init-relayer.sh @@ -8,10 +8,9 @@ echo "" # Configure predefined mnemonic pharses BINARY=rly -CHAIN_DIR=$(pwd)/data +CHAIN_DIR=$(pwd)/src/test-data CHAINID_1=test-1 CHAINID_2=test-2 -RELAYER_DIR=/relayer MNEMONIC_1="alley afraid soup fall idea toss can goose become valve initial strong forward bright dish figure check leopard decide warfare hub unusual join cart" MNEMONIC_2="record gift you once hip style during joke field prize dust unique length more pencil transfer quit train device arrive energy sort steak upset" @@ -23,24 +22,26 @@ if ! [ -x "$(command -v $BINARY)" ]; then fi echo "Initializing $BINARY..." -$BINARY config init --home $CHAIN_DIR/$RELAYER_DIR +$BINARY config init --home $CHAIN_DIR/relayer echo "Adding configurations for both chains..." -$BINARY chains add-dir ./scripts/tests/relayer/interchain-acc-config/chains --home $CHAIN_DIR/$RELAYER_DIR -$BINARY paths add $CHAINID_1 $CHAINID_2 test1-test2 --file ./scripts/tests/relayer/interchain-acc-config/paths/test1-test2.json --home $CHAIN_DIR/$RELAYER_DIR +$BINARY chains add-dir ./src/setup/relayer/chains --home $CHAIN_DIR/relayer +$BINARY paths add $CHAINID_1 $CHAINID_2 test1-test2 --file ./src/setup/relayer/paths/test1-test2.json --home $CHAIN_DIR/relayer echo "Restoring accounts..." -$BINARY keys restore $CHAINID_1 testkey "$MNEMONIC_1" --home $CHAIN_DIR/$RELAYER_DIR -$BINARY keys restore $CHAINID_2 testkey "$MNEMONIC_2" --home $CHAIN_DIR/$RELAYER_DIR +$BINARY keys restore $CHAINID_1 testkey "$MNEMONIC_1" --home $CHAIN_DIR/relayer +$BINARY keys restore $CHAINID_2 testkey "$MNEMONIC_2" --home $CHAIN_DIR/relayer echo "Creating clients and a connection..." -$BINARY tx connection test1-test2 --home $CHAIN_DIR/$RELAYER_DIR +$BINARY tx connection test1-test2 --home $CHAIN_DIR/relayer echo "Creating a channel..." -$BINARY tx channel test1-test2 --home $CHAIN_DIR/$RELAYER_DIR +$BINARY tx channel test1-test2 --home $CHAIN_DIR/relayer echo "Starting to listen relayer..." -$BINARY start test1-test2 -p events -b 100 --home $CHAIN_DIR/$RELAYER_DIR > $CHAIN_DIR/relayer.log 2>&1 & +$BINARY start test1-test2 -p events -b 100 --flush-interval 1s --time-threshold 1s --home $CHAIN_DIR/relayer > $CHAIN_DIR/relayer.log 2>&1 & + +sleep 10 echo "" echo "############################" diff --git a/scripts/tests/relayer/interchain-acc-config/paths/test1-test2.json b/integration-tests/src/setup/relayer/paths/test1-test2.json similarity index 100% rename from scripts/tests/relayer/interchain-acc-config/paths/test1-test2.json rename to integration-tests/src/setup/relayer/paths/test1-test2.json diff --git a/integration-tests/src/teardown.ts b/integration-tests/src/teardown.ts new file mode 100644 index 00000000..4d9ba20e --- /dev/null +++ b/integration-tests/src/teardown.ts @@ -0,0 +1,15 @@ +import { execSync } from 'child_process'; +import path from 'path'; + +module.exports = async () => { + try { + const pathToDataDir = path.join(__dirname, "/test-data"); + execSync("pkill rly") + execSync("pkill terrad") + execSync("pkill terrad") + execSync(`rm -r ${pathToDataDir}`) + } + catch (e) { + console.log(e) + } +} \ No newline at end of file diff --git a/scripts/tests/README.md b/scripts/tests/README.md deleted file mode 100644 index 27948371..00000000 --- a/scripts/tests/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Tests - -This folder contains the integration tests that should run successfully each time a new core release is created. - -At the moment, there are four tests defined that can be run with `make integration-test-all`. The breakdown of each test is as follows: - -- [init-test-framework](./start.sh): build the core and spin up two nodes with their own genesis event and some accounts preloaded with funds. -- [test-relayer](./relayer/): connect the two blockchains with a relayer opening a channel between both of them. - - [test-ica](./ica/delegate.sh): using the relayer, this test creates an interchain account and delegates funds using an interchain message. - - [test-ibc-hooks](./ibc-hooks/increment.sh): deploys a slightly modified [counter contract](./ibc-hooks/counter/) to chain test-2 and submits two requests from chain test-1 to validate that the contract received the funds and executed the wasm code correctly. -- remove-ica-data: removes the data and kills the process when the integration tests are completed. - -## Development process - -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). \ No newline at end of file