mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Name test constants for clarity
This commit is contained in:
parent
73c42232fc
commit
b2c8094643
|
|
@ -28,6 +28,11 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const (
|
||||
FailuresUntilAssumedOffline = 3
|
||||
FailuresUntilBlacklist = 8
|
||||
)
|
||||
|
||||
func (t *testFedClient) QueryKeys(ctx context.Context, origin, s gomatrixserverlib.ServerName, keys map[string][]string) (gomatrixserverlib.RespQueryKeys, error) {
|
||||
t.queryKeysCalled = true
|
||||
if t.shouldFail {
|
||||
|
|
@ -55,7 +60,7 @@ func TestFederationClientQueryKeys(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -86,7 +91,7 @@ func TestFederationClientQueryKeysBlacklisted(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -116,7 +121,7 @@ func TestFederationClientQueryKeysFailure(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{shouldFail: true}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -146,7 +151,7 @@ func TestFederationClientClaimKeys(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -177,7 +182,7 @@ func TestFederationClientClaimKeysBlacklisted(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestPerformWakeupServers(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -102,7 +102,7 @@ func TestQueryRelayServers(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -134,7 +134,7 @@ func TestPerformDirectoryLookup(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
@ -169,7 +169,7 @@ func TestPerformDirectoryLookupRelaying(t *testing.T) {
|
|||
},
|
||||
}
|
||||
fedClient := &testFedClient{}
|
||||
stats := statistics.NewStatistics(testDB, 8, 3)
|
||||
stats := statistics.NewStatistics(testDB, FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
queues := queue.NewOutgoingQueues(
|
||||
testDB, process.NewProcessContext(),
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
FailuresUntilAssumedOffline = 2
|
||||
FailuresUntilBlacklist = 7
|
||||
FailuresUntilAssumedOffline = 3
|
||||
FailuresUntilBlacklist = 8
|
||||
)
|
||||
|
||||
func TestBackoff(t *testing.T) {
|
||||
|
|
@ -106,7 +106,7 @@ func TestBackoff(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRelayServersListing(t *testing.T) {
|
||||
stats := NewStatistics(storage.NewFakeFederationDatabase(), 8, 3)
|
||||
stats := NewStatistics(storage.NewFakeFederationDatabase(), FailuresUntilBlacklist, FailuresUntilAssumedOffline)
|
||||
server := ServerStatistics{statistics: &stats}
|
||||
server.AddRelayServers([]gomatrixserverlib.ServerName{"relay1", "relay1", "relay2"})
|
||||
relayServers := server.KnownRelayServers()
|
||||
|
|
|
|||
Loading…
Reference in a new issue