forked from FIBOSIO/fib-testnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
morebps.js
85 lines (68 loc) · 2.08 KB
/
morebps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var test = require('test');
var process = require('process');
var coroutine = require('coroutine');
var accounts = require('./common/bpaccounts.json');
var config = require('./config.json');
var FIBOS = require('fibos.js');
var _config = require('./common/config.json');
var cmdarr = process.argv;
if (cmdarr.length < 4) {
console.notice('cmd like this: fibos morebps.js 2 6');
process.exit(0);
}
var bp_startnum = Number(cmdarr[2]) || 2;
var bp_endnum = Number(cmdarr[3]) || 2;
if (bp_startnum > bp_endnum || bp_endnum > 25) {
console.notice('cmd like this: fibos morebps.js 2 25');
process.exit(0);
}
var startev = cmdarr[2];
test.setup();
describe(startev + 'more bps start', () => {
var fibos;
var ctx;
before(function() {
fibos = FIBOS({
chainId: config["chainId"],
keyProvider: accounts.map(function(info) {
return info.private_key;
}),
httpEndpoint: _config["httpEndpoint"],
logger: {
log: null,
error: null
}
});
ctx = fibos.contractSync("eosio");
});
it('start bps', function() {
var httpEndpoint = 8800;
var p2p = 9800;
var startccounts = [];
accounts.forEach(function(info, index) {
if (index >= bp_startnum - 1 && index <= bp_endnum - 1) {
info.http = httpEndpoint + index + 1;
info.p2p = p2p + index + 1;
info.num = index + 1;
startccounts.push(info);
}
});
console.notice('after 5 seconds start NO.', bp_startnum, ' to No.', bp_endnum, ' BPs');
console.notice('http port is', httpEndpoint + bp_startnum, ' to ', httpEndpoint + bp_endnum);
coroutine.sleep(5000);
startccounts.forEach(function(info) {
process.start('fibos', ['./lib/morebp_start.js', info.account, info.public_key, info.private_key, info.http, info.p2p]);
coroutine.sleep(1000);
ctx.regproducerSync(info.account, info.public_key, "http://testnet.fo", 1, {
"authorization": info.account
});
ctx.voteproducerSync(info.account, "", [info.account], {
"authorization": info.account
});
console.notice('BP No.', info.num, ' is running');
coroutine.sleep(2000);
});
});
after(function() {});
});
test.run(console.DEBUG);