-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
68 lines (58 loc) · 2.37 KB
/
node.go
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
package pfcharness
import (
"github.com/jfixby/coinharness"
"github.com/jfixby/pin"
"github.com/jfixby/pin/commandline"
)
// ConsoleNodeFactory produces a new ConsoleNode-instance upon request
type ConsoleNodeFactory struct {
// NodeExecutablePathProvider returns path to the pfcd executable
NodeExecutablePathProvider commandline.ExecutablePathProvider
ConsoleCommandCook ConsoleCommandCook
RPCClientFactory RPCClientFactory
}
// NewNode creates and returns a fully initialized instance of the ConsoleNode.
func (factory *ConsoleNodeFactory) NewNode(config *coinharness.TestNodeConfig) coinharness.Node {
pin.AssertNotNil("WorkingDir", config.WorkingDir)
pin.AssertNotEmpty("WorkingDir", config.WorkingDir)
pin.AssertNotEmpty("NodeUser", config.NodeUser)
pin.AssertNotEmpty("NodePassword", config.NodePassword)
args := &coinharness.NewConsoleNodeArgs{
ClientFac: &factory.RPCClientFactory,
ConsoleCommandCook: &factory.ConsoleCommandCook,
NodeExecutablePathProvider: factory.NodeExecutablePathProvider,
RpcUser: config.NodeUser,
RpcPass: config.NodePassword,
AppDir: config.WorkingDir,
P2PHost: config.P2PHost,
P2PPort: config.P2PPort,
NodeRPCHost: config.NodeRPCHost,
NodeRPCPort: config.NodeRPCPort,
ActiveNet: config.ActiveNet,
}
return coinharness.NewConsoleNode(args)
}
type ConsoleCommandCook struct {
}
// cookArguments prepares arguments for the command-line call
func (cook *ConsoleCommandCook) CookArguments(par *coinharness.ConsoleCommandNodeParams) map[string]interface{} {
result := make(map[string]interface{})
result["txindex"] = commandline.NoArgumentValue
result["addrindex"] = commandline.NoArgumentValue
result["rpcuser"] = par.RpcUser
result["rpcpass"] = par.RpcPass
result["rpcconnect"] = par.RpcConnect
result["rpclisten"] = par.RpcListen
result["listen"] = par.P2pAddress
result["datadir"] = par.AppDir
result["debuglevel"] = par.DebugLevel
result["profile"] = par.Profile
result["rpccert"] = par.CertFile
result["rpckey"] = par.KeyFile
if par.MiningAddress != nil {
result["miningaddr"] = par.MiningAddress.String()
}
result[NetworkFor(par.Network)] = commandline.NoArgumentValue
commandline.ArgumentsCopyTo(par.ExtraArguments, result)
return result
}