package iskra import "testing" func TestHashDeterministic(t *testing.T) { data := []byte("func main()") h1 := HashBytes(data) h2 := HashBytes(data) if h1 != h2 { t.Fatal("hash should be deterministic") } } func TestHashDistinct(t *testing.T) { h1 := HashBytes([]byte("func main()")) h2 := HashBytes([]byte("func init()")) if h1 == h2 { t.Fatal("different inputs should produce different hashes") } } func TestHash56Bit(t *testing.T) { h := HashBytes([]byte("anything")) if h>>56 != 0 { t.Fatal("hash should be 56 bits (top 8 bits zero)") } } func TestSegmentKeyStage(t *testing.T) { key := SegmentKey(StageSRC, []byte("test")) if KeyStage(key) != StageSRC { t.Fatal("stage tag not preserved") } key2 := SegmentKey(StageBIN, []byte("test")) if KeyStage(key2) != StageBIN { t.Fatal("stage tag not preserved for BIN") } if KeyHash(key) != KeyHash(key2) { t.Fatal("same content should have same hash regardless of stage") } if key == key2 { t.Fatal("different stages should produce different keys") } }