Skip to content

Commit

Permalink
Merge the develop branch to the master branch, preparation to v2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
akolotov authored Jul 29, 2020
2 parents 64cd258 + ab406bc commit 8a42cfb
Show file tree
Hide file tree
Showing 17 changed files with 566 additions and 25 deletions.
16 changes: 14 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ jobs:
command: |
docker login -u ${DOCKER_LOGIN} -p ${DOCKER_PASSWORD}
cd e2e-commons
docker-compose build oracle monitor ui e2e molecule_runner
docker-compose push oracle monitor ui e2e molecule_runner
docker-compose build oracle monitor ui alm e2e molecule_runner
docker-compose push oracle monitor ui alm e2e molecule_runner
oracle-e2e:
executor: tokenbridge-orb/machine-without-dlc
steps:
Expand All @@ -164,6 +164,14 @@ jobs:
steps:
- tokenbridge-orb/init-repo
- run: ./monitor-e2e/run-tests.sh
alm-e2e:
executor: tokenbridge-orb/machine-without-dlc
steps:
- tokenbridge-orb/install-node
- tokenbridge-orb/install-yarn
- restore_cache:
key: initialize-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn run alm-e2e
cover:
executor: tokenbridge-orb/docker-node
steps:
Expand Down Expand Up @@ -288,6 +296,10 @@ workflows:
- monitor-e2e:
requires:
- build-e2e-images
- alm-e2e:
requires:
- build-e2e-images
- initialize
- deployment-oracle:
requires:
- build-e2e-images
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.16
10.22
15 changes: 15 additions & 0 deletions alm-e2e/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": [
"plugin:node/recommended",
"airbnb-base",
"../.eslintrc"
],
"plugins": ["node", "jest"],
"env": {
"jest/globals": true
},
"globals": {
"page": true,
"browser": true
}
}
24 changes: 24 additions & 0 deletions alm-e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "alm-e2e",
"version": "0.0.1",
"private": true,
"scripts": {
"test": "jest --detectOpenHandles",
"lint": "eslint . --ignore-path ../.eslintignore",
"lint:fix": "eslint . --fix"
},
"dependencies": {
"jest": "24.7.1",
"jest-puppeteer": "^4.4.0",
"puppeteer": "^5.2.1"
},
"jest": {
"preset": "jest-puppeteer"
},
"devDependencies": {
"eslint-plugin-jest": "^23.18.0"
},
"engines": {
"node": ">= 8.9"
}
}
13 changes: 13 additions & 0 deletions alm-e2e/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
cd $(dirname $0)

../e2e-commons/up.sh deploy blocks alm alm-e2e

# run oracle amb e2e tests to generate transactions for alm
docker-compose -f ../e2e-commons/docker-compose.yml run e2e yarn workspace oracle-e2e run alm

yarn test
rc=$?

../e2e-commons/down.sh
exit $rc
50 changes: 50 additions & 0 deletions alm-e2e/src/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const puppeteer = require('puppeteer')
const { waitUntil } = require('./utils/utils')

jest.setTimeout(60000)

const statusText = 'Success'
const statusSelector = 'label[data-id="status"]'

const homeToForeignTxURL = 'http://localhost:3004/77/0x58e7d63368335b9591d4dbb43889084f698fcee93ab7656fd7a39d8c66bc4b60'
const foreignToHomeTxURL = 'http://localhost:3004/42/0x592bf28fc896419d2838f71cd0388775814b692688f1ecd5b1519081566b994a'

describe('ALM', () => {
let browser
let page

beforeAll(async () => {
browser = await puppeteer.launch()
page = await browser.newPage()
})

afterAll(async () => {
await browser.close()
})

it('should be titled "AMB Live Monitoring"', async () => {
await page.goto(foreignToHomeTxURL)

await expect(page.title()).resolves.toMatch('AMB Live Monitoring')
})
it('should display information of foreign to home transaction', async () => {
await page.goto(foreignToHomeTxURL)

await page.waitForSelector(statusSelector)
await waitUntil(async () => {
const element = await page.$(statusSelector)
const text = await page.evaluate(element => element.textContent, element)
return text === statusText
})
})
it('should display information of home to foreign transaction', async () => {
await page.goto(homeToForeignTxURL)

await page.waitForSelector(statusSelector)
await waitUntil(async () => {
const element = await page.$(statusSelector)
const text = await page.evaluate(element => element.textContent, element)
return text === statusText
})
})
})
15 changes: 15 additions & 0 deletions alm-e2e/src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const waitUntil = async (predicate, step = 100, timeout = 20000) => {
const stopTime = Date.now() + timeout
while (Date.now() <= stopTime) {
const result = await predicate()
if (result) {
return result
}
await new Promise(resolve => setTimeout(resolve, step)) // sleep
}
throw new Error(`waitUntil timed out after ${timeout} ms`)
}

