handshake_test.go raw

   1  package gate
   2  
   3  import (
   4  	"context"
   5  	"testing"
   6  	"time"
   7  
   8  	btcdwire "github.com/btcsuite/btcd/wire/v2"
   9  
  10  	"git.smesh.lol/btcd-lite/internal/litedial"
  11  )
  12  
  13  // TestInstanceHandshakeWithTheNode runs the instance's own dialler against the
  14  // node's p2p port, which is the call the daemon makes on startup.
  15  func TestInstanceHandshakeWithTheNode(t *testing.T) {
  16  	addr := p2pAddr(t)
  17  	start := time.Now()
  18  	p, err := litedial.Connect(context.Background(), addr, "/btcd-lite:0.1.0/",
  19  		btcdwire.BitcoinNet(0xDAB5BFFA), 20*time.Second, true, t.Logf)
  20  	took := time.Since(start).Round(time.Millisecond)
  21  	if err != nil {
  22  		t.Fatalf("instance dial to %s after %s: %v", addr, took, err)
  23  	}
  24  	defer p.Close()
  25  	t.Logf("instance dial to %s completed in %s", addr, took)
  26  }
  27