mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +00:00
Add vet linter (#240)
This commit is contained in:
parent
4d05492f43
commit
b72142ace5
@ -10,6 +10,7 @@
|
||||
"ineffassign",
|
||||
"gas",
|
||||
"misspell",
|
||||
"errcheck"
|
||||
"errcheck",
|
||||
"vet"
|
||||
]
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
"gas",
|
||||
"misspell",
|
||||
"unparam",
|
||||
"errcheck"
|
||||
"errcheck",
|
||||
"vet"
|
||||
]
|
||||
}
|
||||
|
@ -163,12 +163,12 @@ func createRoom(req *http.Request, device *authtypes.Device,
|
||||
{"m.room.member", userID, membershipContent},
|
||||
{"m.room.power_levels", "", common.InitialPowerLevelsContent(userID)},
|
||||
// TODO: m.room.canonical_alias
|
||||
{"m.room.join_rules", "", common.JoinRulesContent{"public"}}, // FIXME: Allow this to be changed
|
||||
{"m.room.history_visibility", "", common.HistoryVisibilityContent{"joined"}}, // FIXME: Allow this to be changed
|
||||
{"m.room.guest_access", "", common.GuestAccessContent{"can_join"}}, // FIXME: Allow this to be changed
|
||||
{"m.room.join_rules", "", common.JoinRulesContent{JoinRule: "public"}}, // FIXME: Allow this to be changed
|
||||
{"m.room.history_visibility", "", common.HistoryVisibilityContent{HistoryVisibility: "joined"}}, // FIXME: Allow this to be changed
|
||||
{"m.room.guest_access", "", common.GuestAccessContent{GuestAccess: "can_join"}}, // FIXME: Allow this to be changed
|
||||
// TODO: Other initial state items
|
||||
{"m.room.name", "", common.NameContent{r.Name}}, // FIXME: Only send the name event if a name is supplied, to avoid sending a false room name removal event
|
||||
{"m.room.topic", "", common.TopicContent{r.Topic}},
|
||||
{"m.room.name", "", common.NameContent{Name: r.Name}}, // FIXME: Only send the name event if a name is supplied, to avoid sending a false room name removal event
|
||||
{"m.room.topic", "", common.TopicContent{Topic: r.Topic}},
|
||||
// TODO: invite events
|
||||
// TODO: 3pid invite events
|
||||
// TODO: m.room.aliases
|
||||
|
@ -67,7 +67,7 @@ func main() {
|
||||
keyRing := gomatrixserverlib.KeyRing{
|
||||
KeyFetchers: []gomatrixserverlib.KeyFetcher{
|
||||
// TODO: Use perspective key fetchers for production.
|
||||
&gomatrixserverlib.DirectKeyFetcher{federation.Client},
|
||||
&gomatrixserverlib.DirectKeyFetcher{Client: federation.Client},
|
||||
},
|
||||
KeyDatabase: keyDB,
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ func fingerprintPEM(data []byte) *gomatrixserverlib.TLSFingerprint {
|
||||
}
|
||||
if certDERBlock.Type == "CERTIFICATE" {
|
||||
digest := sha256.Sum256(certDERBlock.Bytes)
|
||||
return &gomatrixserverlib.TLSFingerprint{digest[:]}
|
||||
return &gomatrixserverlib.TLSFingerprint{SHA256: digest[:]}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,8 @@ func (s *serverKeyStatements) bulkSelectServerKeys(
|
||||
return nil, err
|
||||
}
|
||||
r := gomatrixserverlib.PublicKeyRequest{
|
||||
gomatrixserverlib.ServerName(serverName), gomatrixserverlib.KeyID(keyID),
|
||||
ServerName: gomatrixserverlib.ServerName(serverName),
|
||||
KeyID: gomatrixserverlib.KeyID(keyID),
|
||||
}
|
||||
results[r] = serverKeys
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func localKeys(cfg config.Dendrite, validUntil time.Time) (*gomatrixserverlib.Se
|
||||
|
||||
keys.VerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.VerifyKey{
|
||||
cfg.Matrix.KeyID: {
|
||||
gomatrixserverlib.Base64String(publicKey),
|
||||
Key: gomatrixserverlib.Base64String(publicKey),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -15,24 +15,29 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"testing"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
)
|
||||
|
||||
func benchmarkStateEntryMapLookup(entries, lookups int64, b *testing.B) {
|
||||
var list []types.StateEntry
|
||||
for i := int64(0); i < entries; i++ {
|
||||
list = append(list, types.StateEntry{types.StateKeyTuple{
|
||||
types.EventTypeNID(i),
|
||||
types.EventStateKeyNID(i),
|
||||
}, types.EventNID(i)})
|
||||
list = append(list, types.StateEntry{
|
||||
StateKeyTuple: types.StateKeyTuple{
|
||||
EventTypeNID: types.EventTypeNID(i),
|
||||
EventStateKeyNID: types.EventStateKeyNID(i),
|
||||
},
|
||||
EventNID: types.EventNID(i),
|
||||
})
|
||||
}
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
entryMap := stateEntryMap(list)
|
||||
for j := int64(0); j < lookups; j++ {
|
||||
entryMap.lookup(types.StateKeyTuple{
|
||||
types.EventTypeNID(j), types.EventStateKeyNID(j),
|
||||
EventTypeNID: types.EventTypeNID(j),
|
||||
EventStateKeyNID: types.EventStateKeyNID(j),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -56,9 +61,9 @@ func BenchmarkStateEntryMap1000Lookup10000(b *testing.B) {
|
||||
|
||||
func TestStateEntryMap(t *testing.T) {
|
||||
entryMap := stateEntryMap([]types.StateEntry{
|
||||
{types.StateKeyTuple{1, 1}, 1},
|
||||
{types.StateKeyTuple{1, 3}, 2},
|
||||
{types.StateKeyTuple{2, 1}, 3},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 3}, EventNID: 2},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 2, EventStateKeyNID: 1}, EventNID: 3},
|
||||
})
|
||||
|
||||
testCases := []struct {
|
||||
@ -78,7 +83,7 @@ func TestStateEntryMap(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
keyTuple := types.StateKeyTuple{testCase.inputTypeNID, testCase.inputStateKey}
|
||||
keyTuple := types.StateKeyTuple{EventTypeNID: testCase.inputTypeNID, EventStateKeyNID: testCase.inputStateKey}
|
||||
gotEventNID, gotOK := entryMap.lookup(keyTuple)
|
||||
if testCase.wantOK != gotOK {
|
||||
t.Fatalf("stateEntryMap lookup(%v): want ok to be %v, got %v", keyTuple, testCase.wantOK, gotOK)
|
||||
|
@ -15,8 +15,9 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
"testing"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/types"
|
||||
)
|
||||
|
||||
func TestFindDuplicateStateKeys(t *testing.T) {
|
||||
@ -25,18 +26,18 @@ func TestFindDuplicateStateKeys(t *testing.T) {
|
||||
Want []types.StateEntry
|
||||
}{{
|
||||
Input: []types.StateEntry{
|
||||
{types.StateKeyTuple{1, 1}, 1},
|
||||
{types.StateKeyTuple{1, 1}, 2},
|
||||
{types.StateKeyTuple{2, 2}, 3},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 2},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 2, EventStateKeyNID: 2}, EventNID: 3},
|
||||
},
|
||||
Want: []types.StateEntry{
|
||||
{types.StateKeyTuple{1, 1}, 1},
|
||||
{types.StateKeyTuple{1, 1}, 2},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 2},
|
||||
},
|
||||
}, {
|
||||
Input: []types.StateEntry{
|
||||
{types.StateKeyTuple{1, 1}, 1},
|
||||
{types.StateKeyTuple{1, 2}, 2},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 1}, EventNID: 1},
|
||||
{StateKeyTuple: types.StateKeyTuple{EventTypeNID: 1, EventStateKeyNID: 2}, EventNID: 2},
|
||||
},
|
||||
Want: nil,
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user