From 332e3512d89cc13574a6349160975ecca841a91b Mon Sep 17 00:00:00 2001 From: Dmytro Haidashenko Date: Mon, 6 Nov 2023 16:58:14 +0100 Subject: [PATCH] simplify node state check --- common/client/node_fsm_test.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/common/client/node_fsm_test.go b/common/client/node_fsm_test.go index 133693bde01..87e90846699 100644 --- a/common/client/node_fsm_test.go +++ b/common/client/node_fsm_test.go @@ -1,6 +1,7 @@ package client import ( + "slices" "testing" "github.com/stretchr/testify/assert" @@ -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) @@ -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 }