package gate import ( "os" "os/exec" "path/filepath" "strconv" "testing" ) // TestDaemonFillsFromTheForkNode is the parent-side gate run against the fork's // node and the fork's chain name. The header form, the magic and the profile all // differ from the parent's, so a daemon that fills here fills on both chains. func TestDaemonFillsFromTheForkNode(t *testing.T) { if _, err := exec.LookPath("go"); err != nil { t.Skip("go is not on PATH") } r := forkNodeOn(t) r.createWallet(t) r.mine(t, 20) tip, err := strconv.Atoi(r.must(t, "getblockcount")) if err != nil { t.Fatal(err) } bin := t.TempDir() build := exec.Command("go", "build", "-o", filepath.Join(bin, "btcd-lited"), "./cmd/btcd-lited") build.Dir = "../.." if out, err := build.CombinedOutput(); err != nil { t.Fatalf("build: %v\n%s", err, out) } data := t.TempDir() port := freePort(t) logPath := filepath.Join(data, "instance.log") logFile, err := os.Create(logPath) if err != nil { t.Fatal(err) } defer logFile.Close() cmd := exec.Command(filepath.Join(bin, "btcd-lited"), "-data", data, "-listen", "127.0.0.1:"+itoa(port), "-chain", "xbt", "-chain", "btc", "-peer", "127.0.0.1:"+itoa(r.p2p), "-regtest") cmd.Stdout, cmd.Stderr = logFile, logFile if err := cmd.Start(); err != nil { t.Fatal(err) } defer func() { _ = cmd.Process.Kill() _ = cmd.Wait() }() t.Cleanup(func() { if t.Failed() { logged, _ := os.ReadFile(logPath) t.Logf("instance log:\n%s", logged) } }) waitForBlocks(t, cmd, logPath, "http://127.0.0.1:"+itoa(port), tip+1) }