diff --git a/go.mod b/go.mod index 606399481f..b28a58a6f6 100644 --- a/go.mod +++ b/go.mod @@ -1,20 +1,23 @@ -module github.com/btcsuite/btcd +module github.com/paxosglobal/btcd + +replace github.com/btcsuite/btcd => github.com/paxosglobal/btcd v0.20.1-beta.0.20200206213050-d0903b768de2 require ( github.com/aead/siphash v1.0.1 // indirect + github.com/btcsuite/btcd v0.20.1-beta github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd - github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 // indirect + github.com/btcsuite/snappy-go v1.0.0 // indirect github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 github.com/btcsuite/winsvc v1.0.0 github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495 github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 github.com/jrick/logrotate v1.0.0 - github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect + github.com/kkdai/bstream v1.0.0 // indirect + github.com/onsi/ginkgo v1.12.0 // indirect + github.com/onsi/gomega v1.9.0 // indirect golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 ) diff --git a/go.sum b/go.sum index dc773d4775..e5afbd999d 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JG github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 h1:ZA/jbKoGcVAnER6pCHPEkGdZOV7U1oLUedErBHCUMs0= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0 h1:ZxaA6lo2EpxGddsA8JwWOcxlzRybb444sgmeJQMJGQE= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= @@ -26,13 +26,16 @@ github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QU github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8= +github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= +github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= +github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/paxosglobal/btcd v0.20.1-beta.0.20200206213050-d0903b768de2 h1:4a4D6H5pOMeCQDc1Sh3IRipAINaR6JrIzQFKOat98YI= +github.com/paxosglobal/btcd v0.20.1-beta.0.20200206213050-d0903b768de2/go.mod h1:ZrXZzyoIkjdGNjl5BwA7eFb1qOlqOAhtZJCjDt0cuCY= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44 h1:9lP3x0pW80sDI6t1UMSLA4to18W7R7imwAI/sWS9S8Q= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= @@ -41,13 +44,17 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6Zh golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/integration/bip0009_test.go b/integration/bip0009_test.go index df3721b1e6..7f11a3b9b4 100644 --- a/integration/bip0009_test.go +++ b/integration/bip0009_test.go @@ -133,7 +133,7 @@ func testBIP0009(t *testing.T, forkKey string, deploymentID uint32) { if err != nil { t.Fatalf("unable to create primary harness: %v", err) } - if err := r.SetUp(false, 0); err != nil { + if err := r.SetUp(false, 0, defaultConnRetries); err != nil { t.Fatalf("unable to setup test chain: %v", err) } defer r.TearDown() @@ -324,7 +324,7 @@ func TestBIP0009Mining(t *testing.T) { if err != nil { t.Fatalf("unable to create primary harness: %v", err) } - if err := r.SetUp(true, 0); err != nil { + if err := r.SetUp(true, 0, defaultConnRetries); err != nil { t.Fatalf("unable to setup test chain: %v", err) } defer r.TearDown() diff --git a/integration/csv_fork_test.go b/integration/csv_fork_test.go index 345217c864..b83e72ea77 100644 --- a/integration/csv_fork_test.go +++ b/integration/csv_fork_test.go @@ -113,7 +113,7 @@ func TestBIP0113Activation(t *testing.T) { if err != nil { t.Fatal("unable to create primary harness: ", err) } - if err := r.SetUp(true, 1); err != nil { + if err := r.SetUp(true, 1, defaultConnRetries); err != nil { t.Fatalf("unable to setup test chain: %v", err) } defer r.TearDown() @@ -409,7 +409,7 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) { if err != nil { t.Fatal("unable to create primary harness: ", err) } - if err := r.SetUp(true, 1); err != nil { + if err := r.SetUp(true, 1, defaultConnRetries); err != nil { t.Fatalf("unable to setup test chain: %v", err) } defer r.TearDown() diff --git a/integration/rpcserver_test.go b/integration/rpcserver_test.go index df526442be..a51ccda0e5 100644 --- a/integration/rpcserver_test.go +++ b/integration/rpcserver_test.go @@ -118,7 +118,7 @@ func TestMain(m *testing.M) { // Initialize the primary mining node with a chain of length 125, // providing 25 mature coinbases to allow spending from for testing // purposes. - if err := primaryHarness.SetUp(true, 25); err != nil { + if err := primaryHarness.SetUp(true, 25, defaultConnRetries); err != nil { fmt.Println("unable to setup test chain: ", err) // Even though the harness was not fully setup, it still needs diff --git a/integration/rpctest/node.go b/integration/rpctest/node.go index 6aec2b1168..0b21ba3cfa 100644 --- a/integration/rpctest/node.go +++ b/integration/rpctest/node.go @@ -150,6 +150,7 @@ func (n *nodeConfig) rpcConnConfig() rpc.ConnConfig { Pass: n.rpcPass, Certificates: n.certificates, DisableAutoReconnect: true, + DisableTLS: true, } } @@ -201,9 +202,15 @@ func newNode(config *nodeConfig, dataDir string) (*node, error) { // test case, or panic, it is important that the process be stopped via stop(), // otherwise, it will persist unless explicitly killed. func (n *node) start() error { + fmt.Println("starting rpc node") if err := n.cmd.Start(); err != nil { return err } + foundP, err := os.FindProcess(n.cmd.Process.Pid) + if err != nil { + return err + } + fmt.Println("found p", foundP) pid, err := os.Create(filepath.Join(n.dataDir, fmt.Sprintf("%s.pid", n.config))) @@ -220,6 +227,8 @@ func (n *node) start() error { return err } + fmt.Println("created pid file", n.cmd.Process.Pid, filepath.Join(n.dataDir, + fmt.Sprintf("%s.pid", n.config))) return nil } @@ -236,6 +245,7 @@ func (n *node) stop() error { if runtime.GOOS == "windows" { return n.cmd.Process.Signal(os.Kill) } + fmt.Println("signalling to interrupt the process") return n.cmd.Process.Signal(os.Interrupt) } @@ -245,6 +255,7 @@ func (n *node) stop() error { func (n *node) cleanup() error { if n.pidFile != "" { if err := os.Remove(n.pidFile); err != nil { + fmt.Printf("unable to remove pid file %s %v\n", n.pidFile, err) log.Printf("unable to remove file %s: %v", n.pidFile, err) } diff --git a/integration/rpctest/rpc_harness.go b/integration/rpctest/rpc_harness.go index 1c2612e47b..f88258469f 100644 --- a/integration/rpctest/rpc_harness.go +++ b/integration/rpctest/rpc_harness.go @@ -34,6 +34,8 @@ const ( // BlockVersion is the default block version used when generating // blocks. BlockVersion = 4 + + defaultConnRetries = 20 ) var ( @@ -213,13 +215,14 @@ func New(activeNet *chaincfg.Params, handlers *rpcclient.NotificationHandlers, // // NOTE: This method and TearDown should always be called from the same // goroutine as they are not concurrent safe. -func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error { +func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32, connRetries int) error { // Start the btcd node itself. This spawns a new process which will be // managed if err := h.node.start(); err != nil { return err } - if err := h.connectRPCClient(); err != nil { + if err := h.connectRPCClient(connRetries); err != nil { + fmt.Println("process state", h.node.cmd.ProcessState.String()) return err } @@ -272,6 +275,7 @@ func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error { // // This function MUST be called with the harness state mutex held (for writes). func (h *Harness) tearDown() error { + fmt.Println("tearing down rpc node") if h.Node != nil { h.Node.Shutdown() } @@ -307,14 +311,15 @@ func (h *Harness) TearDown() error { // the time between subsequent attempts. If after h.maxConnRetries attempts, // we're not able to establish a connection, this function returns with an // error. -func (h *Harness) connectRPCClient() error { +func (h *Harness) connectRPCClient(connRetries int) error { var client *rpcclient.Client var err error rpcConf := h.node.config.rpcConnConfig() - for i := 0; i < h.maxConnRetries; i++ { + for i := 0; i < connRetries; i++ { if client, err = rpcclient.New(&rpcConf, h.handlers); err != nil { time.Sleep(time.Duration(i) * 50 * time.Millisecond) + fmt.Println("error connecting via RPC", err.Error()) continue } break @@ -489,6 +494,7 @@ func generateListeningAddresses() (string, string) { p2p := net.JoinHostPort(localhost, portString(minPeerPort, maxPeerPort)) rpc := net.JoinHostPort(localhost, portString(minRPCPort, maxRPCPort)) + fmt.Println("using ports", p2p, rpc, processID) return p2p, rpc } diff --git a/integration/rpctest/rpc_harness_test.go b/integration/rpctest/rpc_harness_test.go index 717f8f45af..2720d5be80 100644 --- a/integration/rpctest/rpc_harness_test.go +++ b/integration/rpctest/rpc_harness_test.go @@ -109,7 +109,7 @@ func testConnectNode(r *Harness, t *testing.T) { if err != nil { t.Fatal(err) } - if err := harness.SetUp(false, 0); err != nil { + if err := harness.SetUp(false, 0, defaultConnRetries); err != nil { t.Fatalf("unable to complete rpctest setup: %v", err) } defer harness.TearDown() @@ -185,7 +185,7 @@ func testJoinMempools(r *Harness, t *testing.T) { if err != nil { t.Fatal(err) } - if err := harness.SetUp(false, 0); err != nil { + if err := harness.SetUp(false, 0, defaultConnRetries); err != nil { t.Fatalf("unable to complete rpctest setup: %v", err) } defer harness.TearDown() @@ -285,7 +285,7 @@ func testJoinBlocks(r *Harness, t *testing.T) { if err != nil { t.Fatal(err) } - if err := harness.SetUp(false, 0); err != nil { + if err := harness.SetUp(false, 0, defaultConnRetries); err != nil { t.Fatalf("unable to complete rpctest setup: %v", err) } defer harness.TearDown() @@ -473,7 +473,7 @@ func testMemWalletReorg(r *Harness, t *testing.T) { if err != nil { t.Fatal(err) } - if err := harness.SetUp(true, 5); err != nil { + if err := harness.SetUp(true, 5, defaultConnRetries); err != nil { t.Fatalf("unable to complete rpctest setup: %v", err) } defer harness.TearDown() @@ -575,7 +575,7 @@ func TestMain(m *testing.M) { // Initialize the main mining node with a chain of length 125, // providing 25 mature coinbases to allow spending from for testing // purposes. - if err = mainHarness.SetUp(true, numMatureOutputs); err != nil { + if err = mainHarness.SetUp(true, numMatureOutputs, defaultConnRetries); err != nil { fmt.Println("unable to setup test chain: ", err) // Even though the harness was not fully setup, it still needs diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index 7a8f1885d1..5c37242d83 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -1262,6 +1262,7 @@ func New(config *ConnConfig, ntfnHandlers *NotificationHandlers) (*Client, error var err error httpClient, err = newHTTPClient(config) if err != nil { + fmt.Println("unable to connect http", err.Error()) return nil, err } } else { @@ -1269,6 +1270,7 @@ func New(config *ConnConfig, ntfnHandlers *NotificationHandlers) (*Client, error var err error wsConn, err = dial(config) if err != nil { + fmt.Println("unable to connect ws", err.Error()) return nil, err } start = true @@ -1294,6 +1296,7 @@ func New(config *ConnConfig, ntfnHandlers *NotificationHandlers) (*Client, error log.Infof("Established connection to RPC server %s", config.Host) close(connEstablished) + fmt.Println("starting ws client") client.start() if !client.config.HTTPPostMode && !client.config.DisableAutoReconnect { client.wg.Add(1)