integration: allow setting custom btcd exe path
To allow using a custom btcd executable, we allow specifying a path to a file. If the path is empty, the harness will fall back to compiling one from scratch.
This commit is contained in:
parent
f070f7f2be
commit
9250064837
6 changed files with 31 additions and 18 deletions
|
@ -129,7 +129,7 @@ func assertSoftForkStatus(r *rpctest.Harness, t *testing.T, forkKey string, stat
|
|||
// specific soft fork deployment to test.
|
||||
func testBIP0009(t *testing.T, forkKey string, deploymentID uint32) {
|
||||
// Initialize the primary mining node with only the genesis block.
|
||||
r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, nil)
|
||||
r, err := rpctest.New(&chaincfg.RegressionNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create primary harness: %v", err)
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ func TestBIP0009Mining(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
// Initialize the primary mining node with only the genesis block.
|
||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, nil)
|
||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create primary harness: %v", err)
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ func TestBIP0113Activation(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
btcdCfg := []string{"--rejectnonstd"}
|
||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, btcdCfg)
|
||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, btcdCfg, "")
|
||||
if err != nil {
|
||||
t.Fatal("unable to create primary harness: ", err)
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
|||
// relative lock times.
|
||||
|
||||
btcdCfg := []string{"--rejectnonstd"}
|
||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, btcdCfg)
|
||||
r, err := rpctest.New(&chaincfg.SimNetParams, nil, btcdCfg, "")
|
||||
if err != nil {
|
||||
t.Fatal("unable to create primary harness: ", err)
|
||||
}
|
||||
|
|
|
@ -109,7 +109,9 @@ func TestMain(m *testing.M) {
|
|||
// ensure that non-standard transactions aren't accepted into the
|
||||
// mempool or relayed.
|
||||
btcdCfg := []string{"--rejectnonstd"}
|
||||
primaryHarness, err = rpctest.New(&chaincfg.SimNetParams, nil, btcdCfg)
|
||||
primaryHarness, err = rpctest.New(
|
||||
&chaincfg.SimNetParams, nil, btcdCfg, "",
|
||||
)
|
||||
if err != nil {
|
||||
fmt.Println("unable to create primary harness: ", err)
|
||||
os.Exit(1)
|
||||
|
|
|
@ -41,11 +41,19 @@ type nodeConfig struct {
|
|||
}
|
||||
|
||||
// newConfig returns a newConfig with all default values.
|
||||
func newConfig(prefix, certFile, keyFile string, extra []string) (*nodeConfig, error) {
|
||||
btcdPath, err := btcdExecutablePath()
|
||||
func newConfig(prefix, certFile, keyFile string, extra []string,
|
||||
customExePath string) (*nodeConfig, error) {
|
||||
|
||||
var btcdPath string
|
||||
if customExePath != "" {
|
||||
btcdPath = customExePath
|
||||
} else {
|
||||
var err error
|
||||
btcdPath, err = btcdExecutablePath()
|
||||
if err != nil {
|
||||
btcdPath = "btcd"
|
||||
}
|
||||
}
|
||||
|
||||
a := &nodeConfig{
|
||||
listen: "127.0.0.1:18555",
|
||||
|
|
|
@ -94,11 +94,12 @@ type Harness struct {
|
|||
// New creates and initializes new instance of the rpc test harness.
|
||||
// Optionally, websocket handlers and a specified configuration may be passed.
|
||||
// In the case that a nil config is passed, a default configuration will be
|
||||
// used.
|
||||
// used. If a custom btcd executable is specified, it will be used to start the
|
||||
// harness node. Otherwise a new binary is built on demand.
|
||||
//
|
||||
// NOTE: This function is safe for concurrent access.
|
||||
func New(activeNet *chaincfg.Params, handlers *rpcclient.NotificationHandlers,
|
||||
extraArgs []string) (*Harness, error) {
|
||||
extraArgs []string, customExePath string) (*Harness, error) {
|
||||
|
||||
harnessStateMtx.Lock()
|
||||
defer harnessStateMtx.Unlock()
|
||||
|
@ -144,7 +145,9 @@ func New(activeNet *chaincfg.Params, handlers *rpcclient.NotificationHandlers,
|
|||
miningAddr := fmt.Sprintf("--miningaddr=%s", wallet.coinbaseAddr)
|
||||
extraArgs = append(extraArgs, miningAddr)
|
||||
|
||||
config, err := newConfig("rpctest", certFile, keyFile, extraArgs)
|
||||
config, err := newConfig(
|
||||
"rpctest", certFile, keyFile, extraArgs, customExePath,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ func assertConnectedTo(t *testing.T, nodeA *Harness, nodeB *Harness) {
|
|||
|
||||
func testConnectNode(r *Harness, t *testing.T) {
|
||||
// Create a fresh test harness.
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil)
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ func testActiveHarnesses(r *Harness, t *testing.T) {
|
|||
numInitialHarnesses := len(ActiveHarnesses())
|
||||
|
||||
// Create a single test harness.
|
||||
harness1, err := New(&chaincfg.SimNetParams, nil, nil)
|
||||
harness1, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ func testJoinMempools(r *Harness, t *testing.T) {
|
|||
// Create a local test harness with only the genesis block. The nodes
|
||||
// will be synced below so the same transaction can be sent to both
|
||||
// nodes without it being an orphan.
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil)
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ func testJoinMempools(r *Harness, t *testing.T) {
|
|||
func testJoinBlocks(r *Harness, t *testing.T) {
|
||||
// Create a second harness with only the genesis block so it is behind
|
||||
// the main harness.
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil)
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ func testGenerateAndSubmitBlockWithCustomCoinbaseOutputs(r *Harness,
|
|||
func testMemWalletReorg(r *Harness, t *testing.T) {
|
||||
// Create a fresh harness, we'll be using the main harness to force a
|
||||
// re-org on this local harness.
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil)
|
||||
harness, err := New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ const (
|
|||
|
||||
func TestMain(m *testing.M) {
|
||||
var err error
|
||||
mainHarness, err = New(&chaincfg.SimNetParams, nil, nil)
|
||||
mainHarness, err = New(&chaincfg.SimNetParams, nil, nil, "")
|
||||
if err != nil {
|
||||
fmt.Println("unable to create main harness: ", err)
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue