Skip to content

Commit

Permalink
fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Dec 13, 2023
1 parent a5a8e9e commit 340b0d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func (p *Processor) StartProcessor(cfg config.Config, logger log.Logger, process

var batchPosition int
// if this is the first time seeing this tx hash, add the message to State
// msg, ok := State.Load(LookupKey(dequeuedMsg.SourceTxHash, dequeuedMsg.Type, sha256.Sum256(dequeuedMsg.MsgSentBytes)))
msg, ok := State.Load(dequeuedMsg.SourceTxHash)
if !ok {
batchPosition = 0
Expand Down
18 changes: 15 additions & 3 deletions types/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import (
"github.com/stretchr/testify/require"
)

func TestX(t *testing.T) {
func TestStateHandling(t *testing.T) {
stateMap := NewStateMap()

txHash := "123456789"
msg := MessageState{SourceTxHash: txHash, IrisLookupId: "123", Status: Filtered, MsgSentBytes: []byte("i like turtles")}
msg := MessageState{
SourceTxHash: txHash,
IrisLookupId: "123",
Status: Filtered,
MsgSentBytes: []byte("i like turtles"),
}

stateMap.Store(txHash, []*MessageState{&msg})

loadedMsg, _ := stateMap.Load(txHash)
Expand All @@ -24,7 +30,13 @@ func TestX(t *testing.T) {
require.Equal(t, Complete, loadedMsg2[0].Status)

// even though loadedMsg is a pointer, if we add to the array, we need to re-store in cache.
msg2 := MessageState{SourceTxHash: txHash, IrisLookupId: "123", Status: Filtered, MsgSentBytes: []byte("mock bytes 2")}
msg2 := MessageState{
SourceTxHash: txHash,
IrisLookupId: "123",
Status: Filtered,
MsgSentBytes: []byte("mock bytes 2"),
}

loadedMsg = append(loadedMsg, &msg2)
stateMap.Store(txHash, loadedMsg)

Expand Down

0 comments on commit 340b0d0

Please sign in to comment.