diff --git a/operator-and-conversation/go/clients/operatorchannelclient/client.go b/operator-and-conversation/go/clients/operatorchannelclient/client.go index 645e48e..4acd445 100644 --- a/operator-and-conversation/go/clients/operatorchannelclient/client.go +++ b/operator-and-conversation/go/clients/operatorchannelclient/client.go @@ -153,6 +153,10 @@ func (c *Client) Take(w seat.Warrant, act func(seat.Option, seat.Warrant) error) if _, err := c.State.Update(c.key(w.Ask), k, e.Revision); err != nil && !errors.Is(err, stdio.ErrChanged) { return "", err } + if w.Outcome == OutcomeRefused { + // The router never took the ask (design 47 G 570): its asker's request ends with the router's words. + return Refused, fmt.Errorf("the ask %s was refused: %s", w.Ask, w.Words) + } return Recorded, nil } o, err := For(w, c.Module, k.Ask) diff --git a/operator-and-conversation/go/clients/operatorchannelclient/client_test.go b/operator-and-conversation/go/clients/operatorchannelclient/client_test.go index 8798ea5..2007142 100644 --- a/operator-and-conversation/go/clients/operatorchannelclient/client_test.go +++ b/operator-and-conversation/go/clients/operatorchannelclient/client_test.go @@ -140,6 +140,20 @@ func TestAnAskEndedWithoutAChoiceIsRecordedAndNothingDone(t *testing.T) { } } +func TestAnAskTheRouterRefusedEndsTheRequestWithItsWords(t *testing.T) { + c, _ := client() + _ = c.Ask(askedHeld()) + w := askedWarrant() + w.Outcome, w.Option, w.By, w.Words = OutcomeRefused, "", nil, "its expiry passes the bound of its level" + h, err := c.Take(w, func(seat.Option, seat.Warrant) error { t.Fatal("acted"); return nil }) + if h != Refused || err == nil || !strings.Contains(err.Error(), w.Words) { + t.Fatalf("%s %v, want refused with the router's words", h, err) + } + if h, _ := c.Take(askedWarrant(), func(seat.Option, seat.Warrant) error { t.Fatal("acted after it ended"); return nil }); h != Done { + t.Errorf("the refused ask was not closed: %s", h) + } +} + func TestAKeyPrefixIsPutBeforeEveryKeyOfTheClientsOwnStateAndNotBeforeWhere(t *testing.T) { for _, tc := range []struct{ prefix, key string }{{"n1.", "n1.ask.d-1"}, {"", "ask.d-1"}} { c, _ := client()