diff --git a/packages/scripts/integration-testing/simpleTest203.ts b/packages/scripts/integration-testing/simpleTest204.ts similarity index 72% rename from packages/scripts/integration-testing/simpleTest203.ts rename to packages/scripts/integration-testing/simpleTest204.ts index 3c8fcff06e..63de32c2ab 100644 --- a/packages/scripts/integration-testing/simpleTest203.ts +++ b/packages/scripts/integration-testing/simpleTest204.ts @@ -9,24 +9,24 @@ const repoURL = "https://github.com/TERITORI/teritori-chain.git"; const main = async () => { const binaries = await buildBinaries(repoURL, "teritorid", [ - "v2.0.3", + "v2.0.4", ] as const); const { home, - result: v203Result, - process: v203Process, - } = await startCosmosLocalnet(binaries["v2.0.3"]); + result: v204Result, + process: v204Process, + } = await startCosmosLocalnet(binaries["v2.0.4"]); await deployTeritoriEcosystem( - { binaryPath: binaries["v2.0.3"], home }, + { binaryPath: binaries["v2.0.4"], home }, teritoriLocalnetNetwork.id, "testnet-adm", ); // stop - v203Process.kill(os.constants.signals.SIGINT); - await v203Result; + v204Process.kill(os.constants.signals.SIGINT); + await v204Result; await fs.rm(home, { recursive: true, force: true }); }; diff --git a/packages/scripts/integration-testing/upgradeTest120to203.ts b/packages/scripts/integration-testing/upgradeTest120to204.ts similarity index 90% rename from packages/scripts/integration-testing/upgradeTest120to203.ts rename to packages/scripts/integration-testing/upgradeTest120to204.ts index 28651695b8..c67641b654 100644 --- a/packages/scripts/integration-testing/upgradeTest120to203.ts +++ b/packages/scripts/integration-testing/upgradeTest120to204.ts @@ -19,7 +19,7 @@ const main = async () => { "v1.3.0", "v1.3.1", "v1.4.2", - "v2.0.3", + "v2.0.4", ] as const); const { @@ -74,21 +74,21 @@ const main = async () => { `minimum-gas-prices = "0stake"`, ); - const { process: v203Process, result: v203Result } = - await startCosmosLocalnet(binaries["v2.0.3"], { + const { process: v204Process, result: v204Result } = + await startCosmosLocalnet(binaries["v2.0.4"], { home, height: upgradeHeight, }); // test cosmwasm await deployTeritoriEcosystem( - { binaryPath: binaries["v2.0.3"], home }, + { binaryPath: binaries["v2.0.4"], home }, teritoriLocalnetNetwork.id, "testnet-adm", ); - v203Process.kill(os.constants.signals.SIGINT); - await v203Result; + v204Process.kill(os.constants.signals.SIGINT); + await v204Result; await fs.rm(home, { recursive: true, force: true }); }; diff --git a/packages/scripts/integration-testing/upgradeTest142to203.ts b/packages/scripts/integration-testing/upgradeTest142to204.ts similarity index 88% rename from packages/scripts/integration-testing/upgradeTest142to203.ts rename to packages/scripts/integration-testing/upgradeTest142to204.ts index 6df9baf42b..1dbbdc7e0d 100644 --- a/packages/scripts/integration-testing/upgradeTest142to203.ts +++ b/packages/scripts/integration-testing/upgradeTest142to204.ts @@ -16,7 +16,7 @@ const repoURL = "https://github.com/TERITORI/teritori-chain.git"; const main = async () => { const binaries = await buildBinaries(repoURL, "teritorid", [ "v1.4.2", - "v2.0.3", + "v2.0.4", ] as const); const { @@ -48,8 +48,8 @@ const main = async () => { ); // start next version - const { result, process: v203Process } = await startCosmosLocalnet( - binaries["v2.0.3"], + const { result, process: v204Process } = await startCosmosLocalnet( + binaries["v2.0.4"], { home, height: upgradeHeight, @@ -58,13 +58,13 @@ const main = async () => { // test cosmwasm await deployTeritoriEcosystem( - { binaryPath: binaries["v2.0.3"], home }, + { binaryPath: binaries["v2.0.4"], home }, teritoriLocalnetNetwork.id, "testnet-adm", ); // stop - v203Process.kill(os.constants.signals.SIGINT); + v204Process.kill(os.constants.signals.SIGINT); await result; await fs.rm(home, { recursive: true, force: true }); diff --git a/packages/scripts/network-setup/deployLib.ts b/packages/scripts/network-setup/deployLib.ts index 2f8db663dc..0af9adf2d6 100644 --- a/packages/scripts/network-setup/deployLib.ts +++ b/packages/scripts/network-setup/deployLib.ts @@ -1,4 +1,5 @@ import { IndexedTx } from "@cosmjs/stargate"; +import { bech32 } from "bech32"; import child_process from "child_process"; import { cloneDeep } from "lodash"; import path from "path"; @@ -15,7 +16,7 @@ import { mustGetNonSigningCosmWasmClient, } from "../../networks"; import { zodTryParseJSON } from "../../utils/sanitize"; -import { injectRPCPort, retry, zodTxResult } from "../lib"; +import { injectRPCPort, retry, sleep, zodTxResult } from "../lib"; import sqh from "../sqh"; export const deployTeritoriEcosystem = async ( @@ -30,12 +31,16 @@ export const deployTeritoriEcosystem = async ( } console.log(`Deploying to ${network.displayName}`); - const walletAddr = child_process + let walletAddr = child_process .execSync( `${opts.binaryPath} keys show --keyring-backend test -a ${wallet} --home ${opts.home}`, ) .toString() .trim(); + if (walletAddr.startsWith("Successfully migrated")) { + walletAddr = walletAddr.substring(walletAddr.indexOf("\n")).trim(); + } + bech32.decode(walletAddr); console.log("Wallet address:", walletAddr); @@ -186,11 +191,15 @@ const instantiateNameService = async ( network.rpcEndpoint, )} --yes --keyring-backend test -o json --home ${opts.home}`; console.log("> " + cmd); - const out = await retry(5, () => + let out = await retry(5, () => child_process.execSync(cmd, { stdio: ["inherit", "pipe", "inherit"], + encoding: "utf-8", }), ); + if (!out.startsWith("{")) { + out = out.substring(out.indexOf("{")); + } const outObj = zodTryParseJSON(zodTxResult, out.toString()); if (!outObj) { throw new Error("Failed to parse instantiate result"); @@ -218,12 +227,16 @@ const instantiateContract = async ( label, )} --admin ${admin} --home ${opts.home}`; console.log("> " + cmd); - const out = await retry(5, () => + let out = await retry(5, () => child_process.execSync(cmd, { stdio: ["inherit", "pipe", "inherit"], + encoding: "utf-8", }), ); - const outObj = zodTryParseJSON(zodTxResult, out.toString()); + if (!out.startsWith("{")) { + out = out.substring(out.indexOf("{")); + } + const outObj = zodTryParseJSON(zodTxResult, out); if (!outObj) { throw new Error("Failed to parse instantiate result"); } @@ -246,12 +259,15 @@ const storeWASM = async ( network.rpcEndpoint, )} --yes --keyring-backend test -o json --home ${opts.home}`; console.log("> " + cmd); - const out = await retry(5, () => + let out = await retry(5, () => child_process.execSync(cmd, { stdio: ["inherit", "pipe", "inherit"], encoding: "utf-8", }), ); + if (!out.startsWith("{")) { + out = out.substring(out.indexOf("{")); + } const outObj = zodTryParseJSON(zodTxResult, out); if (!outObj) { throw new Error("Failed to parse store result"); @@ -262,14 +278,24 @@ const storeWASM = async ( return +codeId; }; -// FIXME: timeout -const getTx = async (networkId: string, txhash: string) => { - let tx: IndexedTx | null = null; - while (tx === null) { - tx = await retry(5, async () => { - const client = await mustGetNonSigningCosmWasmClient(networkId); - return client.getTx(txhash); - }); +const getTx = async (networkId: string, txhash: string, timeout?: number) => { + const innerGetTx = async () => { + let tx: IndexedTx | null = null; + while (tx === null) { + tx = await retry(5, async () => { + const client = await mustGetNonSigningCosmWasmClient(networkId); + return client.getTx(txhash); + }); + } + return tx; + }; + const startTimeout = async () => { + await sleep(timeout || 50000); + return undefined; + }; + const tx = await Promise.race([startTimeout(), innerGetTx()]); + if (!tx) { + throw new Error("Timed out waiting for tx '" + txhash + "'"); } return tx; };