Skip to content

Commit

Permalink
Local Dev Env / Setup all UTXOs for Planet A (#36)
Browse files Browse the repository at this point in the history
* setup all UTXOs

* fund earth conract

* make 9_gameCondition to be a recipe

* move run.js into src

* allow to run as a loca lenv or as integration tests

Either:
`yarn test` — run as integration tests as usual
`yarn start` — run local env
`yarn start planetA` — run local env with recipe

* add Air to the mix

* alternative coctail

* basic docker container
  • Loading branch information
johannbarbie authored and troggy committed Jul 26, 2019
1 parent 47ad33d commit 08a99d9
Show file tree
Hide file tree
Showing 22 changed files with 764 additions and 3,997 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.travis.yml
docker-compose.yml
Dockerfile
out/
build/
.github/
.node_modules/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build/*
out
out
process.json
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:lts-alpine
ARG BUILD_DEPS="git g++ cmake make python2 bash"

WORKDIR /opt/leap-local-env

COPY . /opt/leap-local-env

RUN apk add --no-cache --update --virtual build_deps $BUILD_DEPS
RUN yarn
RUN yarn build

EXPOSE 7000
EXPOSE 8545

ENTRYPOINT ["yarn", "start"]
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,43 @@ accounts = [{addr, privKey}, {addr, privKey}...]
// web3 is just Web3 contected to the ganache network
web3 = Web3
```

## Start local environment for development

### Start default / vanilla Leap network

```sh
yarn start
```

This will launch a local Leap Network for you: Ganache as a root chain with Leap contracts deployed and leap-node with JSON RPC.

### Start flavoured Leap Network

In `tests/recipies` you can see possible recipies to run against the local network. Each recipe prepares the environment for a particular purpose — sets up required tokens, makes deposits etc.

To start a network with recipe:

```sh
yarn start <recipe>
```

E.g. `yarn start planetA` to start a local network for Planet A project.

Alternatively, you can start vanilla leap network and then apply a recipe with `yarn apply planetA`.

### Using with Docker

Start vanilla network:

```sh
docker run -p 7000:7000 -p 8545:8545 --name leap-env quay.io/leapdao/leap-sandbox
```

Apply recipe to vanilla network:

```sh
docker exec leap-env node applyRecipe planetA
```

`yarn start <recipe>` should also work for applying recipes to dockerized network, given you have the repo working copy.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "node run.js",
"test": "node src/commands/test",
"start": "node src/commands/start",
"apply": "node src/commands/applyRecipe",
"build": "./scripts/build.sh"
},
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"debug": "^4.1.1",
"ethereumjs-util": "^6.1.0",
"ethers": "^4.0.33",
"ganache-cli": "^6.2.3",
"ganache-cli": "6.5.0",
"jsbi-utils": "^1.0.0",
"leap-core": "^0.32.3"
"leap-core": "^0.33.0"
}
}
243 changes: 0 additions & 243 deletions run.js

This file was deleted.

1 change: 1 addition & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ build_node() {
rm -rf build
mkdir build
mkdir build/logs
mkdir out || true
source configs/build

build_contracts
Expand Down
19 changes: 19 additions & 0 deletions src/commands/applyRecipe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const getEnv = require('../getEnv');

async function run(name) {
console.log('Applying recipe: ', name);
const { contracts, nodes, accounts, wallet, plasmaWallet } = await getEnv();

await require(`../../tests/recipies/${name}`)(contracts, nodes, accounts, wallet, plasmaWallet);
process.exit(0);
}

function onException (e) {
console.error(e);
process.exit(1);
}

process.on('uncaughtException', onException);
process.on('unhandledRejection', onException);

run(process.argv[2]);
18 changes: 18 additions & 0 deletions src/commands/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const startNetwork = require('../run');

async function run(name) {
const { contracts, nodes, accounts, wallet, plasmaWallet } = await startNetwork();
if (name) {
await require(`../../tests/recipies/${name}`)(contracts, nodes, accounts, wallet, plasmaWallet);
}
}

function onException (e) {
console.error(e);
process.exit(1);
}

process.on('uncaughtException', onException);
process.on('unhandledRejection', onException);

run(process.argv[2]);
Loading

0 comments on commit 08a99d9

Please sign in to comment.