diff --git a/node/full_client_test.go b/node/full_client_test.go index 3bd54484b6..4523ad811c 100644 --- a/node/full_client_test.go +++ b/node/full_client_test.go @@ -187,11 +187,7 @@ func TestGenesisChunked(t *testing.T) { assert.Error(err) assert.Nil(gc) - err = rpc.node.Start() - require.NoError(t, err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) expectedID = 0 gc2, err := rpc.GenesisChunked(context.Background(), expectedID) gotID := gc2.ChunkNumber @@ -212,11 +208,7 @@ func TestBroadcastTxAsync(t *testing.T) { mockApp, rpc := getRPC(t) mockApp.On("CheckTx", mock.Anything, &abci.RequestCheckTx{Tx: expectedTx}).Return(&abci.ResponseCheckTx{}, nil) - err := rpc.node.Start() - require.NoError(t, err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) res, err := rpc.BroadcastTxAsync(context.Background(), expectedTx) assert.NoError(err) assert.NotNil(res) @@ -245,11 +237,7 @@ func TestBroadcastTxSync(t *testing.T) { mockApp, rpc := getRPC(t) - err := rpc.node.Start() - require.NoError(t, err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) mockApp.On("CheckTx", mock.Anything, &abci.RequestCheckTx{Tx: expectedTx}).Return(&expectedResponse, nil) res, err := rpc.BroadcastTxSync(context.Background(), expectedTx) @@ -329,14 +317,10 @@ func TestGetBlock(t *testing.T) { mockApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse) mockApp.On("Commit", mock.Anything, mock.Anything).Return(&abci.ResponseCommit{}, nil) - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) ctx := context.Background() block := types.GetRandomBlock(1, 10) - err = rpc.node.Store.SaveBlock(ctx, block, &types.Commit{}) + err := rpc.node.Store.SaveBlock(ctx, block, &types.Commit{}) rpc.node.Store.SetHeight(ctx, block.Height()) require.NoError(err) @@ -356,14 +340,10 @@ func TestGetCommit(t *testing.T) { blocks := []*types.Block{types.GetRandomBlock(1, 5), types.GetRandomBlock(2, 6), types.GetRandomBlock(3, 8), types.GetRandomBlock(4, 10)} - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) ctx := context.Background() for _, b := range blocks { - err = rpc.node.Store.SaveBlock(ctx, b, &types.Commit{}) + err := rpc.node.Store.SaveBlock(ctx, b, &types.Commit{}) rpc.node.Store.SetHeight(ctx, b.Height()) require.NoError(err) } @@ -401,17 +381,12 @@ func TestCometBFTLightClientCompability(t *testing.T) { blocks := []*types.Block{block1, block2, block3} - // start the node for testing - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) ctx := context.Background() // save the 3 blocks for _, b := range blocks { - err = rpc.node.Store.SaveBlock(ctx, b, &b.SignedHeader.Commit) + err := rpc.node.Store.SaveBlock(ctx, b, &b.SignedHeader.Commit) rpc.node.Store.SetHeight(ctx, b.Height()) require.NoError(err) } @@ -522,14 +497,10 @@ func TestGetBlockByHash(t *testing.T) { mockApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse) mockApp.On("Commit", mock.Anything, mock.Anything).Return(&abci.ResponseCommit{}, nil) - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) ctx := context.Background() block := types.GetRandomBlock(1, 10) - err = rpc.node.Store.SaveBlock(ctx, block, &types.Commit{}) + err := rpc.node.Store.SaveBlock(ctx, block, &types.Commit{}) require.NoError(err) abciBlock, err := abciconv.ToABCIBlock(block) require.NoError(err) @@ -596,11 +567,7 @@ func TestTx(t *testing.T) { mockApp.On("CheckTx", mock.Anything, mock.Anything).Return(&abci.ResponseCheckTx{}, nil) mockApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse) - err = rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) tx1 := cmtypes.Tx("tx1") res, err := rpc.BroadcastTxSync(ctx, tx1) assert.NoError(err) @@ -641,17 +608,12 @@ func TestUnconfirmedTxs(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { assert := assert.New(t) - require := require.New(t) mockApp, rpc := getRPC(t) mockApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse) mockApp.On("CheckTx", mock.Anything, mock.Anything).Return(&abci.ResponseCheckTx{}, nil) - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) for _, tx := range c.txs { res, err := rpc.BroadcastTxAsync(context.Background(), tx) @@ -680,17 +642,12 @@ func TestUnconfirmedTxs(t *testing.T) { func TestUnconfirmedTxsLimit(t *testing.T) { assert := assert.New(t) - require := require.New(t) mockApp, rpc := getRPC(t) mockApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse) mockApp.On("CheckTx", mock.Anything, mock.Anything).Return(&abci.ResponseCheckTx{}, nil) - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) tx1 := cmtypes.Tx("tx1") tx2 := cmtypes.Tx("another tx") @@ -872,19 +829,12 @@ func TestMempool2Nodes(t *testing.T) { require.NoError(err) require.NotNil(node2) - err = node1.Start() - require.NoError(err) + startNodeWithCleanup(t, node1) require.NoError(waitForFirstBlock(node1, Store)) - defer func() { - assert.NoError(node1.Stop()) - }() - err = node2.Start() - require.NoError(err) - defer func() { - assert.NoError(node2.Stop()) - }() + startNodeWithCleanup(t, node2) require.NoError(waitForAtLeastNBlocks(node2, 1, Store)) + timeoutCtx, timeoutCancel := context.WithTimeout(context.Background(), 3*time.Second) defer timeoutCancel() @@ -969,6 +919,8 @@ func TestStatus(t *testing.T) { rpc.node.Store.SetHeight(ctx, latestBlock.Height()) require.NoError(err) + startNodeWithCleanup(t, rpc.node) + resp, err := rpc.Status(context.Background()) assert.NoError(err) @@ -1077,12 +1029,7 @@ func TestFutureGenesisTime(t *testing.T) { require.NoError(err) require.NotNil(node) - err = node.Start() - require.NoError(err) - - defer func() { - assert.NoError(node.Stop()) - }() + startNodeWithCleanup(t, node) wg.Wait() assert.True(beginBlockTime.After(genesisTime)) @@ -1090,18 +1037,13 @@ func TestFutureGenesisTime(t *testing.T) { func TestHealth(t *testing.T) { assert := assert.New(t) - require := require.New(t) mockApp, rpc := getRPC(t) mockApp.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse) mockApp.On("CheckTx", mock.Anything, mock.Anything).Return(abci.ResponseCheckTx{}, nil) mockApp.On("Commit", mock.Anything).Return(abci.ResponseCommit{}, nil) - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) resultHealth, err := rpc.Health(context.Background()) assert.Nil(err) @@ -1117,11 +1059,7 @@ func TestNetInfo(t *testing.T) { mockApp.On("CheckTx", mock.Anything, mock.Anything).Return(&abci.ResponseCheckTx{}, nil) mockApp.On("Commit", mock.Anything, mock.Anything).Return(&abci.ResponseCommit{}, nil) - err := rpc.node.Start() - require.NoError(err) - defer func() { - assert.NoError(rpc.node.Stop()) - }() + startNodeWithCleanup(t, rpc.node) netInfo, err := rpc.NetInfo(context.Background()) require.NoError(err) diff --git a/node/full_node_integration_test.go b/node/full_node_integration_test.go index 4d6b7a349a..6470f423bb 100644 --- a/node/full_node_integration_test.go +++ b/node/full_node_integration_test.go @@ -66,12 +66,7 @@ func TestAggregatorMode(t *testing.T) { assert.False(node.IsRunning()) - err = node.Start() - assert.NoError(err) - defer func() { - assert.NoError(node.Stop()) - }() - assert.True(node.IsRunning()) + startNodeWithCleanup(t, node) ctx, cancel = context.WithCancel(context.TODO()) defer cancel() @@ -193,12 +188,7 @@ func TestLazyAggregator(t *testing.T) { assert.False(node.IsRunning()) assert.NoError(err) - assert.NoError(node.Start()) - defer func() { - assert.NoError(node.Stop()) - }() - assert.True(node.IsRunning()) - + startNodeWithCleanup(t, node) require.NoError(waitForFirstBlock(node.(*FullNode), Header)) client := node.GetClient() @@ -221,7 +211,6 @@ func TestLazyAggregator(t *testing.T) { func TestFastDASync(t *testing.T) { // Test setup, create require and contexts for aggregator and client nodes require := require.New(t) - assert := assert.New(t) aggCtx, aggCancel := context.WithCancel(context.Background()) defer aggCancel() ctx, cancel := context.WithCancel(context.Background()) @@ -246,19 +235,13 @@ func TestFastDASync(t *testing.T) { node2 := nodes[1] // Start node 1 - require.NoError(node1.Start()) - defer func() { - assert.NoError(node1.Stop()) - }() + startNodeWithCleanup(t, node1) // Wait for node 1 to sync the first numberOfBlocksToSyncTill require.NoError(waitForAtLeastNBlocks(node1, numberOfBlocksToSyncTill, Store)) // Now that node 1 has already synced, start the second node - require.NoError(node2.Start()) - defer func() { - assert.NoError(node2.Stop()) - }() + startNodeWithCleanup(t, node2) // Start and launch the timer in a go routine to ensure that the test // fails if the nodes do not sync before the timer expires @@ -313,7 +296,7 @@ func TestFastDASync(t *testing.T) { // TestSingleAggregatorTwoFullNodesBlockSyncSpeed tests the scenario where the chain's block time is much faster than the DA's block time. In this case, the full nodes should be able to use block sync to sync blocks much faster than syncing from the DA layer, and the test should conclude within block time func TestSingleAggregatorTwoFullNodesBlockSyncSpeed(t *testing.T) { require := require.New(t) - assert := assert.New(t) + aggCtx, aggCancel := context.WithCancel(context.Background()) defer aggCancel() ctx, cancel := context.WithCancel(context.Background()) @@ -345,19 +328,11 @@ func TestSingleAggregatorTwoFullNodesBlockSyncSpeed(t *testing.T) { node2 := nodes[1] node3 := nodes[2] - require.NoError(node1.Start()) - defer func() { - assert.NoError(node1.Stop()) - }() + startNodeWithCleanup(t, node1) require.NoError(waitForFirstBlock(node1, Store)) - require.NoError(node2.Start()) - defer func() { - assert.NoError(node2.Stop()) - }() - require.NoError(node3.Start()) - defer func() { - assert.NoError(node3.Stop()) - }() + + startNodeWithCleanup(t, node2) + startNodeWithCleanup(t, node3) require.NoError(waitForAtLeastNBlocks(node2, numberOfBlocksTSyncTill, Store)) require.NoError(waitForAtLeastNBlocks(node3, numberOfBlocksTSyncTill, Store)) @@ -393,7 +368,6 @@ func TestHeaderExchange(t *testing.T) { func TestSubmitBlocksToDA(t *testing.T) { require := require.New(t) - assert := assert.New(t) clientNodes := 1 ctx, cancel := context.WithCancel(context.Background()) @@ -409,10 +383,7 @@ func TestSubmitBlocksToDA(t *testing.T) { t, ) seq := nodes[0] - require.NoError(seq.Start()) - defer func() { - assert.NoError(seq.Stop()) - }() + startNodeWithCleanup(t, seq) numberOfBlocksToSyncTill := seq.Store.Height() @@ -433,7 +404,6 @@ func TestSubmitBlocksToDA(t *testing.T) { func testSingleAggregatorSingleFullNode(t *testing.T, source Source) { require := require.New(t) - assert := assert.New(t) aggCtx, aggCancel := context.WithCancel(context.Background()) defer aggCancel() @@ -445,25 +415,17 @@ func testSingleAggregatorSingleFullNode(t *testing.T, source Source) { node1 := nodes[0] node2 := nodes[1] - require.NoError(node1.Start()) - defer func() { - assert.NoError(node1.Stop()) - }() - + startNodeWithCleanup(t, node1) require.NoError(waitForFirstBlock(node1, source)) - require.NoError(node2.Start()) - - defer func() { - assert.NoError(node2.Stop()) - }() + startNodeWithCleanup(t, node2) require.NoError(waitForAtLeastNBlocks(node2, 2, source)) + require.NoError(verifyNodesSynced(node1, node2, source)) } func testSingleAggregatorTwoFullNode(t *testing.T, source Source) { require := require.New(t) - assert := assert.New(t) aggCtx, aggCancel := context.WithCancel(context.Background()) defer aggCancel() @@ -476,29 +438,21 @@ func testSingleAggregatorTwoFullNode(t *testing.T, source Source) { node2 := nodes[1] node3 := nodes[2] - require.NoError(node1.Start()) - defer func() { - assert.NoError(node1.Stop()) - }() + startNodeWithCleanup(t, node1) require.NoError(waitForFirstBlock(node1, source)) - require.NoError(node2.Start()) - defer func() { - assert.NoError(node2.Stop()) - }() - require.NoError(node3.Start()) - defer func() { - assert.NoError(node3.Stop()) - }() + + startNodeWithCleanup(t, node2) + startNodeWithCleanup(t, node3) require.NoError(waitForAtLeastNBlocks(node2, 2, source)) require.NoError(waitForAtLeastNBlocks(node3, 2, source)) + require.NoError(verifyNodesSynced(node1, node2, source)) require.NoError(verifyNodesSynced(node1, node3, source)) } func testSingleAggregatorSingleFullNodeTrustedHash(t *testing.T, source Source) { require := require.New(t) - assert := assert.New(t) aggCtx, aggCancel := context.WithCancel(context.Background()) defer aggCancel() @@ -510,21 +464,15 @@ func testSingleAggregatorSingleFullNodeTrustedHash(t *testing.T, source Source) node1 := nodes[0] node2 := nodes[1] - require.NoError(node1.Start()) - defer func() { - assert.NoError(node1.Stop()) - }() - + startNodeWithCleanup(t, node1) require.NoError(waitForFirstBlock(node1, source)) // Get the trusted hash from node1 and pass it to node2 config trustedHash, err := node1.hSyncService.HeaderStore().GetByHeight(aggCtx, 1) require.NoError(err) + node2.nodeConfig.TrustedHash = trustedHash.Hash().String() - require.NoError(node2.Start()) - defer func() { - assert.NoError(node2.Stop()) - }() + startNodeWithCleanup(t, node2) require.NoError(waitForAtLeastNBlocks(node1, 2, source)) require.NoError(verifyNodesSynced(node1, node2, source)) @@ -532,7 +480,6 @@ func testSingleAggregatorSingleFullNodeTrustedHash(t *testing.T, source Source) func testSingleAggregatorSingleFullNodeSingleLightNode(t *testing.T) { require := require.New(t) - assert := assert.New(t) aggCtx, aggCancel := context.WithCancel(context.Background()) defer aggCancel() @@ -549,18 +496,9 @@ func testSingleAggregatorSingleFullNodeSingleLightNode(t *testing.T) { fullNode, _ := createAndConfigureNode(ctx, 1, false, false, keys, bmConfig, dalc, t) lightNode, _ := createNode(ctx, 2, false, true, keys, bmConfig, t) - require.NoError(sequencer.Start()) - defer func() { - assert.NoError(sequencer.Stop()) - }() - require.NoError(fullNode.Start()) - defer func() { - assert.NoError(fullNode.Stop()) - }() - require.NoError(lightNode.Start()) - defer func() { - assert.NoError(lightNode.Stop()) - }() + startNodeWithCleanup(t, sequencer) + startNodeWithCleanup(t, fullNode) + startNodeWithCleanup(t, lightNode) require.NoError(waitForAtLeastNBlocks(sequencer.(*FullNode), 2, Header)) require.NoError(verifyNodesSynced(sequencer, fullNode, Header)) diff --git a/node/full_node_test.go b/node/full_node_test.go index 925c34d709..79ae58a494 100644 --- a/node/full_node_test.go +++ b/node/full_node_test.go @@ -27,17 +27,15 @@ import ( // simply check that node is starting and stopping without panicking func TestStartup(t *testing.T) { ctx := context.Background() - node := initializeAndStartFullNode(ctx, t) - defer cleanUpNode(node, t) + _ = initAndStartNodeWithCleanup(ctx, t, "full").(*FullNode) } func TestMempoolDirectly(t *testing.T) { ctx := context.Background() - node := initializeAndStartFullNode(ctx, t) - defer cleanUpNode(node, t) - assert := assert.New(t) + node := initAndStartNodeWithCleanup(ctx, t, "full").(*FullNode) + assert := assert.New(t) peerID := getPeerID(assert) verifyTransactions(node, peerID, assert) verifyMempoolSize(node, assert) @@ -72,10 +70,7 @@ func TestTrySyncNextBlockMultiple(t *testing.T) { DAHeight: state.DAHeight, } - err = node.Start() - require.NoError(t, err) - defer cleanUpNode(node, t) - + startNodeWithCleanup(t, node) require.NoError(t, waitUntilBlockHashSeen(node, b2.Hash().String())) newHeight := store.Height() @@ -135,9 +130,7 @@ func TestInvalidBlocksIgnored(t *testing.T) { // Validate b1 to make sure it's still valid require.NoError(t, b1.ValidateBasic()) - err = node.Start() - require.NoError(t, err) - defer cleanUpNode(node, t) + startNodeWithCleanup(t, node) // Submit invalid blocks to the mock DA // Invalid blocks should be ignored by the node @@ -164,13 +157,17 @@ func setupMockApplication() *mocks.Application { // generateSingleKey generates a single private key func generateSingleKey() crypto.PrivKey { - key, _, _ := crypto.GenerateEd25519Key(rand.Reader) + key, _, err := crypto.GenerateEd25519Key(rand.Reader) + if err != nil { + panic(err) + } return key } // getPeerID generates a peer ID func getPeerID(assert *assert.Assertions) peer.ID { key := generateSingleKey() + peerID, err := peer.IDFromPrivateKey(key) assert.NoError(err) return peerID diff --git a/node/helpers_test.go b/node/helpers_test.go index ad150e7682..a5dc226a60 100644 --- a/node/helpers_test.go +++ b/node/helpers_test.go @@ -11,7 +11,6 @@ import ( testutils "github.com/celestiaorg/utils/test" "github.com/cometbft/cometbft/libs/log" "github.com/libp2p/go-libp2p/core/crypto" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" goDATest "github.com/rollkit/go-da/test" @@ -35,7 +34,6 @@ func TestMockTester(t *testing.T) { func TestGetNodeHeight(t *testing.T) { require := require.New(t) - assert := assert.New(t) ctx, cancel := context.WithCancel(context.Background()) defer cancel() dalc := getMockDA(t) @@ -47,15 +45,12 @@ func TestGetNodeHeight(t *testing.T) { bmConfig := getBMConfig() fullNode, _ := createAndConfigureNode(ctx, 0, true, false, keys, bmConfig, dalc, t) lightNode, _ := createNode(ctx, 1, true, true, keys, bmConfig, t) - require.NoError(fullNode.Start()) - defer func() { - assert.NoError(fullNode.Stop()) - }() - assert.NoError(lightNode.Start()) - defer func() { - assert.NoError(lightNode.Stop()) - }() + fullNode.(*FullNode).dalc = dalc + fullNode.(*FullNode).blockManager.SetDALC(dalc) + + startNodeWithCleanup(t, fullNode) + startNodeWithCleanup(t, lightNode) cases := []struct { desc string diff --git a/node/light_client_test.go b/node/light_client_test.go index a7b9576a42..4d731a5a1a 100644 --- a/node/light_client_test.go +++ b/node/light_client_test.go @@ -16,8 +16,7 @@ import ( func TestLightClient_Panics(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - ln := initializeAndStartLightNode(ctx, t) - defer cleanUpNode(ln, t) + ln := initAndStartNodeWithCleanup(ctx, t, "light").(*LightNode) tests := []struct { name string diff --git a/node/node_test.go b/node/node_test.go index 24d81041ea..0f5d08e3e9 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -20,32 +20,40 @@ var MockServerAddr = ":7980" var MockNamespace = "00000000000000000000000000000000000000000000000000deadbeef" +// startNode starts the full node and stops it when the test is done +func startNodeWithCleanup(t *testing.T, node Node) { + require.False(t, node.IsRunning()) + require.NoError(t, node.Start()) + require.True(t, node.IsRunning()) + t.Cleanup(func() { + cleanUpNode(node, t) + }) +} + // cleanUpNode stops the node and checks if it is running func cleanUpNode(node Node, t *testing.T) { assert.NoError(t, node.Stop()) assert.False(t, node.IsRunning()) } -func initializeAndStartFullNode(ctx context.Context, t *testing.T) *FullNode { - node := initializeAndStartNode(ctx, t, "full") - return node.(*FullNode) -} +// initializeAndStartNode initializes and starts a node of the specified type. +func initAndStartNodeWithCleanup(ctx context.Context, t *testing.T, nodeType string) Node { + node, _ := setupTestNode(ctx, t, nodeType) + startNodeWithCleanup(t, node) -func initializeAndStartLightNode(ctx context.Context, t *testing.T) *LightNode { - node := initializeAndStartNode(ctx, t, "light") - return node.(*LightNode) + return node } -// initializeAndStartNode initializes and starts a test node -func initializeAndStartNode(ctx context.Context, t *testing.T, nodeType string) Node { - node, _ := setupTestNode(ctx, t, nodeType) - require.False(t, node.IsRunning()) - err := node.Start() +// setupTestNode sets up a test node based on the NodeType. +func setupTestNode(ctx context.Context, t *testing.T, nodeType string) (Node, ed25519.PrivKey) { + node, privKey, err := newTestNode(ctx, t, nodeType) require.NoError(t, err) - require.True(t, node.IsRunning()) - return node + require.NotNil(t, node) + + return node, privKey } +// newTestNode creates a new test node based on the NodeType. func newTestNode(ctx context.Context, t *testing.T, nodeType string) (Node, ed25519.PrivKey, error) { config := config.NodeConfig{DAAddress: MockServerAddr, DANamespace: MockNamespace} switch nodeType { @@ -54,7 +62,7 @@ func newTestNode(ctx context.Context, t *testing.T, nodeType string) (Node, ed25 case "full": config.Light = false default: - panic(fmt.Sprint("invalid node type", nodeType)) + panic(fmt.Sprintf("invalid node type: %v", nodeType)) } app := setupMockApplication() genesis, genesisValidatorKey := types.GetGenesisWithPrivkey() @@ -62,25 +70,17 @@ func newTestNode(ctx context.Context, t *testing.T, nodeType string) (Node, ed25 if err != nil { return nil, nil, err } + key := generateSingleKey() + logger := test.NewFileLogger(t) node, err := NewNode(ctx, config, key, signingKey, proxy.NewLocalClientCreator(app), genesis, DefaultMetricsProvider(cmconfig.DefaultInstrumentationConfig()), logger) return node, genesisValidatorKey, err } -// setupTestNode sets up a test node -func setupTestNode(ctx context.Context, t *testing.T, nodeType string) (Node, ed25519.PrivKey) { - node, privKey, err := newTestNode(ctx, t, nodeType) - require.NoError(t, err) - require.NotNil(t, node) - return node, privKey -} - func TestNewNode(t *testing.T) { ctx := context.Background() - ln := initializeAndStartLightNode(ctx, t) - cleanUpNode(ln, t) - fn := initializeAndStartFullNode(ctx, t) - cleanUpNode(fn, t) + _ = initAndStartNodeWithCleanup(ctx, t, "light").(*LightNode) + _ = initAndStartNodeWithCleanup(ctx, t, "full").(*FullNode) }