Add comprehensive tests for new policy fields and combinations
Some checks failed
Go / build-and-release (push) Has been cancelled
Some checks failed
Go / build-and-release (push) Has been cancelled
Introduce tests to validate functionality for new policy fields, including `max_expiry_duration`, `protected_required`, `identifier_regex`, and `follows_whitelist_admins`. Also, cover combinations of new and existing fields to ensure compatibility and precedence rules are correctly enforced. bump to v0.31.2
This commit is contained in:
@@ -12,12 +12,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"next.orly.dev/app/config"
|
||||
"next.orly.dev/pkg/database"
|
||||
"git.mleku.dev/mleku/nostr/encoders/event"
|
||||
"git.mleku.dev/mleku/nostr/encoders/tag"
|
||||
"git.mleku.dev/mleku/nostr/interfaces/signer/p8k"
|
||||
"github.com/gorilla/websocket"
|
||||
"next.o
|
||||
"next.orly.dev/pkg/protocol/publish"
|
||||
)
|
||||
|
||||
@@ -50,6 +49,24 @@ func createSignedTestEvent(t *testing.T, kind uint16, content string, tags ...*t
|
||||
*ev.Tags = append(*ev.Tags, tg)
|
||||
}
|
||||
|
||||
// Kind 3 (follow list) events must have at least one p tag
|
||||
// Add a dummy p tag if none provided
|
||||
if kind == 3 {
|
||||
hasPTag := false
|
||||
for _, tg := range tags {
|
||||
if tg != nil && tg.Len() >= 1 && string(tg.Key()) == "p" {
|
||||
hasPTag = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasPTag {
|
||||
// Use the signer's own pubkey as the follow target
|
||||
pubkeyHex := signer.Pub()
|
||||
pTag := tag.NewFromBytesSlice([]byte("p"), pubkeyHex)
|
||||
*ev.Tags = append(*ev.Tags, pTag)
|
||||
}
|
||||
}
|
||||
|
||||
// Sign the event (this sets Pubkey, ID, and Sig)
|
||||
if err := ev.Sign(signer); err != nil {
|
||||
t.Fatalf("Failed to sign event: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user