package litedial import ( "context" "net" "os" "testing" "time" btcdwire "github.com/btcsuite/btcd/wire/v2" ) // TestConnectToTheRig dials the node on this machine went it is up. It is the // instance's dial, run from a test binary. func TestConnectToTheRig(t *testing.T) { addr := os.Getenv("BTCD_LITE_TEST_PEER") if addr == "" { addr = "127.0.0.1:18444" } nc, err := net.DialTimeout("tcp", addr, time.Second) if err != nil { t.Skipf("no node at %s", addr) } _ = nc.Close() start := time.Now() p, err := Connect(context.Background(), addr, "/btcd-lite:0.1.0/", btcdwire.BitcoinNet(0xDAB5BFFA), 20*time.Second, true, t.Logf) if err != nil { t.Fatalf("connect after %s: %v", time.Since(start).Round(time.Millisecond), err) } defer p.Close() t.Logf("connected in %s", time.Since(start).Round(time.Millisecond)) }