Copy the kept call's ask id from its request header into the call's _meta as mesh/ask
Every tool call and seat verb the tool runner serves hands the bundle the ask id the kept call set in the header x-ask (stdio.AskHeader) under _meta mesh/ask (stdio.MetaAsk), beside mesh/call; a call whose header carries none names none. Builds: design 47 H2 §775, H-A-351
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/approval"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
"github.com/novox/mesh-tools/node-tools/internal/bus"
|
||||
@@ -20,6 +21,7 @@ import (
|
||||
type saidCaller struct {
|
||||
Caller string `json:"caller"`
|
||||
Call string `json:"call"`
|
||||
Ask *string `json:"ask"`
|
||||
Arguments map[string]any `json:"arguments"`
|
||||
}
|
||||
|
||||
@@ -65,7 +67,39 @@ func TestACallOnTheCallerNamedSubjectReachesTheModuleWithItsCaller(t *testing.T)
|
||||
if got.Arguments["caller"] != "novox.node-tools" {
|
||||
t.Errorf("%s: the arguments did not reach the module as sent: %v", key, got.Arguments)
|
||||
}
|
||||
// A call that carries no ask id in its header names none in `_meta` (design 47 H2 §775, H-A-351).
|
||||
if got.Ask != nil {
|
||||
t.Errorf("%s reached the module with ask %q, want none for a call whose header carries none", key, *got.Ask)
|
||||
}
|
||||
}
|
||||
// **The ask id a kept call sets in its request header is copied into the call's `_meta` as mesh/ask** (design 47 H2 §775,
|
||||
// H-A-351), for a module's tool and for a seat's verb.
|
||||
url := mt.URL(t)
|
||||
t.Run("TheAskIdOfTheHeaderReachesTheModule", func(t *testing.T) {
|
||||
raw, err := nats.Connect(url)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer raw.Close()
|
||||
for _, subject := range []string{"mesh.mod.ledger.tool.who", "mesh.seat.node-desk.tool.who.anchor"} {
|
||||
msg := nats.NewMsg(subject)
|
||||
msg.Header.Set(stdio.AskHeader, "ask-7f3a")
|
||||
msg.Data = []byte(`{}`)
|
||||
var reply struct {
|
||||
Result saidCaller `json:"result"`
|
||||
}
|
||||
mt.Until(t, func() error {
|
||||
answer, err := raw.RequestMsg(msg, 5*time.Second)
|
||||
if err == nil {
|
||||
err = json.Unmarshal(answer.Data, &reply)
|
||||
}
|
||||
return err
|
||||
})
|
||||
if reply.Result.Ask == nil || *reply.Result.Ask != "ask-7f3a" {
|
||||
t.Errorf("%s reached the module with ask %v, want the header's ask-7f3a under mesh/ask", subject, reply.Result.Ask)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// deskDefined is the seat list's definition of the fixture seat node-desk, its verb who.
|
||||
|
||||
Reference in New Issue
Block a user