-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.go
More file actions
82 lines (61 loc) · 2.02 KB
/
setup.go
File metadata and controls
82 lines (61 loc) · 2.02 KB
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
package main
import (
"fmt"
"github.com/jfixby/coinharness"
"github.com/jfixby/pin"
"path/filepath"
)
type Setup struct {
// WorkingDir defines test setup working dir
WorkingDir *pin.TempDirHandler
}
func NewInstance(harnessName string, testSetup *coinharness.ChainWithMatureOutputsSpawner) pin.Spawnable {
harnessFolderName := "harness-" + harnessName
pin.AssertNotNil("ConsoleNodeFactory", testSetup.NodeFactory)
pin.AssertNotNil("ActiveNet", testSetup.ActiveNet)
pin.AssertNotNil("WalletFactory", testSetup.WalletFactory)
harnessFolder := filepath.Join(testSetup.WorkingDir, harnessFolderName)
walletFolder := filepath.Join(harnessFolder, "wallet")
nodeFolder := filepath.Join(harnessFolder, "node")
p2p := testSetup.NetPortManager.ObtainPort()
nodeRPC := testSetup.NetPortManager.ObtainPort()
walletRPC := testSetup.NetPortManager.ObtainPort()
localhost := "127.0.0.1"
nodeConfig := &coinharness.TestNodeConfig{
P2PHost: localhost,
P2PPort: p2p,
NodeRPCHost: localhost,
NodeRPCPort: nodeRPC,
NodeUser: "node.user",
NodePassword: "node.pass",
ActiveNet: testSetup.ActiveNet,
WorkingDir: nodeFolder,
}
walletConfig := &coinharness.TestWalletConfig{
Seed: testSetup.NewTestSeed(0),
NodeRPCHost: localhost,
NodeRPCPort: nodeRPC,
WalletRPCHost: localhost,
WalletRPCPort: walletRPC,
NodeUser: "node.user",
NodePassword: "node.pass",
WalletUser: "wallet.user",
WalletPassword: "wallet.pass",
ActiveNet: testSetup.ActiveNet,
WorkingDir: walletFolder,
}
harness := &coinharness.Harness{
Name: harnessName,
Node: testSetup.NodeFactory.NewNode(nodeConfig),
Wallet: testSetup.WalletFactory.NewWallet(walletConfig),
WorkingDir: harnessFolder,
}
pin.AssertTrue("Networks match", harness.Node.Network() == harness.Wallet.Network())
nodeNet := harness.Node.Network()
walletNet := harness.Wallet.Network()
pin.AssertTrue(
fmt.Sprintf(
"Wallet net<%v> is the same as Node net<%v>", walletNet, nodeNet),
walletNet == nodeNet)
return harness
}