-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocal.js
93 lines (88 loc) · 2.97 KB
/
local.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
86
87
88
89
90
91
92
93
'use strict'
const { series } = require('async')
const TestHarness = require('../src/index')
const Api = require('../src/api')
let th = new TestHarness()
th.run({
local: true,
name: 'test123',
livepeerBinaryPath: '../containers/lpnode/livepeer_linux/livepeer',
blockchain: {
// keep these to run a private testnet.
name: 'lpTestNet',
networkId: 54321,
controllerAddress: '0xA1fe753Fe65002C22dDc7eab29A308f73C7B6982' //pm
},
nodes: {
transcoders: {
// how many containers to run as transcoders.
instances: 1,
// these are the livepeer binary flags, add them as you wish.
// the test-harness overrides flags that has to do with directories or
// ip/port bindings, these are automated.
flags: '--v 4 -transcoder -initializeRound=true'
},
orchestrators: {
instances: 1,
// TODO these are not complete, try adding the right orchestrator flags :)
flags: '--v 4 -initializeRound'
},
broadcasters: {
instances: 2,
flags: '--v 4'
}
}
}, (err, experiment) => {
// experiment is a parsed compose file.
if (err) throw err
console.log('so far so good')
// Now we have a running network.
// lets get some tokens, do some deposits and activate transcoders
var api = new Api(experiment)
// NOTE: all API methods are based on `livepeer_cli`
// the first parameter is always an array that can be
// 'all' , all the livepeer nodes.
// 'broadcasters', 'transcoders', 'orchestrators' : types of nodes.
// 'lp_broadcaster_0' : a single lp node.
series([
(next) => { api.requestTokens(['all'], next) },
(next) => { api.fundDeposit(['all'], '5000000000', next) },
(next) => { api.initializeRound(['lp_transcoder_0'], next) },
(next) => {
console.log('activating transcoders...')
api.activateOrchestrator(['orchestrators', 'transcoders'], {
blockRewardCut: '10',
feeShare: '5',
pricePerSegment: '1',
amount: '500'
// ServiceURI will be set by the test-harness.
}, next)
}
], (err, results) => {
if (err) throw err
console.log('done!')
})
// If you like callbacks (lol) , here is the same code without async.series
// api.requestTokens(['all'], (err, output) => {
// if (err) throw err
// console.log('requested LPT', output)
// api.fundDeposit(['all'], '5000000000', (err, output) => {
// console.log('funds deposited')
// api.initializeRound(['lp_transcoder_0'], (err, output) => {
// if (err) throw err
// console.log('round initialized!', output)
// api.activateOrchestrator(['orchestrators', 'transcoders'], {
// blockRewardCut: '10',
// feeShare: '5',
// pricePerSegment: '1',
// amount: '500'
// // ServiceURI will be set by the test-harness.
// }, (err, output) => {
// if (err) throw err
// console.log('we good.', output)
// cb()
// })
// })
// })
// })
})