From 53e94f010c414b755af494c3c8960e54fcef00c5 Mon Sep 17 00:00:00 2001 From: Jono Wenger <jono@elixxir.io> Date: Wed, 4 Jan 2023 10:22:35 -0800 Subject: [PATCH] Update deps --- Makefile | 4 +- go.mod | 2 +- go.sum | 4 +- indexedDb/channels/implementation.go | 60 ++++++++++++----------- indexedDb/channels/implementation_test.go | 14 ++++-- indexedDb/dm/implementation.go | 21 ++++---- 6 files changed, 56 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index 4a6c40fd..916f6fd9 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,8 @@ build: go mod tidy update_release: - GOFLAGS="" go get -d gitlab.com/elixxir/client/v4@release - GOFLAGS="" go get gitlab.com/elixxir/crypto@release + GOFLAGS="" go get -d gitlab.com/elixxir/client/v4@project/adminCommands + GOFLAGS="" go get gitlab.com/elixxir/crypto@project/adminCommands GOFLAGS="" go get gitlab.com/elixxir/primitives@release GOFLAGS="" go get gitlab.com/xx_network/crypto@release GOFLAGS="" go get gitlab.com/xx_network/primitives@release diff --git a/go.mod b/go.mod index 856d68fc..e1203618 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/spf13/jwalterweatherman v1.1.0 gitlab.com/elixxir/client/v4 v4.3.12-0.20230104175249-e265a4ca4e58 - gitlab.com/elixxir/crypto v0.0.7-0.20221220211727-4158804e6037 + gitlab.com/elixxir/crypto v0.0.7-0.20230104175234-604a6cd56b98 gitlab.com/elixxir/primitives v0.0.3-0.20221214192222-988b44a6958a gitlab.com/xx_network/crypto v0.0.5-0.20221121220724-8eefdbb0eb46 gitlab.com/xx_network/primitives v0.0.4-0.20221219230308-4b5550a9247d diff --git a/go.sum b/go.sum index 9859c304..f6a9c577 100644 --- a/go.sum +++ b/go.sum @@ -382,8 +382,8 @@ gitlab.com/elixxir/client/v4 v4.3.12-0.20230104175249-e265a4ca4e58 h1:cZFtKQQT3F gitlab.com/elixxir/client/v4 v4.3.12-0.20230104175249-e265a4ca4e58/go.mod h1:IbslBQ3B9cAoWiHhucRSLcDiF6CMIDmbRlHfoO0sEDA= gitlab.com/elixxir/comms v0.0.4-0.20221215214627-7807bfdde33a h1:DuqDqWc5cWjZ3qk98K1Bf9y1dYlyCeIigFmkHWDKc1Q= gitlab.com/elixxir/comms v0.0.4-0.20221215214627-7807bfdde33a/go.mod h1:B2Yek4mCbtN2aXZkyZcUffd3sTEZ5WgKD0mRBSVYtF8= -gitlab.com/elixxir/crypto v0.0.7-0.20221220211727-4158804e6037 h1:R6jdr5GiYmZGYYdCokey/k2JJD1eB0+AwD+BVNT6iBQ= -gitlab.com/elixxir/crypto v0.0.7-0.20221220211727-4158804e6037/go.mod h1:7whUm4bnEdEoiVfMnu3TbHgvlrz0Ywp/Tekqg2Wl7vw= +gitlab.com/elixxir/crypto v0.0.7-0.20230104175234-604a6cd56b98 h1:4uAPUenpRJYdnVGJzC3QXPX+dQkztL3YOMC1C0lJGN4= +gitlab.com/elixxir/crypto v0.0.7-0.20230104175234-604a6cd56b98/go.mod h1:7whUm4bnEdEoiVfMnu3TbHgvlrz0Ywp/Tekqg2Wl7vw= gitlab.com/elixxir/ekv v0.2.1 h1:dtwbt6KmAXG2Tik5d60iDz2fLhoFBgWwST03p7T+9Is= gitlab.com/elixxir/ekv v0.2.1/go.mod h1:USLD7xeDnuZEavygdrgzNEwZXeLQJK/w1a+htpN+JEU= gitlab.com/elixxir/primitives v0.0.3-0.20221214192222-988b44a6958a h1:F17FfEjS+/uDI/TTYQD21S5JvNZ9+p9bieau2nyLCzo= diff --git a/indexedDb/channels/implementation.go b/indexedDb/channels/implementation.go index 6ac4d47d..26c78490 100644 --- a/indexedDb/channels/implementation.go +++ b/indexedDb/channels/implementation.go @@ -152,10 +152,9 @@ func (w *wasmModel) deleteMsgByChannel(channelID *id.ID) error { // // It may be called multiple times on the same message; it is incumbent on the // user of the API to filter such called by message ID. -func (w *wasmModel) ReceiveMessage(channelID *id.ID, - messageID message.ID, nickname, text string, - pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, - timestamp time.Time, lease time.Duration, round rounds.Round, +func (w *wasmModel) ReceiveMessage(channelID *id.ID, messageID message.ID, + nickname, text string, pubKey ed25519.PublicKey, dmToken uint32, + codeset uint8, timestamp time.Time, lease time.Duration, round rounds.Round, mType channels.MessageType, status channels.SentStatus, hidden bool) uint64 { textBytes := []byte(text) var err error @@ -189,11 +188,11 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID, // // Messages may arrive our of order, so a reply, in theory, can arrive before // the initial message. As a result, it may be important to buffer replies. -func (w *wasmModel) ReceiveReply(channelID *id.ID, - messageID message.ID, replyTo message.ID, - nickname, text string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, - timestamp time.Time, lease time.Duration, round rounds.Round, - mType channels.MessageType, status channels.SentStatus, hidden bool) uint64 { +func (w *wasmModel) ReceiveReply(channelID *id.ID, messageID, + replyTo message.ID, nickname, text string, pubKey ed25519.PublicKey, + dmToken uint32, codeset uint8, timestamp time.Time, lease time.Duration, + round rounds.Round, mType channels.MessageType, status channels.SentStatus, + hidden bool) uint64 { textBytes := []byte(text) var err error @@ -225,11 +224,11 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID, // // Messages may arrive our of order, so a reply, in theory, can arrive before // the initial message. As a result, it may be important to buffer reactions. -func (w *wasmModel) ReceiveReaction(channelID *id.ID, - messageID message.ID, reactionTo message.ID, - nickname, reaction string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, - timestamp time.Time, lease time.Duration, round rounds.Round, - mType channels.MessageType, status channels.SentStatus, hidden bool) uint64 { +func (w *wasmModel) ReceiveReaction(channelID *id.ID, messageID, + reactionTo message.ID, nickname, reaction string, pubKey ed25519.PublicKey, + dmToken uint32, codeset uint8, timestamp time.Time, lease time.Duration, + round rounds.Round, mType channels.MessageType, status channels.SentStatus, + hidden bool) uint64 { textBytes := []byte(reaction) var err error @@ -255,6 +254,9 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID, return uuid } +// UpdateFromMessageID is called whenever a message with the message ID is +// modified. +// // The API needs to return the UUID of the modified message that can be // referenced at a later time. // @@ -296,9 +298,9 @@ func (w *wasmModel) UpdateFromMessageID(messageID message.ID, // messageID, timestamp, round, pinned, and hidden are all nillable and may be // updated based upon the UUID at a later date. If a nil value is passed, then // make no update. -func (w *wasmModel) UpdateFromUUID(uuid uint64, - messageID *message.ID, timestamp *time.Time, - round *rounds.Round, pinned, hidden *bool, status *channels.SentStatus) { +func (w *wasmModel) UpdateFromUUID(uuid uint64, messageID *message.ID, + timestamp *time.Time, round *rounds.Round, pinned, hidden *bool, + status *channels.SentStatus) { parentErr := errors.New("failed to UpdateFromUUID") // FIXME: this is a bit of race condition without the mux. @@ -327,9 +329,8 @@ func (w *wasmModel) UpdateFromUUID(uuid uint64, } // updateMessage is a helper for updating a stored message. -func (w *wasmModel) updateMessage(currentMsgJson string, - messageID *message.ID, timestamp *time.Time, - round *rounds.Round, pinned, hidden *bool, +func (w *wasmModel) updateMessage(currentMsgJson string, messageID *message.ID, + timestamp *time.Time, round *rounds.Round, pinned, hidden *bool, status *channels.SentStatus) (uint64, error) { newMessage := &Message{} @@ -380,9 +381,10 @@ func (w *wasmModel) updateMessage(currentMsgJson string, // autoincrement key by default. If you are trying to overwrite an existing // message, then you need to set it manually yourself. func buildMessage(channelID, messageID, parentID []byte, nickname string, - text []byte, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, timestamp time.Time, - lease time.Duration, round id.Round, mType channels.MessageType, - pinned, hidden bool, status channels.SentStatus) *Message { + text []byte, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, + timestamp time.Time, lease time.Duration, round id.Round, + mType channels.MessageType, pinned, hidden bool, + status channels.SentStatus) *Message { return &Message{ MessageID: messageID, Nickname: nickname, @@ -404,8 +406,8 @@ func buildMessage(channelID, messageID, parentID []byte, nickname string, } // receiveHelper is a private helper for receiving any sort of message. -func (w *wasmModel) receiveHelper(newMessage *Message, isUpdate bool) (uint64, - error) { +func (w *wasmModel) receiveHelper( + newMessage *Message, isUpdate bool) (uint64, error) { // Convert to jsObject newMessageJson, err := json.Marshal(newMessage) if err != nil { @@ -437,7 +439,7 @@ func (w *wasmModel) receiveHelper(newMessage *Message, isUpdate bool) (uint64, msgID := message.ID{} copy(msgID[:], newMessage.MessageID) msg, errLookup := w.msgIDLookup(msgID) - if msg.ID != 0 && errLookup == nil { + if errLookup == nil && msg.ID != 0 { return msg.ID, nil } return 0, errors.Errorf("uuid lookup failure: %+v", err) @@ -449,7 +451,8 @@ func (w *wasmModel) receiveHelper(newMessage *Message, isUpdate bool) (uint64, } // GetMessage returns the message with the given [channel.MessageID]. -func (w *wasmModel) GetMessage(messageID message.ID) (channels.ModelMessage, error) { +func (w *wasmModel) GetMessage( + messageID message.ID) (channels.ModelMessage, error) { lookupResult, err := w.msgIDLookup(messageID) if err != nil { return channels.ModelMessage{}, err @@ -491,8 +494,7 @@ func (w *wasmModel) GetMessage(messageID message.ID) (channels.ModelMessage, err } // msgIDLookup gets the UUID of the Message with the given messageID. -func (w *wasmModel) msgIDLookup(messageID message.ID) (*Message, - error) { +func (w *wasmModel) msgIDLookup(messageID message.ID) (*Message, error) { msgIDStr := js.ValueOf(base64.StdEncoding.EncodeToString(messageID.Bytes())) resultObj, err := indexedDb.GetIndex(w.db, messageStoreName, messageStoreMessageIndex, msgIDStr) diff --git a/indexedDb/channels/implementation_test.go b/indexedDb/channels/implementation_test.go index 92d9b622..9e14fbe7 100644 --- a/indexedDb/channels/implementation_test.go +++ b/indexedDb/channels/implementation_test.go @@ -40,7 +40,8 @@ func dummyCallback(uint64, *id.ID, bool) {} // Happy path, insert message and look it up func TestWasmModel_msgIDLookup(t *testing.T) { - cipher, err := cryptoChannel.NewCipher([]byte("testpass"), []byte("testsalt"), 128, csprng.NewSystemRNG()) + cipher, err := cryptoChannel.NewCipher( + []byte("testpass"), []byte("testsalt"), 128, csprng.NewSystemRNG()) if err != nil { t.Fatalf("Failed to create cipher") } @@ -125,7 +126,8 @@ func TestWasmModel_DeleteMessage(t *testing.T) { // Test wasmModel.UpdateSentStatus happy path and ensure fields don't change. func Test_wasmModel_UpdateSentStatus(t *testing.T) { - cipher, err := cryptoChannel.NewCipher([]byte("testpass"), []byte("testsalt"), 128, csprng.NewSystemRNG()) + cipher, err := cryptoChannel.NewCipher( + []byte("testpass"), []byte("testsalt"), 128, csprng.NewSystemRNG()) if err != nil { t.Fatalf("Failed to create cipher") } @@ -134,10 +136,11 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) { if c != nil { cs = "_withCipher" } - t.Run(fmt.Sprintf("Test_wasmModel_UpdateSentStatus%s", cs), func(t *testing.T) { + t.Run("Test_wasmModel_UpdateSentStatus"+cs, func(t *testing.T) { storage.GetLocalStorage().Clear() testString := "Test_wasmModel_UpdateSentStatus" + cs - testMsgId := message.DeriveChannelMessageID(&id.ID{1}, 0, []byte(testString)) + testMsgId := message.DeriveChannelMessageID( + &id.ID{1}, 0, []byte(testString)) eventModel, err := newWASMModel(testString, c, dummyCallback) if err != nil { t.Fatalf("%+v", err) @@ -193,7 +196,8 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) { // Smoke test wasmModel.JoinChannel/wasmModel.LeaveChannel happy paths. func Test_wasmModel_JoinChannel_LeaveChannel(t *testing.T) { - cipher, err := cryptoChannel.NewCipher([]byte("testpass"), []byte("testsalt"), 128, csprng.NewSystemRNG()) + cipher, err := cryptoChannel.NewCipher( + []byte("testpass"), []byte("testsalt"), 128, csprng.NewSystemRNG()) if err != nil { t.Fatalf("Failed to create cipher") } diff --git a/indexedDb/dm/implementation.go b/indexedDb/dm/implementation.go index 0b5e812d..d6703af6 100644 --- a/indexedDb/dm/implementation.go +++ b/indexedDb/dm/implementation.go @@ -99,10 +99,10 @@ func (w *wasmModel) Receive(messageID message.ID, nickname string, text []byte, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, timestamp time.Time, round rounds.Round, mType dm.MessageType, status dm.Status) uint64 { parentErr := errors.New("failed to Receive") - var err error // If there is no extant Conversation, create one. - if _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)); err != nil { + _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)) + if err != nil { if strings.Contains(err.Error(), indexedDb.ErrDoesNotExist) { err = w.joinConversation(nickname, pubKey, dmToken, codeset) if err != nil { @@ -141,10 +141,10 @@ func (w *wasmModel) ReceiveText(messageID message.ID, nickname, text string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, timestamp time.Time, round rounds.Round, status dm.Status) uint64 { parentErr := errors.New("failed to ReceiveText") - var err error // If there is no extant Conversation, create one. - if _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)); err != nil { + _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)) + if err != nil { if strings.Contains(err.Error(), indexedDb.ErrDoesNotExist) { err = w.joinConversation(nickname, pubKey, dmToken, codeset) if err != nil { @@ -182,13 +182,14 @@ func (w *wasmModel) ReceiveText(messageID message.ID, nickname, text string, } func (w *wasmModel) ReceiveReply(messageID message.ID, reactionTo message.ID, - nickname, text string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, - timestamp time.Time, round rounds.Round, status dm.Status) uint64 { + nickname, text string, pubKey ed25519.PublicKey, dmToken uint32, + codeset uint8, timestamp time.Time, round rounds.Round, + status dm.Status) uint64 { parentErr := errors.New("failed to ReceiveReply") - var err error // If there is no extant Conversation, create one. - if _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)); err != nil { + _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)) + if err != nil { if strings.Contains(err.Error(), indexedDb.ErrDoesNotExist) { err = w.joinConversation(nickname, pubKey, dmToken, codeset) if err != nil { @@ -229,10 +230,10 @@ func (w *wasmModel) ReceiveReaction(messageID message.ID, reactionTo message.ID, nickname, reaction string, pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, timestamp time.Time, round rounds.Round, status dm.Status) uint64 { parentErr := errors.New("failed to ReceiveText") - var err error // If there is no extant Conversation, create one. - if _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)); err != nil { + _, err := indexedDb.Get(w.db, conversationStoreName, utils.CopyBytesToJS(pubKey)) + if err != nil { if strings.Contains(err.Error(), indexedDb.ErrDoesNotExist) { err = w.joinConversation(nickname, pubKey, dmToken, codeset) if err != nil { -- GitLab