Test example scripts

This commit is contained in:
Simon Warta 2020-08-03 07:49:26 +02:00
parent 29fae9ad75
commit 97aca6c7cf
4 changed files with 27 additions and 3 deletions

View File

@ -139,6 +139,18 @@ jobs:
environment:
SKIP_BUILD: 1
command: yarn selftest
- run:
name: Run CLI examples
working_directory: packages/cli
environment:
SKIP_BUILD: 1
command: |
./bin/cosmwasm-cli --init examples/delegate.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/faucet_addresses.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/generate_address.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/helpers.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/local_faucet.ts --code "process.exit(0)"
./bin/cosmwasm-cli --init examples/mask.ts --code "process.exit(0)"
- run:
command: ./scripts/wasmd/stop.sh
- run:

View File

@ -5,5 +5,5 @@ for (let i of [0, 1, 2, 3, 4]) {
const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic, makeCosmoshubPath(i), "cosmos");
const [{ address, pubkey }] = await wallet.getAccounts();
console.info(`Address ${i}: ${address}`);
console.info(`Pubkey ${i}: ${pubkey}`);
console.info(`Pubkey ${i}: ${toBase64(pubkey)}`);
}

View File

@ -3,5 +3,5 @@ const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic);
const [{ address, pubkey }] = await wallet.getAccounts();
console.info("mnemonic:", mnemonic);
console.info("pubkey:", pubkey);
console.info("pubkey:", encodeSecp256k1Pubkey(pubkey));
console.info("address:", address);

View File

@ -14,6 +14,11 @@ export function main(originalArgs: readonly string[]): void {
describe: "Read initial TypeScript code from files",
type: "array",
},
code: {
describe:
"Add initial TypeScript code from the argument. All code arguments are processed after all init arguments.",
type: "array",
},
// Maintainer options
debug: {
describe: "Enable debugging",
@ -24,7 +29,7 @@ export function main(originalArgs: readonly string[]): void {
type: "boolean",
},
})
.group(["init", "help", "version"], "User options")
.group(["init", "code", "help", "version"], "User options")
.group(["debug", "selftest"], "Maintainer options")
.parse(originalArgs);
@ -162,6 +167,13 @@ export function main(originalArgs: readonly string[]): void {
}
}
if (args.code) {
for (const code of args.code.map((arg) => arg.toString())) {
if (args.debug) console.info(`Adding code: '${code}' ...`);
init += `${code}\n`;
}
}
const tsconfigPath = join(__dirname, "..", "tsconfig_repl.json");
const installationDir = join(__dirname, "..");
new TsRepl(tsconfigPath, init, !!args.debug, installationDir).start().catch((error) => {