From d8af915b072e0ebe985615a42a226c190c41e2d4 Mon Sep 17 00:00:00 2001 From: jbhusson <jonah@elixxir.io> Date: Wed, 5 Jan 2022 21:03:07 -0500 Subject: [PATCH] Add 0 byte to message contents --- bindings/notifications.go | 2 ++ bindings/notifications_test.go | 20 ++++++++++++++++++++ network/message/sendCmixUtils.go | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/bindings/notifications.go b/bindings/notifications.go index 71db73728..cfd87f51d 100644 --- a/bindings/notifications.go +++ b/bindings/notifications.go @@ -9,6 +9,7 @@ package bindings import ( "encoding/json" + "fmt" "github.com/pkg/errors" "gitlab.com/elixxir/client/storage/edge" "gitlab.com/elixxir/crypto/fingerprint" @@ -68,6 +69,7 @@ func NotificationsForMe(notifCSV, preimages string) (*ManyNotificationForMeRepor } list, err := notifications.DecodeNotificationsCSV(notifCSV) + fmt.Printf("%+v, %+v", list[0], list[1]) if err != nil { return nil, err diff --git a/bindings/notifications_test.go b/bindings/notifications_test.go index b180d09d7..c22d787f8 100644 --- a/bindings/notifications_test.go +++ b/bindings/notifications_test.go @@ -123,3 +123,23 @@ func TestManyNotificationForMeReport_Get(t *testing.T) { t.Errorf("Didnt get error when too long") } } + +func TestManyNotificationForMeReport_Get2(t *testing.T) { + //preimages := "[{\"Data\":\"+imfMoh4wSvzdqlXvkeM8HK37NSrcWWzNIQuN2SAWzQD\",\"Type\":\"default\",\"Source\":\"+imfMoh4wSvzdqlXvkeM8HK37NSrcWWzNIQuN2SAWzQD\"},{\"Data\":\"KyX9P0GJy1tGpX2Kl0RSHO7liXh8WZ3lVmgh0luiyPc=\",\"Type\":\"request\",\"Source\":\"+imfMoh4wSvzdqlXvkeM8HK37NSrcWWzNIQuN2SAWzQD\"},{\"Data\":\"AKpMwY5PX3A3VA+xW2P96XoAxm+w/qODIoCOv/C1jmg=\",\"Type\":\"e2e\",\"Source\":\"k2aR7LPdbI825ZM15PPQGgA5xHi5uj+945ozTWHXYn8D\"},{\"Data\":\"sFu5vVtjkpvyF9aRGadbEFpI1HtFfoz3o2y2wAcq7GE=\",\"Type\":\"silent\",\"Source\":\"k2aR7LPdbI825ZM15PPQGgA5xHi5uj+945ozTWHXYn8D\"},{\"Data\":\"fejEMJllneWUvTwG5xsk921iZymizzRakowl1odzMHM=\",\"Type\":\"endFT\",\"Source\":\"k2aR7LPdbI825ZM15PPQGgA5xHi5uj+945ozTWHXYn8D\"}]" + //csv := "LfDJYRwrmSBc9Y9Kt1C0TpxezIp42QUxZytbnoAkJrU=,NBWOG68cZhzmPrcnv0VbmuAutZ+Mfyx7vQ==" + preimages := "[{\"Data\":\"6i0/uGCZWM5CMfyS5TtqgZziDiwr62jkqI2VGP2OsfY=\",\"Type\":\"endFT\",\"Source\":\"yVbuL00vkMOMOq+9dzk7qUmc9KDUpK4QH5wxohURU7cD\"},{\"Data\":\"+imfMoh4wSvzdqlXvkeM8HK37NSrcWWzNIQuN2SAWzQD\",\"Type\":\"default\",\"Source\":\"+imfMoh4wSvzdqlXvkeM8HK37NSrcWWzNIQuN2SAWzQD\"},{\"Data\":\"AKpMwY5PX3A3VA+xW2P96XoAxm+w/qODIoCOv/C1jmg=\",\"Type\":\"e2e\",\"Source\":\"k2aR7LPdbI825ZM15PPQGgA5xHi5uj+945ozTWHXYn8D\"},{\"Data\":\"KyX9P0GJy1tGpX2Kl0RSHO7liXh8WZ3lVmgh0luiyPc=\",\"Type\":\"request\",\"Source\":\"+imfMoh4wSvzdqlXvkeM8HK37NSrcWWzNIQuN2SAWzQD\"},{\"Data\":\"fejEMJllneWUvTwG5xsk921iZymizzRakowl1odzMHM=\",\"Type\":\"endFT\",\"Source\":\"k2aR7LPdbI825ZM15PPQGgA5xHi5uj+945ozTWHXYn8D\"},{\"Data\":\"sFu5vVtjkpvyF9aRGadbEFpI1HtFfoz3o2y2wAcq7GE=\",\"Type\":\"silent\",\"Source\":\"k2aR7LPdbI825ZM15PPQGgA5xHi5uj+945ozTWHXYn8D\"},{\"Data\":\"z8jcb8HmzayFuzOGiPATJE7eaLCbu6p5TVky7zt9WWs=\",\"Type\":\"e2e\",\"Source\":\"yVbuL00vkMOMOq+9dzk7qUmc9KDUpK4QH5wxohURU7cD\"},{\"Data\":\"kMwwG5wg5/d7C5ptV/5qxOCcvXPNu1zEqAJJhAzpN1o=\",\"Type\":\"silent\",\"Source\":\"yVbuL00vkMOMOq+9dzk7qUmc9KDUpK4QH5wxohURU7cD\"}]" + // csv := "sonu7rdo4fnDnQr/EYcYfpdU3TOnZ/A+fvM5C9wYVRk=,6FZ+fEXi6DTbimit3xQv+629eXBd6cy7/w==" + csv := "dVRQWAgW7PD88S5LZQ2XehPSJn7U0h1cJT5b01Qesvw=,xFrwD5n5UmYNXAHPChpFmV6OecAJNxGP+w==\n2yDqIz9z01Pq+tV13HW/9TO4umz3jU6DaOhKATCRpqc=,kkKWe1VSwYEtiyKg6W4S5Q8Rzv53aLU6yQ==" + + report, err := NotificationsForMe(csv, preimages) + if err != nil { + t.Errorf("Failed to check if notifications are for me: %+v", err) + } + var found bool + for _, i := range report.many { + found = found || i.forMe + } + if !found { + t.Errorf("No notifications for me :(") + } +} diff --git a/network/message/sendCmixUtils.go b/network/message/sendCmixUtils.go index 15674cd2f..0a2f54c19 100644 --- a/network/message/sendCmixUtils.go +++ b/network/message/sendCmixUtils.go @@ -154,7 +154,8 @@ func buildSlotMessage(msg format.Message, recipient *id.ID, target *id.ID, } // Set the identity fingerprint - ifp := fingerprint.IdentityFP(msg.GetContents(), preimage) + + ifp := fingerprint.IdentityFP(append([]byte{0}, msg.GetContents()...), preimage) msg.SetIdentityFP(ifp) -- GitLab