From 16984262bc25cb5bd28f6cd46bccfd9389aef9ac Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 29 Jul 2020 15:26:56 +0100 Subject: [PATCH] Fix current state server test (sort of) --- currentstateserver/currentstateserver_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/currentstateserver/currentstateserver_test.go b/currentstateserver/currentstateserver_test.go index 41e70fd14..12d599a2f 100644 --- a/currentstateserver/currentstateserver_test.go +++ b/currentstateserver/currentstateserver_test.go @@ -15,6 +15,7 @@ package currentstateserver import ( + "bytes" "context" "crypto/ed25519" "encoding/json" @@ -160,8 +161,13 @@ func TestQueryCurrentState(t *testing.T) { t.Errorf("QueryCurrentState want tuple %+v but it is missing from the response", tuple) continue } - if !reflect.DeepEqual(gotEvent.JSON(), wantEvent.JSON()) { - t.Errorf("QueryCurrentState tuple %+v got event JSON %s want %s", tuple, string(gotEvent.JSON()), string(wantEvent.JSON())) + gotCanon, err := gomatrixserverlib.CanonicalJSON(gotEvent.JSON()) + if err != nil { + t.Errorf("CanonicalJSON failed: %w", err) + continue + } + if !bytes.Equal(gotCanon, wantEvent.JSON()) { + t.Errorf("QueryCurrentState tuple %+v got event JSON %s want %s", tuple, string(gotCanon), string(wantEvent.JSON())) } } }