Files
neural-hunt/internal/core/core_test.go
jbergner 005fd6ca51
Some checks failed
release-tag / release-image (push) Failing after 1m18s
RC-1
2026-08-10 05:48:55 +02:00

30 lines
689 B
Go

package core
import (
"math/big"
"testing"
)
func TestExpectedGuessDeterministic(t *testing.T) {
a := ExpectedGuess("task_x", "seed", "client", 7, 28)
b := ExpectedGuess("task_x", "seed", "client", 7, 28)
if a != b {
t.Fatalf("not deterministic: %s != %s", a, b)
}
n, ok := new(big.Int).SetString(a, 10)
if !ok || n.Sign() < 0 || n.BitLen() > 28 {
t.Fatalf("guess outside range: %s", a)
}
}
func TestScore(t *testing.T) {
if Score(big.NewInt(0), 32) != 100 {
t.Fatal("exact hit must score 100")
}
near := Score(big.NewInt(1), 32)
far := Score(new(big.Int).Lsh(big.NewInt(1), 30), 32)
if near <= far {
t.Fatalf("near score %f should exceed far %f", near, far)
}
}