From beaf4c9c38b9fd08f3055271e99c28cbb470a223 Mon Sep 17 00:00:00 2001 From: youfak Date: Wed, 29 Jul 2026 20:04:09 +0800 Subject: [PATCH] fix: normalize admin config checksums --- internal/domain/adminstate/contracttest/contract.go | 3 ++- internal/domain/adminstate/memory.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/domain/adminstate/contracttest/contract.go b/internal/domain/adminstate/contracttest/contract.go index c00759a..4c401f4 100644 --- a/internal/domain/adminstate/contracttest/contract.go +++ b/internal/domain/adminstate/contracttest/contract.go @@ -36,7 +36,7 @@ func Run(t *testing.T, factory Factory) { func runConfigContract(t *testing.T, store adminstate.Store) { t.Helper() - command := configCommand("req-config", "cfg-1", strings.Repeat("a", adminstate.SHA256HexBytes)) + command := configCommand("req-config", "cfg-1", strings.Repeat("ab", adminstate.SHA256HexBytes/2)) result, err := store.CommitConfig(context.Background(), command) if err != nil || !result.Changed || result.Revision != 1 || result.RequestID != command.RequestID { t.Fatalf("CommitConfig(first) = %+v, %v", result, err) @@ -58,6 +58,7 @@ func runConfigContract(t *testing.T, store adminstate.Store) { command.RequestID = "req-config-replay" command.OccurredAt = command.OccurredAt.Add(time.Second) + command.Checksum = strings.ToUpper(command.Checksum) replayed, err := store.CommitConfig(context.Background(), command) if err != nil || replayed.Changed || replayed.Revision != 1 { t.Fatalf("CommitConfig(replay) = %+v, %v", replayed, err) diff --git a/internal/domain/adminstate/memory.go b/internal/domain/adminstate/memory.go index 5f563e7..4cb581e 100644 --- a/internal/domain/adminstate/memory.go +++ b/internal/domain/adminstate/memory.go @@ -6,6 +6,7 @@ import ( "math" "net/netip" "sort" + "strings" "sync" "time" ) @@ -42,6 +43,7 @@ func (store *MemoryStore) CommitConfig(ctx context.Context, command CommitConfig return result, ErrInvalidCommand } command = cloneCommitConfigCommand(command) + command.Checksum = strings.ToLower(command.Checksum) store.mu.Lock() defer store.mu.Unlock()