The engine's Composed keeps the catalogue's Plan and the declaration types and goes through nodeengineclient's codec; the fingerprint key part is meshcatalogclient's. The candidate answer is nodeengine.CandidateAnswer; the have still holds it through an interim JSON bridge (link.interimAnswers) until the Have group moves. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
27 lines
1.2 KiB
Go
27 lines
1.2 KiB
Go
package judge
|
|
|
|
import (
|
|
nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/delivery"
|
|
)
|
|
|
|
// An answer too large for the node's key is fitted: the texts go first, the verdict and the paths stay, and the answer
|
|
// given is not changed (moved from mesh-sdk's placement test with FitAnswer, novox/hq ADR 0593 §7).
|
|
func TestFitAnswer(t *testing.T) {
|
|
long := strings.Repeat("x", delivery.MaxBody)
|
|
big := CandidateAnswer{Proposal: "p-x1", Revision: 1, Verdict: nodeengine.CandidateAnswerVerdictDiffers, Differs: []ModuleDiffers{{
|
|
Module: "nats", Why: "differs", Bodies: []ResourceBodies{{ID: "conf", Why: "changed",
|
|
Paths: []string{"content.links.1", "content.password"}, Composed: long, Running: long}}}}}
|
|
if same := FitAnswer(big, 1<<20); same.Note != "" || same.Differs[0].Bodies[0].Composed != long {
|
|
t.Errorf("an answer within the bound was cut: %+v", same.Note)
|
|
}
|
|
fitted := FitAnswer(big, 4<<10)
|
|
if len(fitted.Differs[0].Bodies[0].Composed) != 0 || len(fitted.Differs[0].Bodies[0].Paths) != 2 ||
|
|
fitted.Verdict != nodeengine.CandidateAnswerVerdictDiffers || !strings.Contains(fitted.Note, "cut") || big.Differs[0].Bodies[0].Composed == "" {
|
|
t.Errorf("fitted as %+v", fitted)
|
|
}
|
|
}
|