diff --git a/crypto/sql_store.go b/crypto/sql_store.go index ffb83f90..8f6291cd 100644 --- a/crypto/sql_store.go +++ b/crypto/sql_store.go @@ -413,8 +413,10 @@ func (store *SQLCryptoStore) GetGroupSession(ctx context.Context, roomID id.Room Reason: withheldReason.String, } } + fmt.Printf("got here 1\n") libolmIgs, goolmIgs, chains, rs, err := store.postScanInboundGroupSession(sessionBytes, ratchetSafetyBytes, forwardingChains.String) if err != nil { + fmt.Printf("got here 2 %+v\n", err) return nil, err } return &InboundGroupSession{ @@ -527,7 +529,7 @@ func (store *SQLCryptoStore) GetWithheldGroupSession(ctx context.Context, roomID func (store *SQLCryptoStore) postScanInboundGroupSession(sessionBytes, ratchetSafetyBytes []byte, forwardingChains string) (igs olm.InboundGroupSession, igsGoolm olm.InboundGroupSession, chains []string, safety RatchetSafety, err error) { igs = libolm.NewBlankInboundGroupSession() - err = igs.Unpickle(sessionBytes, store.PickleKey) + err = igs.Unpickle(bytes.Clone(sessionBytes), store.PickleKey) if err != nil { return } diff --git a/crypto/store_test.go b/crypto/store_test.go index c0ffa36b..b5ae113d 100644 --- a/crypto/store_test.go +++ b/crypto/store_test.go @@ -158,9 +158,7 @@ func TestStoreMegolmSession(t *testing.T) { acc := NewOlmAccount() internal, err := libolm.InboundGroupSessionFromPickled([]byte(groupSession), []byte("test")) - if err != nil { - t.Fatalf("Error creating internal inbound group session: %v", err) - } + require.NoError(t, err, "Error creating internal inbound group session") internalGoolm, err := session.MegolmInboundSessionFromPickled([]byte(groupSession), []byte("test")) require.NoError(t, err) @@ -174,14 +172,10 @@ func TestStoreMegolmSession(t *testing.T) { } err = store.PutGroupSession(context.TODO(), igs) - if err != nil { - t.Errorf("Error storing inbound group session: %v", err) - } + require.NoError(t, err, "Error storing inbound group session") retrieved, err := store.GetGroupSession(context.TODO(), "room1", igs.ID()) - if err != nil { - t.Errorf("Error retrieving inbound group session: %v", err) - } + require.NoError(t, err, "Error retrieving inbound group session") pickled, err := retrieved.InternalLibolm.Pickle([]byte("test")) require.NoError(t, err)