xbt_test.go raw

   1  package utxobuild_test
   2  
   3  import (
   4  	"os"
   5  	"testing"
   6  
   7  	"git.smesh.lol/btcd-lite/internal/utxobuild"
   8  )
   9  
  10  // TestBuildOverTheForkBodies builds a checkpoint chain over the fork node's own
  11  // bodies, which the fork gate captures when it runs. The fork's headers are a
  12  // different size from Bitcoin's, so a parser that assumes either form fails
  13  // here and nowhere else.
  14  func TestBuildOverTheForkBodies(t *testing.T) {
  15  	src := bodies{}
  16  	for h := uint32(0); ; h++ {
  17  		raw, err := os.ReadFile(testdataPath("xbt", h))
  18  		if err != nil {
  19  			if h == 0 {
  20  				t.Skip("no captured fork bodies")
  21  			}
  22  			break
  23  		}
  24  		src[h] = mustDecodeHex(t, raw)
  25  	}
  26  	dir := t.TempDir()
  27  	_, err := utxobuild.Build(utxobuild.Config{Dir: dir, Interval: 20, From: 0, To: uint32(len(src)), Blocks: src, Logf: t.Logf})
  28  	if err != nil {
  29  		t.Fatalf("build over the fork's bodies: %v", err)
  30  	}
  31  }
  32