Skip to content

Commit

Permalink
simplify node state check
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaidashenko committed Nov 6, 2023
1 parent 3b8e668 commit 332e351
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions common/client/node_fsm_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"slices"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -83,17 +84,6 @@ func testTransition(t *testing.T, rpc *mockNodeClient[types.ID, Head], transitio
assert.Equal(t, destinationState, node.State(), "Expected node to successfully transition from %s to %s state", allowedState, destinationState)
m.AssertCalled(t)
}

isAllowed := func(ns nodeState) bool {
for _, allowed := range allowedStates {
if allowed == ns {
return true
}
}

return false
}

// noop on attempt to transition from Closed state
m := new(fnMock)
node.setState(nodeStateClosed)
Expand All @@ -102,7 +92,7 @@ func testTransition(t *testing.T, rpc *mockNodeClient[types.ID, Head], transitio
assert.Equal(t, nodeStateClosed, node.State(), "Expected node to remain in closed state on transition attempt")

for _, nodeState := range allNodeStates {
if isAllowed(nodeState) || nodeState == nodeStateClosed {
if slices.Contains(allowedStates, nodeState) || nodeState == nodeStateClosed {
continue
}

Expand Down

0 comments on commit 332e351

Please sign in to comment.