module.exports = {
waitUntil
}
2 changes: 1 addition & 1 deletion alm/src/components/ConfirmationsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const ConfirmationsContainer = ({ message, receipt, fromHome, timestamp }
<StyledConfirmationContainer className="col-9">
<div className="row is-center">
<StatusLabel>Status:</StatusLabel>
<StatusResultLabel>
<StatusResultLabel data-id="status">
{status !== CONFIRMATIONS_STATUS.UNDEFINED ? statusLabel[status] : <SimpleLoading />}
</StatusResultLabel>
</div>
Expand Down
5 changes: 4 additions & 1 deletion alm/src/utils/getConfirmationsForTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ export const getConfirmationsForTx = async (
status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED
}))

validatorConfirmations = [...validatorConfirmations, ...notRequiredConfirmations]
notRequiredConfirmations.forEach(validatorData => {
const index = validatorConfirmations.findIndex(e => e.validator === validatorData.validator)
validatorConfirmations[index] = validatorData
})
signatureCollectedResult = true
}

Expand Down
2 changes: 1 addition & 1 deletion deployment/group_vars/wetc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
UI_NATIVE_TOKEN_DISPLAY_NAME: "ETC"

## Home contract
COMMON_HOME_RPC_URL: "https://ethereumclassic.network"
COMMON_HOME_RPC_URL: "https://www.ethercluster.com/etc"
UI_HOME_NETWORK_DISPLAY_NAME: "Ethereum Classic"
UI_HOME_WITHOUT_EVENTS: false
COMMON_HOME_BRIDGE_ADDRESS: "0x073081832B4Ecdce79d4D6753565c85Ba4b3BeA9"
Expand Down
10 changes: 10 additions & 0 deletions e2e-commons/components-envs/alm.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
COMMON_HOME_BRIDGE_ADDRESS=0x0AEe1FCD12dDFab6265F7f8956e6E012A9Fe4Aa0
COMMON_FOREIGN_BRIDGE_ADDRESS=0x0AEe1FCD12dDFab6265F7f8956e6E012A9Fe4Aa0

COMMON_HOME_RPC_URL=http://localhost:8541
COMMON_FOREIGN_RPC_URL=http://localhost:8542

ALM_HOME_NETWORK_NAME=Parity1
ALM_FOREIGN_NETWORK_NAME=Parity2

PORT=3000
10 changes: 10 additions & 0 deletions e2e-commons/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ services:
command: "true"
networks:
- ultimate
alm:
image: ${DOCKER_LOGIN}/tokenbridge-e2e-alm:${CIRCLE_BRANCH}
build:
context: ..
dockerfile: alm/Dockerfile
args:
DOT_ENV_PATH: e2e-commons/components-envs/alm.env
command: "true"
networks:
- ultimate
monitor:
image: ${DOCKER_LOGIN}/tokenbridge-e2e-monitor:${CIRCLE_BRANCH}
build:
Expand Down
2 changes: 2 additions & 0 deletions e2e-commons/pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ while [ "$1" != "" ]; do
docker-compose pull monitor
elif [ "$1" == "ui" ]; then
docker-compose pull ui
elif [ "$1" == "alm" ]; then
docker-compose pull alm
fi
shift
done
36 changes: 36 additions & 0 deletions e2e-commons/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ startValidator () {
docker-compose $1 run $2 $3 -d oracle-erc20-native yarn sender:foreign
}

startAMBValidator () {
docker-compose $1 run -d --name $4 redis
docker-compose $1 run -d --name $5 rabbit
docker-compose $1 run $2 $3 -d oracle-amb yarn watcher:signature-request
docker-compose $1 run $2 $3 -d oracle-amb yarn watcher:collected-signatures
docker-compose $1 run $2 $3 -d oracle-amb yarn watcher:affirmation-request
docker-compose $1 run $2 $3 -d oracle-amb yarn sender:home
docker-compose $1 run $2 $3 -d oracle-amb yarn sender:foreign
}

