package utxobuild_test import ( "testing" "git.smesh.lol/nostrino/pkg/crypto/chainhash" "git.smesh.lol/btcd-lite/internal/utxo" utxostore "git.smesh.lol/btcd-lite/internal/utxo/store" "git.smesh.lol/btcd-lite/internal/wire" ) // TestWalkTouchesPerCheckpoint compares the two things the builder could get // wrong on its own: the touches it collects for a range, and the name of the // checkpoint it writes. It walks the fixture's bodies itself and prints, per // range, the touch count and the walk's name, so the builder's log line can be // put beside it. func TestWalkTouchesPerCheckpoint(t *testing.T) { bodies, _ := chainOfBodies(40) var set []utxo.Entry var touches []utxo.Touch from := uint32(0) for h := uint32(0); h < 40; h++ { b, err := wire.ParseBlock(bodies[h]) if err != nil { t.Fatalf("body %d: %v", h, err) } lookup := utxo.Lookup(func(op wire.OutPoint) (utxo.Entry, bool) { return utxo.Find(set, op) }) ts, err := utxo.BlockTouches(b, h, lookup) if err != nil { t.Fatalf("body %d touches: %v", h, err) } touches = append(touches, ts...) set, err = utxo.ApplyRange(set, ts) if err != nil { t.Fatalf("body %d apply: %v", h, err) } if (h+1)%10 != 0 { continue } t.Logf("range %d..%d: %d touches, %d entries, walk %s", from, h+1, len(touches), len(set), utxostore.NameOf(set)) from, touches = h+1, nil } _ = chainhash.Hash{} }