Added more initialization of environment

This commit is contained in:
Kirill Fedoseev 2019-10-21 21:43:31 +03:00
parent 159c097505
commit 088aee652d
7 changed files with 89 additions and 21 deletions

View File

@ -8,33 +8,40 @@ orbs:
environment:
TARGET_NETWORK: development
jobs:
prepare_test_environment:
executor: bridge/node-dev
steps:
- checkout
- run: git submodule update --init
- setup_remote_docker
- run: ./demo/start-environment.sh
- run: ./src/test-services/ethereumSend/run.sh 0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa 100
- run: ./src/test-services/ethereumSend/run.sh 0xf7ca4aed1795e424433498cef43f6a3825c88731 100
- run: ./src/test-services/ethereumSend/run.sh 0xad6c8127143032d843a260c5d379d8d9b3d51f15 100
- run: docker kill ganache_side ganache_home
- persist_to_workspace:
root: .
paths:
./demo/ganache_home_db
./demo/ganache_side_db
run_tests:
executor: bridge/node-dev
steps:
- checkout
- run: git submodule update --init
- setup_remote_docker
- attach_workspace:
at: .
- ls ./demo/ganache_side_db
- run: touch ./src/deploy/.keys.$TARGET_NETWORK
- run: ./demo/start-environment.sh
- run: touch ./src/test-services/.keys.$TARGET_NETWORK
- run: ./src/test-services/ethereumSend/run.sh 0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa 100
- run: ./src/test-services/ethereumSend/run.sh 0xf7ca4aed1795e424433498cef43f6a3825c88731 100
- run: ./src/test-services/ethereumSend/run.sh 0xad6c8127143032d843a260c5d379d8d9b3d51f15 100
- run: ./src/test-services/binanceSend/run.sh tbnb14r3z8xk7qsar3vwj05w8cd8gqwk7g6gfurlt5l 100 0.1
- run: ./src/test-services/binanceSend/run.sh tbnb1efjg7xt98t67ql2cmwjc5860lgayet9l8m55ym 100 0.1
- run: ./src/test-services/binanceSend/run.sh tbnb12epcy4p7ktas0nlyrfuektcyh0e83dwzuq73f4 100 0.1
- run:
command: ./demo/validator-demo.sh -d
environment:
N: 1
- run:
command: ./demo/validator-demo.sh -d
environment:
N: 2
- run:
command: ./demo/validator-demo.sh -d
environment:
N: 3
- run: sleep 10
- run:
command: ./tests/run.sh
environment:
HOME_RPC_URL: 'http://ganache_home:8545'
workflows:
version: 2
main:
jobs:
- prepare_test_environment
- run_tests

View File

@ -23,4 +23,4 @@ fi
# load env for particular environment
source ".env.$TARGET_NETWORK"
docker-compose -p "$NAME" -f ../../src/oracle/docker-compose-test.yml up ${DCU_FLAGS}
docker-compose -p "$NAME" -f ../../src/oracle/docker-compose-test.yml up ${DCU_FLAGS} $@

14
tests/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM node:10.16.0-alpine
WORKDIR /tests
RUN npm install -g mocha
COPY ./package.json .
RUN npm install
COPY config.json ./
COPY test ./test
ENTRYPOINT ["mocha"]

19
tests/config.json Normal file
View File

@ -0,0 +1,19 @@
{
"users": [
{
"privateKey": "7ed93ad7753e00b52265a73dfbbcd2296256772965323fcb9a6320b5cd084b89",
"ethAddress": "0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa",
"bncAddress": "tbnb14r3z8xk7qsar3vwj05w8cd8gqwk7g6gfurlt5l"
},
{
"privateKey": "2ad6e3a232ad3ea058b61352302118a99085600ff8b6eec4ccf0066a33756231",
"ethAddress": "0xf7ca4aed1795e424433498cef43f6a3825c88731",
"bncAddress": "tbnb1efjg7xt98t67ql2cmwjc5860lgayet9l8m55ym"
},
{
"privateKey": "eb6dd328677b3fa2822fb8e834507e569bda52e8ffa49266df0f2de239c4ec98",
"ethAddress": "0xad6c8127143032d843a260c5d379d8d9b3d51f15",
"bncAddress": "tbnb12epcy4p7ktas0nlyrfuektcyh0e83dwzuq73f4"
}
]
}

7
tests/package.json Normal file
View File

@ -0,0 +1,7 @@
{
"name": "tests",
"version": "0.0.1",
"dependencies": {
"web3": "1.0.0-beta.55"
}
}

9
tests/run.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd $(dirname "$0")
docker build -t tests . > /dev/null
docker run --network blockchain_home --rm -e HOME_RPC_URL tests $@

12
tests/test/index.js Normal file
View File

@ -0,0 +1,12 @@
const Web3 = require('web3')
const { users } = require('../config')
const web3 = new Web3(process.env.HOME_RPC_URL)
describe('check balance', function () {
it('should have correct balance', async function () {
const balance = await web3.eth.getBalance(users[0].ethAddress)
console.log(balance.toNumber())
return 0
})
})