while [ "$1" != "" ]; do
if [ "$1" == "oracle" ]; then
docker-compose up -d redis rabbit
Expand Down Expand Up @@ -83,6 +93,12 @@ while [ "$1" != "" ]; do
docker-compose run -d -p 3003:3000 ui-amb-stake-erc20-erc20 yarn start
fi

if [ "$1" == "alm" ]; then
docker-compose up -d alm

docker-compose run -d -p 3004:3000 alm serve -p 3000 -s .
fi

if [ "$1" == "deploy" ]; then
docker-compose run e2e e2e-commons/scripts/deploy.sh
fi
Expand Down Expand Up @@ -115,5 +131,25 @@ while [ "$1" != "" ]; do
../deployment-e2e/molecule.sh ultimate-amb-stake-erc-to-erc
fi

if [ "$1" == "alm-e2e" ]; then
docker-compose up -d redis rabbit

docker-compose run -d oracle-amb yarn watcher:signature-request
docker-compose run -d oracle-amb yarn watcher:collected-signatures
docker-compose run -d oracle-amb yarn watcher:affirmation-request
docker-compose run -d oracle-amb yarn sender:home
docker-compose run -d oracle-amb yarn sender:foreign

oracle2name="-p validator2"
oracle2Values="-e ORACLE_VALIDATOR_ADDRESS=0xdCC784657C78054aa61FbcFFd2605F32374816A4 -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=5a5c3645d0f04e9eb4f27f94ed4c244a225587405b8838e7456f7781ce3a9513"
oracle2comp="-e ORACLE_QUEUE_URL=amqp://rabbit2 -e ORACLE_REDIS_URL=redis://redis2"
startAMBValidator "$oracle2name" "$oracle2Values" "$oracle2comp" "redis2" "rabbit2"

oracle3name="-p validator3"
oracle3Values="-e ORACLE_VALIDATOR_ADDRESS=0xDcef88209a20D52165230104B245803C3269454d -e ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=f877f62a1c19f852cff1d29f0fb1ecac18821c0080d4cc0520c60c098293dca1"
oracle3comp="-e ORACLE_QUEUE_URL=amqp://rabbit3 -e ORACLE_REDIS_URL=redis://redis3"
startAMBValidator "$oracle3name" "$oracle3Values" "$oracle3comp" "redis3" "rabbit3"
fi

shift # Shift all the parameters down by one
done
3 changes: 2 additions & 1 deletion oracle-e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"start": "mocha",
"lint": "eslint . --ignore-path ../.eslintignore",
"amb": "ULTIMATE=true mocha test/amb.js"
"amb": "ULTIMATE=true mocha test/amb.js",
"alm": "mocha test/amb.js"
},
"author": "",
"license": "ISC",
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"monitor-e2e",
"contracts",
"burner-wallet-plugin",
"alm"
"alm",
"alm-e2e"
],
"scripts": {
"initialize": "yarn clean && git submodule update --init && yarn install --unsafe-perm --frozen-lockfile && yarn install:deploy && yarn compile:contracts",
Expand All @@ -39,10 +40,11 @@
"build:alm": "yarn workspace alm run build",
"build:plugin": "yarn workspace burner-wallet-plugin run build",
"lint": "yarn wsrun --exclude token-bridge-contracts lint",
"test": "yarn wsrun --exclude oracle-e2e --exclude ui-e2e --exclude monitor-e2e test",
"test": "yarn wsrun --exclude oracle-e2e --exclude ui-e2e --exclude monitor-e2e --exclude alm-e2e test",
"oracle-e2e": "./oracle-e2e/run-tests.sh",
"ui-e2e": "./ui-e2e/run-tests.sh",
"monitor-e2e": "./monitor-e2e/run-tests.sh",
"alm-e2e": "./alm-e2e/run-tests.sh",
"clean": "rm -rf ./node_modules ./**/node_modules ./**/**/node_modules ./**/build ./**/**/dist",
"compile:contracts": "yarn workspace token-bridge-contracts run compile",
"install:deploy": "cd contracts/deploy && npm install --unsafe-perm --silent",
Expand Down
Loading

0 comments on commit 8a42cfb

Please sign in to comment.