Remove subscription_stability_test.go and improve test variable naming
Some checks failed
Go / build-and-release (push) Has been cancelled
Some checks failed
Go / build-and-release (push) Has been cancelled
Deleted `subscription_stability_test.go` to clean up unused or redundant code. Updated naming in test files for improved readability, replacing `tag` with `tg` for consistency. Also updated the `github.com/klauspost/compress` dependency to v1.18.2.
This commit is contained in:
@@ -36,12 +36,12 @@ func TestKind3TagRoundTrip(t *testing.T) {
|
||||
|
||||
// Verify all tags have key "p"
|
||||
pTagCount := 0
|
||||
for _, tag := range *ev1.Tags {
|
||||
for _, tg := range *ev1.Tags {
|
||||
if tag != nil && tag.Len() >= 2 {
|
||||
key := tag.Key()
|
||||
key := tg.Key()
|
||||
if len(key) == 1 && key[0] == 'p' {
|
||||
pTagCount++
|
||||
t.Logf("Found p tag with value length: %d bytes", len(tag.Value()))
|
||||
t.Logf("Found p tag with value length: %d bytes", len(tg.Value()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,12 +62,12 @@ func TestKind3TagRoundTrip(t *testing.T) {
|
||||
|
||||
// Verify all tags still have key "p"
|
||||
pTagCount2 := 0
|
||||
for _, tag := range *ev2.Tags {
|
||||
for _, tg := range *ev2.Tags {
|
||||
if tag != nil && tag.Len() >= 2 {
|
||||
key := tag.Key()
|
||||
key := tg.Key()
|
||||
if len(key) == 1 && key[0] == 'p' {
|
||||
pTagCount2++
|
||||
t.Logf("Found p tag after round-trip with value length: %d bytes", len(tag.Value()))
|
||||
t.Logf("Found p tag after round-trip with value length: %d bytes", len(tg.Value()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,8 +581,8 @@ func TestQueryEventsByTag(t *testing.T) {
|
||||
for _, ev := range events {
|
||||
if ev.Tags != nil && ev.Tags.Len() > 0 {
|
||||
// Find a tag with at least 2 elements and first element of length 1
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTagEvent = ev
|
||||
break
|
||||
}
|
||||
@@ -600,9 +600,9 @@ func TestQueryEventsByTag(t *testing.T) {
|
||||
|
||||
// Get the first tag with at least 2 elements and first element of length 1
|
||||
var testTag *tag.T
|
||||
for _, tag := range *testTagEvent.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
testTag = tag
|
||||
for _, tg := range *testTagEvent.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTag = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -627,10 +627,10 @@ func TestQueryEventsByTag(t *testing.T) {
|
||||
// Verify all events have the tag
|
||||
for i, ev := range evs {
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
if utils.FastEqual(tag.Key(), testTag.Key()) &&
|
||||
utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(tg.Key(), testTag.Key()) &&
|
||||
utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ func TestQueryForAuthorsTags(t *testing.T) {
|
||||
if ev.Tags != nil && ev.Tags.Len() > 0 {
|
||||
// Find a tag with at least 2 elements and the first element of
|
||||
// length 1
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testEvent = ev
|
||||
break
|
||||
}
|
||||
@@ -115,9 +115,9 @@ func TestQueryForAuthorsTags(t *testing.T) {
|
||||
|
||||
// Get the first tag with at least 2 elements and first element of length 1
|
||||
var testTag *tag.T
|
||||
for _, tag := range *testEvent.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
testTag = tag
|
||||
for _, tg := range *testEvent.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTag = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -163,11 +163,11 @@ func TestQueryForAuthorsTags(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ func TestQueryForIds(t *testing.T) {
|
||||
for _, ev := range events {
|
||||
if ev.Tags != nil && ev.Tags.Len() > 0 {
|
||||
// Find a tag with at least 2 elements and first element of length 1
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testEvent = ev
|
||||
break
|
||||
}
|
||||
@@ -187,9 +187,9 @@ func TestQueryForIds(t *testing.T) {
|
||||
if testEvent != nil {
|
||||
// Get the first tag with at least 2 elements and first element of length 1
|
||||
var testTag *tag.T
|
||||
for _, tag := range *testEvent.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
testTag = tag
|
||||
for _, tg := range *testEvent.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTag = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -221,11 +221,11 @@ func TestQueryForIds(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
@@ -325,11 +325,11 @@ func TestQueryForIds(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
@@ -393,11 +393,11 @@ func TestQueryForIds(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
@@ -454,11 +454,11 @@ func TestQueryForIds(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ func TestQueryForKindsAuthorsTags(t *testing.T) {
|
||||
for _, ev := range events {
|
||||
if ev.Tags != nil && ev.Tags.Len() > 0 {
|
||||
// Find a tag with at least 2 elements and first element of length 1
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testEvent = ev
|
||||
break
|
||||
}
|
||||
@@ -115,9 +115,9 @@ func TestQueryForKindsAuthorsTags(t *testing.T) {
|
||||
|
||||
// Get the first tag with at least 2 elements and first element of length 1
|
||||
var testTag *tag.T
|
||||
for _, tag := range *testEvent.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
testTag = tag
|
||||
for _, tg := range *testEvent.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTag = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -174,11 +174,11 @@ func TestQueryForKindsAuthorsTags(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ func TestQueryForKindsTags(t *testing.T) {
|
||||
for _, ev := range events {
|
||||
if ev.Tags != nil && ev.Tags.Len() > 0 {
|
||||
// Find a tag with at least 2 elements and first element of length 1
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testEvent = ev
|
||||
break
|
||||
}
|
||||
@@ -115,9 +115,9 @@ func TestQueryForKindsTags(t *testing.T) {
|
||||
|
||||
// Get the first tag with at least 2 elements and first element of length 1
|
||||
var testTag *tag.T
|
||||
for _, tag := range *testEvent.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
testTag = tag
|
||||
for _, tg := range *testEvent.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTag = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -163,11 +163,11 @@ func TestQueryForKindsTags(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ func TestQueryForTags(t *testing.T) {
|
||||
for _, ev := range events {
|
||||
if ev.Tags != nil && ev.Tags.Len() > 0 {
|
||||
// Find a tag with at least 2 elements and first element of length 1
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testEvent = ev
|
||||
break
|
||||
}
|
||||
@@ -110,9 +110,9 @@ func TestQueryForTags(t *testing.T) {
|
||||
|
||||
// Get the first tag with at least 2 elements and first element of length 1
|
||||
var testTag *tag.T
|
||||
for _, tag := range *testEvent.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
testTag = tag
|
||||
for _, tg := range *testEvent.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
testTag = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -147,11 +147,11 @@ func TestQueryForTags(t *testing.T) {
|
||||
|
||||
// Check if the event has the tag we're looking for
|
||||
var hasTag bool
|
||||
for _, tag := range *ev.Tags {
|
||||
if tag.Len() >= 2 && len(tag.Key()) == 1 {
|
||||
for _, tg := range *ev.Tags {
|
||||
if tg.Len() >= 2 && len(tg.Key()) == 1 {
|
||||
if utils.FastEqual(
|
||||
tag.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tag.Value(), testTag.Value()) {
|
||||
tg.Key(), testTag.Key(),
|
||||
) && utils.FastEqual(tg.Value(), testTag.Value()) {
|
||||
hasTag = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -896,7 +896,7 @@ func TestFollowsWhitelistAdminsWithWriteAllow(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Generate if needed
|
||||
if tt.signer.Pub() == nil {
|
||||
tt.signer.Generate()
|
||||
_ = tt.signer.Generate()
|
||||
}
|
||||
|
||||
ev := createTestEventForNewFields(t, tt.signer, "test", 1)
|
||||
|
||||
@@ -87,7 +87,7 @@ type Rule struct {
|
||||
ReadDeny []string `json:"read_deny,omitempty"`
|
||||
// MaxExpiry is the maximum expiry time in seconds for events written to the relay. If 0, there is no maximum expiry. Events must have an expiry time if this is set, and it must be no more than this value in the future compared to the event's created_at time.
|
||||
// Deprecated: Use MaxExpiryDuration instead for human-readable duration strings.
|
||||
MaxExpiry *int64 `json:"max_expiry,omitempty"`
|
||||
MaxExpiry *int64 `json:"max_expiry,omitempty"` //nolint:staticcheck // Intentional backward compatibility
|
||||
// MaxExpiryDuration is the maximum expiry time in ISO-8601 duration format.
|
||||
// Format: P[n]Y[n]M[n]W[n]DT[n]H[n]M[n]S (e.g., "P7D" for 7 days, "PT1H" for 1 hour, "P1DT12H" for 1 day 12 hours).
|
||||
// Parsed into maxExpirySeconds at load time.
|
||||
@@ -152,7 +152,7 @@ func (r *Rule) hasAnyRules() bool {
|
||||
len(r.readAllowBin) > 0 || len(r.readDenyBin) > 0 ||
|
||||
r.SizeLimit != nil || r.ContentLimit != nil ||
|
||||
r.MaxAgeOfEvent != nil || r.MaxAgeEventInFuture != nil ||
|
||||
r.MaxExpiry != nil || r.MaxExpiryDuration != "" || r.maxExpirySeconds != nil ||
|
||||
r.MaxExpiry != nil || r.MaxExpiryDuration != "" || r.maxExpirySeconds != nil || //nolint:staticcheck // Backward compat
|
||||
len(r.MustHaveTags) > 0 ||
|
||||
r.Script != "" || r.Privileged ||
|
||||
r.WriteAllowFollows || len(r.FollowsWhitelistAdmins) > 0 ||
|
||||
@@ -226,9 +226,9 @@ func (r *Rule) populateBinaryCache() error {
|
||||
} else {
|
||||
r.maxExpirySeconds = &seconds
|
||||
}
|
||||
} else if r.MaxExpiry != nil {
|
||||
} else if r.MaxExpiry != nil { //nolint:staticcheck // Backward compatibility
|
||||
// Fall back to MaxExpiry (raw seconds) if MaxExpiryDuration not set
|
||||
r.maxExpirySeconds = r.MaxExpiry
|
||||
r.maxExpirySeconds = r.MaxExpiry //nolint:staticcheck // Backward compatibility
|
||||
}
|
||||
|
||||
// Compile IdentifierRegex pattern
|
||||
@@ -956,7 +956,7 @@ func (sr *ScriptRunner) readResponses() {
|
||||
}
|
||||
|
||||
// logOutput logs the output from stderr
|
||||
func (sr *ScriptRunner) logOutput(stdout, stderr io.ReadCloser) {
|
||||
func (sr *ScriptRunner) logOutput(_ /* stdout */, stderr io.ReadCloser) {
|
||||
defer stderr.Close()
|
||||
|
||||
// Only log stderr, stdout is used by readResponses
|
||||
|
||||
Reference in New Issue
Block a user