Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Dec 13, 2023
1 parent e732647 commit a5a8e9e
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions cmd/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,37 @@ func TestProcessNonWhitelistedChannel(t *testing.T) {
p.Mu.RUnlock()
}

// created message -> not \ -> filtered
func TestProcessNonBurnMessageWhenDisabled(t *testing.T) {
setupTest()

p := cmd.NewProcessor()

go p.StartProcessor(cfg, logger, processingQueue, sequenceMap)

emptyBz := make([]byte, 32)
expectedState := &types.MessageState{
SourceTxHash: "123",
Type: "",
IrisLookupId: "a404f4155166a1fc7ffee145b5cac6d0f798333745289ab1db171344e226ef0c",
Status: types.Created,
SourceDomain: 0,
DestDomain: 4,
DestinationCaller: emptyBz,
}

processingQueue <- expectedState

time.Sleep(2 * time.Second)

actualState, ok := cmd.State.Load(expectedState.SourceTxHash)
require.True(t, ok)
p.Mu.RLock()
require.Equal(t, types.Filtered, actualState[0].Status)
p.Mu.RUnlock()

}

// test batch transactions where multiple messages can be sent with the same tx hash
// MsgSentBytes defer between messages
func TestBatchTx(t *testing.T) {
Expand Down Expand Up @@ -229,30 +260,3 @@ func TestBatchTx(t *testing.T) {
require.Equal(t, 2, len(actualState))
p.Mu.RUnlock()
}

// created message -> not \ -> filtered
func TestProcessNonBurnMessageWhenDisabled(t *testing.T) {
setupTest()

go cmd.StartProcessor(cfg, logger, processingQueue, sequenceMap)

emptyBz := make([]byte, 32)
expectedState := &types.MessageState{
SourceTxHash: "123",
Type: "",
IrisLookupId: "a404f4155166a1fc7ffee145b5cac6d0f798333745289ab1db171344e226ef0c",
Status: types.Created,
SourceDomain: 0,
DestDomain: 4,
DestinationCaller: emptyBz,
}

processingQueue <- expectedState

time.Sleep(2 * time.Second)

actualState, ok := cmd.State.Load(cmd.LookupKey(expectedState.SourceTxHash, expectedState.Type))
require.True(t, ok)
require.Equal(t, types.Filtered, actualState.Status)

}

0 comments on commit a5a8e9e

Please sign in to comment.