- Three fuzz targets, in scripts/fuzz.sh too: FuzzDecodeHead (a head that is accepted re-encodes to its input, and a rejection carries one normative code), FuzzEvaluateSecurity (verdicts of this version, X for both or for neither) and FuzzCheckPath (the rules of one entry and the decoder of the head agree on every path). About a million runs each, clean; scripts/check.sh 60s is clean. - Spec v0.10, section 67: the fixtures of format 3 exist, so "Serán ... (por implementar)" reads "Son ...", as for those of format 2. No rule changes. - spec/README.md: v0.10 approved by its author on 30 September 2026 and implemented on this branch, with the SHA-256 of its text; the tag spec-v0.10 waits for the author. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>v0.10
parent
735885cb29
commit
6fa2b54bd3
@ -0,0 +1,39 @@
|
||||
package pathrule_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
|
||||
"g.activething.com/go/DateKeys/internal/pathrule"
|
||||
"g.activething.com/go/DateKeys/internal/testkit"
|
||||
)
|
||||
|
||||
// FuzzCheckPath: the rules of one entry and the decoder of the head agree on
|
||||
// every path: a head that holds it alone decodes exactly when the path is
|
||||
// valid UTF-8 of 1 to 1024 bytes (R1, layer 3) that CheckPath accepts, since
|
||||
// one path collides with none and makes at most 31 folders (spec §29.5).
|
||||
func FuzzCheckPath(f *testing.F) {
|
||||
var paths testkit.PathVectorFile
|
||||
if err := testkit.ReadJSON("../../testdata/vectors/paths.json", &paths); err != nil {
|
||||
f.Fatal(err)
|
||||
}
|
||||
for _, v := range paths.Paths {
|
||||
f.Add(v.Path)
|
||||
}
|
||||
f.Fuzz(func(t *testing.T, p string) {
|
||||
err := pathrule.CheckPath(p)
|
||||
var e *pathrule.Error
|
||||
if err != nil && !errors.As(err, &e) {
|
||||
t.Fatalf("an error that is not a pathrule.Error: %v", err)
|
||||
}
|
||||
valid := err == nil && utf8.ValidString(p) && len(p) >= 1 && len(p) <= pathrule.MaxPathLen
|
||||
head, merr := testkit.TreeHead([]string{p})
|
||||
if merr != nil {
|
||||
return
|
||||
}
|
||||
if got, _ := testkit.HeadResult(head); (got == testkit.ResultOK) != valid {
|
||||
t.Fatalf("path %+q: CheckPath %v, the head decodes to %s", p, err, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Reference in new issue