Keygen restart tests
This commit is contained in:
parent
2d444a8cd2
commit
3b6e64b784
|
@ -27,4 +27,6 @@ VOTES_PROXY_PORT=5001
|
||||||
|
|
||||||
SIGN_RESTART_PORT=6001
|
SIGN_RESTART_PORT=6001
|
||||||
|
|
||||||
|
KEYGEN_RESTART_PORT=7001
|
||||||
|
|
||||||
LOG_LEVEL=trace
|
LOG_LEVEL=trace
|
||||||
|
|
|
@ -27,4 +27,6 @@ VOTES_PROXY_PORT=5001
|
||||||
|
|
||||||
SIGN_RESTART_PORT=6001
|
SIGN_RESTART_PORT=6001
|
||||||
|
|
||||||
|
KEYGEN_RESTART_PORT=7001
|
||||||
|
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
|
|
@ -27,4 +27,6 @@ VOTES_PROXY_PORT=5002
|
||||||
|
|
||||||
SIGN_RESTART_PORT=6002
|
SIGN_RESTART_PORT=6002
|
||||||
|
|
||||||
|
KEYGEN_RESTART_PORT=7002
|
||||||
|
|
||||||
LOG_LEVEL=trace
|
LOG_LEVEL=trace
|
||||||
|
|
|
@ -27,4 +27,6 @@ VOTES_PROXY_PORT=5002
|
||||||
|
|
||||||
SIGN_RESTART_PORT=6002
|
SIGN_RESTART_PORT=6002
|
||||||
|
|
||||||
|
KEYGEN_RESTART_PORT=7002
|
||||||
|
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
|
|
@ -27,4 +27,6 @@ VOTES_PROXY_PORT=5003
|
||||||
|
|
||||||
SIGN_RESTART_PORT=6003
|
SIGN_RESTART_PORT=6003
|
||||||
|
|
||||||
|
KEYGEN_RESTART_PORT=7003
|
||||||
|
|
||||||
LOG_LEVEL=trace
|
LOG_LEVEL=trace
|
||||||
|
|
|
@ -27,4 +27,6 @@ VOTES_PROXY_PORT=5003
|
||||||
|
|
||||||
SIGN_RESTART_PORT=6003
|
SIGN_RESTART_PORT=6003
|
||||||
|
|
||||||
|
KEYGEN_RESTART_PORT=7003
|
||||||
|
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
|
|
@ -39,6 +39,8 @@ services:
|
||||||
- LOG_LEVEL
|
- LOG_LEVEL
|
||||||
volumes:
|
volumes:
|
||||||
- '${PWD}/${TARGET_NETWORK}/keys:/keys'
|
- '${PWD}/${TARGET_NETWORK}/keys:/keys'
|
||||||
|
ports:
|
||||||
|
- '${KEYGEN_RESTART_PORT}:8001'
|
||||||
networks:
|
networks:
|
||||||
- test_network
|
- test_network
|
||||||
signer:
|
signer:
|
||||||
|
|
|
@ -36,6 +36,8 @@ services:
|
||||||
- LOG_LEVEL
|
- LOG_LEVEL
|
||||||
volumes:
|
volumes:
|
||||||
- '${PWD}/${TARGET_NETWORK}/keys:/keys'
|
- '${PWD}/${TARGET_NETWORK}/keys:/keys'
|
||||||
|
ports:
|
||||||
|
- '${KEYGEN_RESTART_PORT}:8001'
|
||||||
networks:
|
networks:
|
||||||
- keygen-proxy-net
|
- keygen-proxy-net
|
||||||
- rabbit-keygen-net
|
- rabbit-keygen-net
|
||||||
|
|
|
@ -44,6 +44,12 @@ function killKeygen() {
|
||||||
exec.execSync('pkill gg18_keygen || true')
|
exec.execSync('pkill gg18_keygen || true')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restart(req, res) {
|
||||||
|
logger.info('Manual cancelling current keygen attempt')
|
||||||
|
killKeygen()
|
||||||
|
res.send('Done')
|
||||||
|
}
|
||||||
|
|
||||||
function keygen(keysFile, epoch) {
|
function keygen(keysFile, epoch) {
|
||||||
let restartTimeoutId
|
let restartTimeoutId
|
||||||
let epochDaemonIntervalId
|
let epochDaemonIntervalId
|
||||||
|
@ -144,7 +150,7 @@ async function main() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.get('/restart', restart)
|
||||||
app.get('/start', (req, res) => {
|
app.get('/start', (req, res) => {
|
||||||
logger.info('Ready to start')
|
logger.info('Ready to start')
|
||||||
ready = true
|
ready = true
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
FOREIGN_URL=http://http-api:8000
|
FOREIGN_URL=http://http-api:8000
|
||||||
FOREIGN_ASSET=DEV-BA8
|
FOREIGN_ASSET=DEV-9BA
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FOREIGN_URL=http://http-api:8000
|
FOREIGN_URL=http://http-api:8000
|
||||||
FOREIGN_ASSET=DEV-BA8
|
FOREIGN_ASSET=DEV-9BA
|
||||||
|
|
||||||
FOREIGN_PRIVATE_KEY=dd5ec5a7abe9d1fff21170ae591085f000fc6fd9ca0107fe047593f44e328e40
|
FOREIGN_PRIVATE_KEY=dd5ec5a7abe9d1fff21170ae591085f000fc6fd9ca0107fe047593f44e328e40
|
||||||
|
|
|
@ -7,5 +7,5 @@ SIDE_RPC_URL=http://ganache_side:8545
|
||||||
|
|
||||||
FOREIGN_URL=http://http-api:8000
|
FOREIGN_URL=http://http-api:8000
|
||||||
FOREIGN_CHAIN_ID=Binance-Dev
|
FOREIGN_CHAIN_ID=Binance-Dev
|
||||||
FOREIGN_ASSET=DEV-BA8
|
FOREIGN_ASSET=DEV-9BA
|
||||||
FOREIGN_PRIVATE_KEY=dd5ec5a7abe9d1fff21170ae591085f000fc6fd9ca0107fe047593f44e328e40
|
FOREIGN_PRIVATE_KEY=dd5ec5a7abe9d1fff21170ae591085f000fc6fd9ca0107fe047593f44e328e40
|
||||||
|
|
|
@ -2,16 +2,21 @@ const assert = require('assert')
|
||||||
|
|
||||||
const { waitPromise, delay } = require('./utils/wait')
|
const { waitPromise, delay } = require('./utils/wait')
|
||||||
const { getBepBalance, getBncFlags } = require('./utils/bncController')
|
const { getBepBalance, getBncFlags } = require('./utils/bncController')
|
||||||
|
const { getNonce } = require('./utils/sideController')
|
||||||
const { controller1, controller2, controller3 } = require('./utils/proxyController')
|
const { controller1, controller2, controller3 } = require('./utils/proxyController')
|
||||||
|
const { keygenController1 } = require('./utils/keygenController')
|
||||||
|
|
||||||
|
const { validators } = require('../config')
|
||||||
|
|
||||||
module.exports = (newThreshold) => {
|
module.exports = (newThreshold) => {
|
||||||
describe('change threshold', function () {
|
describe('change threshold', function () {
|
||||||
let info
|
let info
|
||||||
let initialInfo
|
let initialInfo
|
||||||
|
let validatorNonce
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
initialInfo = await controller1.getInfo()
|
initialInfo = await controller1.getInfo()
|
||||||
|
validatorNonce = await getNonce(validators[0])
|
||||||
info = initialInfo
|
info = initialInfo
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -89,8 +94,17 @@ module.exports = (newThreshold) => {
|
||||||
assert.strictEqual(info.nextThreshold, newThreshold, 'Next threshold is not set correctly')
|
assert.strictEqual(info.nextThreshold, newThreshold, 'Next threshold is not set correctly')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should finish keygen process and start funds transfer', async function () {
|
it('should start keys generation', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
await waitPromise(
|
||||||
|
() => getNonce(validators[0]),
|
||||||
|
(nonce) => nonce > validatorNonce + 2
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should restart keygen generation and regenerate keys properly, should start funds transfer', async function () {
|
||||||
|
this.timeout(360000)
|
||||||
|
await keygenController1.restart()
|
||||||
info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'funds_transfer')
|
info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'funds_transfer')
|
||||||
const flags = await getBncFlags(initialInfo.foreignBridgeAddress)
|
const flags = await getBncFlags(initialInfo.foreignBridgeAddress)
|
||||||
assert.strictEqual(flags, 0, 'Foreign bridge flags are not set correctly')
|
assert.strictEqual(flags, 0, 'Foreign bridge flags are not set correctly')
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
function createController(validatorId) {
|
||||||
|
const url = `http://validator${validatorId}_keygen_1:8001/`
|
||||||
|
|
||||||
|
const keygenClient = axios.create({
|
||||||
|
baseURL: url,
|
||||||
|
timeout: 10000
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
async restart() {
|
||||||
|
await keygenClient.get('/restart')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
keygenController1: createController(1),
|
||||||
|
keygenController2: createController(2),
|
||||||
|
keygenController3: createController(3)
|
||||||
|
}
|
|
@ -3,14 +3,14 @@ const axios = require('axios')
|
||||||
function createController(validatorId) {
|
function createController(validatorId) {
|
||||||
const url = `http://validator${validatorId}_signer_1:8001/`
|
const url = `http://validator${validatorId}_signer_1:8001/`
|
||||||
|
|
||||||
const sideClient = axios.create({
|
const signerClient = axios.create({
|
||||||
baseURL: url,
|
baseURL: url,
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async restart() {
|
async restart() {
|
||||||
await sideClient.get('/restart')
|
await signerClient.get('/restart')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue