feat: apply durable event acknowledgements

This commit is contained in:
2026-09-06 09:40:47 +00:00
parent ebbbcb6aff
commit ca26d35632
3 changed files with 56 additions and 0 deletions
+21
View File
@@ -118,6 +118,17 @@ func TestSendCommandEventCanonicalDigest_HP_EVENT_02(t *testing.T) {
}
}
func TestApplyEventAckValidatesAndReleasesPrefix_HP_EVENT_03(t *testing.T) {
store := &ackStore{}
ack := &rvboxv1.EventAck{IssueUuid: "019c46f1-1d02-7000-8000-000000000066", ThroughEventSeq: 4}
if err := ApplyEventAck(context.Background(), store, ack); err != nil || store.issue.String() != ack.IssueUuid || store.sequence != 4 {
t.Fatalf("ApplyEventAck = issue=%s sequence=%d err=%v", store.issue, store.sequence, err)
}
if err := ApplyEventAck(context.Background(), store, &rvboxv1.EventAck{IssueUuid: "bad", ThroughEventSeq: 1}); !errors.Is(err, ErrInvalidEventAck) {
t.Fatalf("invalid ack error = %v", err)
}
}
type fakeTransport struct {
written []byte
read []byte
@@ -130,6 +141,16 @@ func (store *reconcileStore) DiscardTerminal(_ context.Context, issue domain.UUI
return nil
}
type ackStore struct {
issue domain.UUID
sequence uint64
}
func (store *ackStore) Ack(_ context.Context, issue domain.UUID, sequence uint64) error {
store.issue, store.sequence = issue, sequence
return nil
}
func (transport *fakeTransport) Write(_ context.Context, value []byte) error {
transport.written = append([]byte(nil), value...)
return nil