Migrate NPC registry durable contract

This commit is contained in:
2026-08-05 18:25:04 +00:00
parent 916a32195b
commit 9653e06297
56 changed files with 256 additions and 237 deletions

View File

@@ -43,13 +43,13 @@ func TestValidatorContractAndRegistration(t *testing.T) {
func TestValidatorDefersShapeAndRejectsIdentityIssues(t *testing.T) {
validator := New(Options{})
shapeInvalid := dnd.NPCList{NPCs: []dnd.NPC{{Name: "missing evidence"}}}
shapeInvalid := dnd.NPCRegistry{NPCs: []dnd.NPC{{Name: "missing evidence"}}}
result, err := validator.Validate(context.Background(), validationRequest(shapeInvalid))
if err != nil || !result.Approved {
t.Fatalf("shape-invalid result = %#v, error = %v, want deferred approval", result, err)
}
value := validNPCList(2)
value := validNPCRegistry(2)
value.NPCs[0].ID = "not-an-id"
value.NPCs[1].Name = value.NPCs[0].Name
value.NPCs[1].ID = value.NPCs[0].ID
@@ -65,7 +65,7 @@ func TestValidatorDefersShapeAndRejectsIdentityIssues(t *testing.T) {
}
func TestValidatorBoundsUnicodeDiagnostics(t *testing.T) {
value := validNPCList(30)
value := validNPCRegistry(30)
for index := range value.NPCs {
value.NPCs[index].ID = fmt.Sprintf("bad-%d", index)
value.NPCs[index].Name = strings.Repeat("火", 140) + fmt.Sprintf("-%d", index)
@@ -82,12 +82,12 @@ func TestValidatorBoundsUnicodeDiagnostics(t *testing.T) {
}
}
func validationRequest(value dnd.NPCList) contracts.TypedValidationRequest[dnd.NPCList] {
return contracts.TypedValidationRequest[dnd.NPCList]{Value: value}
func validationRequest(value dnd.NPCRegistry) contracts.TypedValidationRequest[dnd.NPCRegistry] {
return contracts.TypedValidationRequest[dnd.NPCRegistry]{Value: value}
}
func validNPCList(count int) dnd.NPCList {
value := dnd.NPCList{NPCs: make([]dnd.NPC, count)}
func validNPCRegistry(count int) dnd.NPCRegistry {
value := dnd.NPCRegistry{NPCs: make([]dnd.NPC, count)}
for index := range value.NPCs {
name := fmt.Sprintf("NPC %d", index)
value.NPCs[index] = dnd.NPC{ID: "npc:sha256:0000000000000000000000000000000000000000000000000000000000000000", Name: name, SourceRefs: []source.SourceRef{sourceRefForTest()}}