diff --git a/packages-ts/gauntlet-cosmos-contracts/package.json b/packages-ts/gauntlet-cosmos-contracts/package.json index 01aff793a..359ab814d 100644 --- a/packages-ts/gauntlet-cosmos-contracts/package.json +++ b/packages-ts/gauntlet-cosmos-contracts/package.json @@ -21,8 +21,8 @@ "preinstall": "node ../../scripts/require-yarn.js", "gauntlet": "ts-node ./src/index.ts", "lint": "tsc", - "test:debug:wasmd-up": "yarn ts-node ./test/scripts/startWasmdAndUpload.ts", - "test:debug": "yarn test:codegen && SKIP_WASMD_SETUP=true yarn test", + "dev:test:wasmd-up": "yarn ts-node ./test/scripts/startWasmdAndUpload.ts", + "dev:test": "yarn test:codegen && SKIP_WASMD_SETUP=true yarn test", "test": "yarn test:codegen && SKIP_PROMPTS=true jest --runInBand --config ../../jest.config.js --selectProjects gauntlet-cosmos-contracts --passWithNoTests", "test:codegen": "yarn node ./src/scripts/codegen.js", "test:coverage": "yarn test --collectCoverage", diff --git a/packages-ts/gauntlet-cosmos-contracts/test/utils.ts b/packages-ts/gauntlet-cosmos-contracts/test/utils.ts index e5efffb4b..c86d00c7d 100644 --- a/packages-ts/gauntlet-cosmos-contracts/test/utils.ts +++ b/packages-ts/gauntlet-cosmos-contracts/test/utils.ts @@ -1,9 +1,11 @@ -import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing' +import { DirectSecp256k1HdWallet, coins } from '@cosmjs/proto-signing' import { execSync } from 'child_process' import { readFileSync, writeFileSync } from 'fs' import path from 'path' import UploadCmd from '../src/commands/tooling/upload' +import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' +import { GasPrice } from '@cosmjs/stargate' const MNEMONIC = 'surround miss nominee dream gap cross assault thank captain prosper drop duty group candy wealth weather scale put' @@ -70,21 +72,27 @@ export const startWasmdAndUpload = async () => { const otherAddresses = accounts.map((a) => a.address).join(' ') const wasmdScript = path.join(__dirname, '../../../scripts/wasmd.sh') - execSync(`${wasmdScript} ${otherAddresses}`) + execSync(wasmdScript) + + // querying wasmd too soon will result in errors + await new Promise((f) => setTimeout(f, 10000)) + + const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC, { prefix: 'wasm' }) + const deployerAccounts = await deployerWallet.getAccounts() + const deployerAccount = deployerAccounts[0] + const deployer = await SigningCosmWasmClient.connectWithSigner(NODE_URL, deployerWallet, { + gasPrice: GasPrice.fromString(DEFAULT_GAS_PRICE), + }) + + // initialize other accounts with some tokens + for (const a of accounts) { + await deployer.sendTokens(deployerAccount.address, a.address, coins("1", "ucosm"), "auto") + } - // retrieve default deployer account - const deployerAccount = await (async () => { - const deployerWallet = await DirectSecp256k1HdWallet.fromMnemonic(MNEMONIC, { prefix: 'wasm' }) - const deployerAccounts = await deployerWallet.getAccounts() - return deployerAccounts[0] - })() accounts = [deployerAccount, ...accounts] console.log(`All accounts initialized ${deployerAccount.address} ${otherAddresses}`) - // querying wasmd too soon will result in errors - await new Promise((f) => setTimeout(f, 10000)) - // upload contracts process.env.SKIP_PROMPTS = 'true' @@ -94,7 +102,7 @@ export const startWasmdAndUpload = async () => { mnemonic: MNEMONIC, nodeURL: NODE_URL, gauntletTest: true, - defaultGasPrice: '0.025ucosm', + defaultGasPrice: DEFAULT_GAS_PRICE, }, [], ) diff --git a/scripts/wasmd.sh b/scripts/wasmd.sh index 9ad9379b9..3d952c9e7 100755 --- a/scripts/wasmd.sh +++ b/scripts/wasmd.sh @@ -35,8 +35,7 @@ docker run \ --name "${container_name}" \ "cosmwasm/wasmd:${container_version}" \ "./setup_and_run.sh" \ - "${genesis_account}" \ - "$@" + "${genesis_account}" echo "Waiting for wasmd container to become ready.." start_time=$(date +%s)