Artifact e3a32c8d746fd2d6f7f20c126eb70f320e8a4f6909640d8a69472cb07ab38042:
- File
simio/rand_test.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 889) [annotate] [blame] [check-ins using]
package simio import ( "bytes" "testing" ) func TestCryptoRandReads(t *testing.T) { r := CryptoRand{} buf := make([]byte, 32) n, err := r.Read(buf) if err != nil { t.Fatal(err) } if n != 32 { t.Fatalf("expected 32 bytes, got %d", n) } if bytes.Equal(buf, make([]byte, 32)) { t.Fatal("expected non-zero bytes") } } func TestSeededRandDeterministic(t *testing.T) { r1 := NewSeededRand(42) r2 := NewSeededRand(42) buf1 := make([]byte, 64) buf2 := make([]byte, 64) r1.Read(buf1) r2.Read(buf2) if !bytes.Equal(buf1, buf2) { t.Fatal("same seed should produce identical output") } } func TestSeededRandDifferentSeeds(t *testing.T) { r1 := NewSeededRand(1) r2 := NewSeededRand(2) buf1 := make([]byte, 64) buf2 := make([]byte, 64) r1.Read(buf1) r2.Read(buf2) if bytes.Equal(buf1, buf2) { t.Fatal("different seeds should produce different output") } }