package chains_test import ( "testing" btcdwire "github.com/btcsuite/btcd/wire/v2" "git.smesh.lol/btcd-lite/internal/chains" ) // TestWireMagic: a profile carries the magic as the four bytes on the wire and // btcd's BitcoinNet is those bytes read little-endian. Mainnet is f9beb4d9 on // the wire and d9b4bef9 in btcd's type, and passing the first where the second // belongs writes a magic no node recognises, which reads as a peer that accepts // TCP and then says nothing. func TestWireMagic(t *testing.T) { btc, err := chains.ParentChain() if err != nil { t.Fatal(err) } if got := btc.WireMagic(); got != btcdwire.MainNet { t.Fatalf("btc wire magic is %#08x, btcd's mainnet is %#08x", uint32(got), uint32(btcdwire.MainNet)) } xbt, err := chains.ForkChain() if err != nil { t.Fatal(err) } if xbt.WireMagic() != btcdwire.MainNet { t.Fatalf("the fork's wire magic is %#08x; the fork reuses the magic", uint32(xbt.WireMagic())) } rt := chains.Regtest() if got := uint32(rt.Exported.Magic); got != 0xdab5bffa { t.Fatalf("regtest's exported magic is %#08x", got) } if got := uint32(rt.WireMagic()); got != 0xdab5bffa { t.Fatalf("regtest's wire magic is %#08x, the node accepts 0xdab5bffa", got) } if got := uint32(rt.Profile.Magic); got != 0xfabfb5da { t.Fatalf("regtest's profile magic is %#08x, the wire order is 0xfabfb5da", got) } }