mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 03:43:11 -06:00
sort events by depth because sytest makes me sad
Specifically I think it's
4172585c25/lib/SyTest/Federation/Client.pm (L265)
to blame here.
This commit is contained in:
parent
bc1d8772dc
commit
ef4a9dc2a4
|
|
@ -17,6 +17,7 @@ package routing
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
|
|
@ -275,6 +276,12 @@ func SendJoin(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort events deterministically by depth (lower is earlier)
|
||||||
|
// We also do this because sytest's basic federation server isn't good at using the correct
|
||||||
|
// state if these lists are randomised, resulting in flakey tests. :(
|
||||||
|
sort.Sort(eventsByDepth(stateAndAuthChainResponse.StateEvents))
|
||||||
|
sort.Sort(eventsByDepth(stateAndAuthChainResponse.AuthChainEvents))
|
||||||
|
|
||||||
// https://matrix.org/docs/spec/server_server/latest#put-matrix-federation-v1-send-join-roomid-eventid
|
// https://matrix.org/docs/spec/server_server/latest#put-matrix-federation-v1-send-join-roomid-eventid
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
|
|
@ -285,3 +292,15 @@ func SendJoin(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type eventsByDepth []gomatrixserverlib.HeaderedEvent
|
||||||
|
|
||||||
|
func (e eventsByDepth) Len() int {
|
||||||
|
return len(e)
|
||||||
|
}
|
||||||
|
func (e eventsByDepth) Swap(i, j int) {
|
||||||
|
e[i], e[j] = e[j], e[i]
|
||||||
|
}
|
||||||
|
func (e eventsByDepth) Less(i, j int) bool {
|
||||||
|
return e[i].Depth() < e[j].Depth()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue