Skip to content

Commit

Permalink
redo local testnet creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Voyager Bot committed Jan 11, 2019
1 parent 533e406 commit 85f9b0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 51 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "node tasks/build/localBuild",
"build:testnets": "cd tasks/build/testnets && ./localBuild.sh",
"build:gaia": "cd tasks/build/Gaia && ./localBuild.sh",
"build:local": "node tasks/build/local/build",
"build:local": "node tasks/testnet",
"start": "yarn frontend & yarn proxy & yarn fullnode & yarn stargate",
"doc": "jsdoc -r -c jsdoc.json",
"lint": "yarn lint:eslint && yarn lint:format",
Expand Down
64 changes: 14 additions & 50 deletions tasks/testnet.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,25 @@
"use strict"

let runner = require(`./runner.js`)
let config = require(`../app/src/config.js`)
const fs = require(`fs-extra`)
const { join, resolve } = require(`path`)
const {
startNodes,
buildNodes,
setupAccounts
} = require(`./build/local/helper`)
const { buildNodes } = require(`./build/local/helper`)
const appDir = resolve(`${__dirname}/../`)
const buildTestnetPath = join(appDir, `builds`, `testnets`)

async function main() {
const network = process.argv[2] || config.default_network
const network = process.argv[2] || `local-testnet`
const numberNodes = parseInt(process.argv[3], 10) || 1

let extendedEnv = {}
let networkPath = `./app/networks/${network}/`

if (network === `local-testnet`) {
const { cliHomePrefix, nodes, mainAccountSignInfo } = await buildNodes(
join(buildTestnetPath, network),
{
chainId: network,
password: `1234567890`,
overwrite: false,
moniker: `local`,
keyName: `main-account`
},
numberNodes
)
await startNodes(nodes, mainAccountSignInfo, network)
fs.copySync(join(nodes[1].home, `config`), cliHomePrefix)
let { version } = require(`../package.json`)
fs.writeFileSync(`${cliHomePrefix}/app_version`, version)
networkPath = cliHomePrefix // join(nodes[1].home, `config`)
extendedEnv = {
LCD_URL: `https://localhost:9070`,
RPC_URL: `http://localhost:26657`,
COSMOS_HOME: cliHomePrefix
}
await setupAccounts(nodes[1].cliHome, join(cliHomePrefix, `lcd`), {
keyName: `local-test`
})
}

// run Voyager in a development environment
let child = await runner(networkPath, extendedEnv)

// kill all development processes if master process fails
process.on(`exit`, () => {
child.kill(`SIGKILL`)
})
child.on(`exit`, () => process.exit())
await buildNodes(
join(buildTestnetPath, network),
{
chainId: network,
password: `1234567890`,
overwrite: false,
moniker: `local`,
keyName: `main-account`
},
numberNodes
)
}

main().catch(function(error) {
console.error(`Starting the application failed`, error)
})
main()

0 comments on commit 85f9b0c

Please sign in to comment.