feat: persist participant-scoped proposal recovery

This commit is contained in:
Josh Creek
2026-09-01 07:50:11 +01:00
parent 1eb6e8f9f4
commit 30b4560bd5
7 changed files with 217 additions and 20 deletions
@@ -0,0 +1,30 @@
package store
import (
"testing"
"time"
)
func TestProposalRecoverySQLBindsParticipantAndExpiresAtReadBoundary(t *testing.T) {
for query, fragments := range map[string][]string{
ProposalExpireSQL: {"state = 'OPEN'", "expires_at <= $2", "revision = revision + 1"},
ProposalParticipantExpireSQL: {"response = 'PENDING'", "response = 'TIMED_OUT'"},
ProposalRecoverySelectSQL: {"proposal_id = $1", "player_id = $2", "EXISTS"},
ProposalParticipantsSelectSQL: {"proposal_id = $1", "ORDER BY player_id"},
} {
for _, fragment := range fragments {
if !contains(query, fragment) {
t.Fatalf("query %q missing %q", query, fragment)
}
}
}
}
func TestProposalRecoveryRejectsMissingAuthorityInputs(t *testing.T) {
if _, err := GetProposal(nil, nil, "player-1", "proposal-1", time.Unix(1000, 0)); err == nil {
t.Fatal("nil database accepted")
}
if _, err := GetProposal(nil, nil, "", "proposal-1", time.Unix(1000, 0)); err == nil {
t.Fatal("empty player accepted")
}
}