tokenbridge/e2e-commons/scripts/blocks.js

40 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2019-06-03 15:49:40 +02:00
const Web3 = require('web3')
const homeWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity1:8545'))
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity2:8545'))
const {user, blockGenerator} = require('../constants.json');
homeWeb3.eth.accounts.wallet.add(user.privateKey)
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
homeWeb3.eth.accounts.wallet.add(blockGenerator.privateKey)
foreignWeb3.eth.accounts.wallet.add(blockGenerator.privateKey)
2019-06-03 15:49:40 +02:00
function generateNewBlock(web3, address) {
return web3.eth.sendTransaction({
from: address,
to: '0x0000000000000000000000000000000000000000',
gasPrice: '1',
gas: '21000',
value: '1'
})
}
2019-06-03 15:49:40 +02:00
function main() {
setTimeout(async () => {
try {
generateNewBlock(homeWeb3, blockGenerator.address)
2020-07-14 21:53:05 +07:00
} catch (_) {} // in case of Transaction with the same hash was already imported.
try {
generateNewBlock(foreignWeb3, blockGenerator.address)
2020-07-14 21:53:05 +07:00
} catch (_) {} // in case of Transaction with the same hash was already imported.
2019-06-03 15:49:40 +02:00
main()
}, 1000)
2019-06-03 15:49:40 +02:00
}
main()
process.on('SIGTERM', function () {
console.log('Finishing sending blocks...')
process.exit(0);
});