Skip to content

Commit 1c938bd

Browse files
Address comments
1 parent 717d597 commit 1c938bd

5 files changed

Lines changed: 31 additions & 15 deletions

File tree

da/jsonrpc/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9-
"strings"
109

1110
"cosmossdk.io/log"
1211
"github.com/filecoin-project/go-jsonrpc"
@@ -61,7 +60,7 @@ func (api *API) GetIDs(ctx context.Context, height uint64, _ []byte) (*da.GetIDs
6160
api.Logger.Debug("RPC call indicates blobs not found", "method", "GetIDs", "height", height)
6261
return nil, err // Return the specific ErrBlobNotFound
6362
}
64-
if strings.Contains(err.Error(), da.ErrHeightFromFuture.Error()) {
63+
if errors.Is(err, da.ErrHeightFromFuture) {
6564
api.Logger.Debug("RPC call indicates height from future", "method", "GetIDs", "height", height)
6665
return nil, err // Return the specific ErrHeightFromFuture
6766
}

da/jsonrpc/proxy_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func TestProxy(t *testing.T) {
7373
t.Run("Given height is from the future", func(t *testing.T) {
7474
HeightFromFutureTest(t, &client.DA)
7575
})
76+
dummy.StopHeightTicker()
7677
}
7778

7879
// BasicDATest tests round trip of messages to DA and back.

node/full_node_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func testSingleSequencerTwoFullNodes(t *testing.T, source Source) {
328328
shutdownAndWait(t, cancels, &runningWg, 5*time.Second)
329329
}
330330

331-
// testSingleSequencerSingleFullNode sets up a single sequencer and a single full node with a trusted hash, starts the sequencer, waits for it to produce a block, then starts the full node with the trusted hash.
331+
// testSingleSequencerSingleFullNodeTrustedHash sets up a single sequencer and a single full node with a trusted hash, starts the sequencer, waits for it to produce a block, then starts the full node with the trusted hash.
332332
// It waits for both nodes to reach a target block height (using the provided 'source' to determine block inclusion), verifies that both nodes are fully synced, and then shuts them down.
333333
func testSingleSequencerSingleFullNodeTrustedHash(t *testing.T, source Source) {
334334
require := require.New(t)

node/helpers_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ const (
4242
)
4343

4444
// createTestComponents creates test components for node initialization
45-
func createTestComponents(t *testing.T, config rollkitconfig.Config) (coreexecutor.Executor, coresequencer.Sequencer, coreda.DA, *p2p.Client, datastore.Batching, *key.NodeKey) {
45+
func createTestComponents(t *testing.T, config rollkitconfig.Config) (coreexecutor.Executor, coresequencer.Sequencer, coreda.DA, *p2p.Client, datastore.Batching, *key.NodeKey, func()) {
4646
executor := coreexecutor.NewDummyExecutor()
4747
sequencer := coresequencer.NewDummySequencer()
4848
dummyDA := coreda.NewDummyDA(100_000, 0, 0, config.DA.BlockTime.Duration)
4949
dummyDA.StartHeightTicker()
5050

51+
stopDAHeightTicker := func() {
52+
dummyDA.StopHeightTicker()
53+
}
54+
5155
// Create genesis and keys for P2P client
5256
_, genesisValidatorKey, _ := types.GetGenesisWithPrivkey("test-chain")
5357
p2pKey := &key.NodeKey{
@@ -59,7 +63,7 @@ func createTestComponents(t *testing.T, config rollkitconfig.Config) (coreexecut
5963
require.NotNil(t, p2pClient)
6064
ds := dssync.MutexWrap(datastore.NewMapDatastore())
6165

62-
return executor, sequencer, dummyDA, p2pClient, ds, p2pKey
66+
return executor, sequencer, dummyDA, p2pClient, ds, p2pKey, stopDAHeightTicker
6367
}
6468

6569
func getTestConfig(t *testing.T, n int) rollkitconfig.Config {
@@ -97,7 +101,7 @@ func createNodeWithCleanup(t *testing.T, config rollkitconfig.Config) (*FullNode
97101
remoteSigner, err := remote_signer.NewNoopSigner(genesisValidatorKey)
98102
require.NoError(t, err)
99103

100-
executor, sequencer, dac, p2pClient, ds, _ := createTestComponents(t, config)
104+
executor, sequencer, dac, p2pClient, ds, _, stopDAHeightTicker := createTestComponents(t, config)
101105
nodeKey, err := InitFiles(config.RootDir)
102106
require.NoError(t, err)
103107

@@ -121,6 +125,7 @@ func createNodeWithCleanup(t *testing.T, config rollkitconfig.Config) (*FullNode
121125
cleanup := func() {
122126
// Cancel the context to stop the node
123127
cancel()
128+
stopDAHeightTicker()
124129
}
125130

126131
return node.(*FullNode), cleanup
@@ -143,7 +148,7 @@ func createNodesWithCleanup(t *testing.T, num int, config rollkitconfig.Config)
143148

144149
aggListenAddress := config.P2P.ListenAddress
145150
aggPeers := config.P2P.Peers
146-
executor, sequencer, dac, p2pClient, ds, aggP2PKey := createTestComponents(t, config)
151+
executor, sequencer, dac, p2pClient, ds, aggP2PKey, stopDAHeightTicker := createTestComponents(t, config)
147152
aggPeerID, err := peer.IDFromPrivateKey(aggP2PKey.PrivKey)
148153
require.NoError(err)
149154

@@ -170,6 +175,7 @@ func createNodesWithCleanup(t *testing.T, num int, config rollkitconfig.Config)
170175
cleanup := func() {
171176
// Cancel the context to stop the node
172177
aggCancel()
178+
stopDAHeightTicker()
173179
}
174180

175181
nodes[0], cleanups[0] = aggNode.(*FullNode), cleanup
@@ -186,7 +192,7 @@ func createNodesWithCleanup(t *testing.T, num int, config rollkitconfig.Config)
186192
}
187193
config.P2P.ListenAddress = fmt.Sprintf("/ip4/127.0.0.1/tcp/%d", 40001+i)
188194
config.RPC.Address = fmt.Sprintf("127.0.0.1:%d", 8001+i)
189-
executor, sequencer, _, p2pClient, _, nodeP2PKey := createTestComponents(t, config)
195+
executor, sequencer, _, p2pClient, _, nodeP2PKey, stopDAHeightTicker := createTestComponents(t, config)
190196
node, err := NewNode(
191197
ctx,
192198
config,
@@ -206,6 +212,7 @@ func createNodesWithCleanup(t *testing.T, num int, config rollkitconfig.Config)
206212
cleanup := func() {
207213
// Cancel the context to stop the node
208214
cancel()
215+
stopDAHeightTicker()
209216
}
210217
nodes[i], cleanups[i] = node.(*FullNode), cleanup
211218
nodePeerID, err := peer.IDFromPrivateKey(nodeP2PKey.PrivKey)

pkg/cmd/run_node_test.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ import (
2525

2626
const MockDANamespace = "test"
2727

28-
func createTestComponents(_ context.Context, t *testing.T) (coreexecutor.Executor, coresequencer.Sequencer, coreda.DA, signer.Signer, *p2p.Client, datastore.Batching) {
28+
func createTestComponents(_ context.Context, t *testing.T) (coreexecutor.Executor, coresequencer.Sequencer, coreda.DA, signer.Signer, *p2p.Client, datastore.Batching, func()) {
2929
executor := coreexecutor.NewDummyExecutor()
3030
sequencer := coresequencer.NewDummySequencer()
3131
dummyDA := coreda.NewDummyDA(100_000, 0, 0, 10*time.Second)
3232
dummyDA.StartHeightTicker()
33+
stopDAHeightTicker := func() {
34+
dummyDA.StopHeightTicker()
35+
}
3336
tmpDir := t.TempDir()
3437
keyProvider, err := filesigner.CreateFileSystemSigner(filepath.Join(tmpDir, "config"), []byte{})
3538
if err != nil {
@@ -39,7 +42,7 @@ func createTestComponents(_ context.Context, t *testing.T) (coreexecutor.Executo
3942
p2pClient := &p2p.Client{}
4043
ds := datastore.NewMapDatastore()
4144

42-
return executor, sequencer, dummyDA, keyProvider, p2pClient, ds
45+
return executor, sequencer, dummyDA, keyProvider, p2pClient, ds, stopDAHeightTicker
4346
}
4447

4548
func TestParseFlags(t *testing.T) {
@@ -79,7 +82,8 @@ func TestParseFlags(t *testing.T) {
7982

8083
args := append([]string{"start"}, flags...)
8184

82-
executor, sequencer, dac, keyProvider, p2pClient, ds := createTestComponents(context.Background(), t)
85+
executor, sequencer, dac, keyProvider, p2pClient, ds, stopDAHeightTicker := createTestComponents(context.Background(), t)
86+
defer stopDAHeightTicker()
8387
nodeKey, err := key.GenerateNodeKey()
8488
if err != nil {
8589
t.Fatalf("Error: %v", err)
@@ -159,7 +163,8 @@ func TestAggregatorFlagInvariants(t *testing.T) {
159163
for i, flags := range flagVariants {
160164
args := append([]string{"start"}, flags...)
161165

162-
executor, sequencer, dac, keyProvider, p2pClient, ds := createTestComponents(context.Background(), t)
166+
executor, sequencer, dac, keyProvider, p2pClient, ds, stopDAHeightTicker := createTestComponents(context.Background(), t)
167+
defer stopDAHeightTicker()
163168

164169
nodeKey, err := key.GenerateNodeKey()
165170
if err != nil {
@@ -199,7 +204,8 @@ func TestDefaultAggregatorValue(t *testing.T) {
199204
}
200205
for _, tc := range testCases {
201206
t.Run(tc.name, func(t *testing.T) {
202-
executor, sequencer, dac, keyProvider, p2pClient, ds := createTestComponents(context.Background(), t)
207+
executor, sequencer, dac, keyProvider, p2pClient, ds, stopDAHeightTicker := createTestComponents(context.Background(), t)
208+
defer stopDAHeightTicker()
203209

204210
nodeKey, err := key.GenerateNodeKey()
205211
if err != nil {
@@ -283,7 +289,8 @@ func TestCentralizedAddresses(t *testing.T) {
283289
"--rollkit.da.address=http://central-da:26657",
284290
}
285291

286-
executor, sequencer, dac, keyProvider, p2pClient, ds := createTestComponents(context.Background(), t)
292+
executor, sequencer, dac, keyProvider, p2pClient, ds, stopDAHeightTicker := createTestComponents(context.Background(), t)
293+
defer stopDAHeightTicker()
287294

288295
tmpDir := t.TempDir()
289296
nodeKey, err := key.LoadOrGenNodeKey(filepath.Join(tmpDir, "config", "node_key.json"))
@@ -312,7 +319,9 @@ func TestStartNodeErrors(t *testing.T) {
312319
logger := log.NewNopLogger() // Use NopLogger for tests unless specific logging output is needed
313320

314321
// Common setup
315-
executor, sequencer, dac, _, p2pClient, ds := createTestComponents(baseCtx, t)
322+
executor, sequencer, dac, _, p2pClient, ds, stopDAHeightTicker := createTestComponents(baseCtx, t)
323+
defer stopDAHeightTicker()
324+
316325
nodeKey, err := key.GenerateNodeKey()
317326
assert.NoError(t, err)
318327
tmpDir := t.TempDir()

0 commit comments

Comments
 (0)