Add share cards

This commit is contained in:
satoshi committed 2026-09-04 00:54:26 +03:00
1 parent ec42ce9b54
commit 4669bf10c0
51 files changed
+1193 -239

No files matched your search

+10 -10
View File
@@ -90,7 +90,7 @@ func setChain(agg *Aggregator, chain string) {
// ---- reconcileOnce tests ----
// TestReconcileOnce_ChainFilter verifies that a block recorded on testnet
// is NOT orphaned when the node is now on mainnet — even if the canonical
// is NOT orphaned when the node is now on mainnet, even if the canonical
// hash at that height on mainnet is different.
func TestReconcileOnce_ChainFilter_NoFalseOrphan(t *testing.T) {
st := openTempStore(t)
@@ -109,7 +109,7 @@ func TestReconcileOnce_ChainFilter_NoFalseOrphan(t *testing.T) {
}
// Mock RPC: getblockhash returns a different mainnet hash; getblock
// for our testnet hash returns "Block not found" — it doesn't exist
// for our testnet hash returns "Block not found", it doesn't exist
// on mainnet at all, confirming it's cross-network not a reorg.
rpc := mockRPC(t, func(method string) (any, *rpcErrResp) {
switch method {
@@ -132,7 +132,7 @@ func TestReconcileOnce_ChainFilter_NoFalseOrphan(t *testing.T) {
}
for _, b := range blocks {
if b.Height == 100 && !b.OrphanedAt.IsZero() {
t.Error("testnet block was falsely orphaned after switching to mainnet — chain filter broken")
t.Error("testnet block was falsely orphaned after switching to mainnet, chain filter broken")
}
}
}
@@ -156,7 +156,7 @@ func TestReconcileOnce_GenuineReorg(t *testing.T) {
}
// getblockhash returns a different canonical hash (reorg happened).
// getblock for our hash SUCCEEDS — the block still exists in bitcoind's
// getblock for our hash SUCCEEDS, the block still exists in bitcoind's
// block store after a reorg, it's just no longer on the active chain.
// This distinguishes a real reorg from a cross-network block.
rpc := mockRPC(t, func(method string) (any, *rpcErrResp) {
@@ -223,7 +223,7 @@ func TestReconcileOnce_RPCError_NoOrphan(t *testing.T) {
blocks, _ := st.Recent(10)
for _, b := range blocks {
if b.Height == 300 && !b.OrphanedAt.IsZero() {
t.Error("block was orphaned on RPC error — should only orphan on definitive hash mismatch")
t.Error("block was orphaned on RPC error, should only orphan on definitive hash mismatch")
}
}
}
@@ -240,7 +240,7 @@ func TestReconcileOnce_LegacyBlock_StillChecked(t *testing.T) {
RewardBT: 3.125,
FoundAt: time.Now(),
Source: "test",
Chain: "", // legacy — no chain recorded
Chain: "", // legacy, no chain recorded
})
// Canonical hash differs AND getblock succeeds (block exists on this
@@ -250,7 +250,7 @@ func TestReconcileOnce_LegacyBlock_StillChecked(t *testing.T) {
case "getblockhash":
return "different_canonical", nil
case "getblock":
// Block exists in this chain's store — genuine reorg
// Block exists in this chain's store, genuine reorg
return map[string]any{"hash": "legacy_hash", "height": 400, "confirmations": -1}, nil
}
return nil, nil
@@ -281,11 +281,11 @@ func TestReconcileOnce_LegacyBlock_CrossNetwork(t *testing.T) {
RewardBT: 50,
FoundAt: time.Now(),
Source: "test",
Chain: "", // legacy — no chain recorded
Chain: "", // legacy, no chain recorded
})
// Canonical hash differs AND getblock fails (block doesn't exist on
// this network at all). Should NOT orphan — should stamp as "other".
// this network at all). Should NOT orphan, should stamp as "other".
rpc := mockRPC(t, func(method string) (any, *rpcErrResp) {
switch method {
case "getblockhash":
@@ -436,6 +436,6 @@ func TestIngestBlockEvents_ChainStamping(t *testing.T) {
t.Fatal("block not found in store")
}
if blocks[0].Chain != "test" {
t.Errorf("Chain = %q, want test — chain stamping broken", blocks[0].Chain)
t.Errorf("Chain = %q, want test, chain stamping broken", blocks[0].Chain)
}
}