Skip to content

Commit f26e960

Browse files
authored
test: remove outdated DA mock and update references (#1878)
## Overview Deleted mock implementation of DA in test/mocks/DA.go. Updated code to use new DA mock from go-da/mocks. Also removed mock generation command from Makefile. Resolves #1877 <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes #<issue number> --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a new mock package (`damock`) for improved testing of the data availability layer. - **Bug Fixes** - Enhanced integration tests for the full node functionality to ensure accurate behavior under various configurations. - **Chores** - Updated dependency version for `github.com/rollkit/go-da` from `v0.7.0` to `v0.8.0` and retracted an erroneous version. - **Refactor** - Removed outdated mock implementations and updated test cases to utilize the new mock definitions for better reliability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 17272d5 commit f26e960

File tree

8 files changed

+14
-279
lines changed

8 files changed

+14
-279
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ mock-gen:
8989
@echo "-> Generating mocks"
9090
mockery --output test/mocks --srcpkg github.com/cometbft/cometbft/rpc/client --name Client
9191
mockery --output test/mocks --srcpkg github.com/cometbft/cometbft/abci/types --name Application
92-
mockery --output test/mocks --srcpkg github.com/rollkit/go-da --name DA
9392
mockery --output test/mocks --srcpkg github.com/rollkit/rollkit/store --name Store
9493
.PHONY: mock-gen
9594

block/manager_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"google.golang.org/grpc/credentials/insecure"
3030

3131
goDA "github.com/rollkit/go-da"
32+
goDAMock "github.com/rollkit/go-da/mocks"
3233
goDATest "github.com/rollkit/go-da/test"
3334

3435
seqGRPC "github.com/rollkit/go-sequencing/proxy/grpc"
@@ -272,7 +273,7 @@ func TestSubmitBlocksToMockDA(t *testing.T) {
272273

273274
for _, tc := range testCases {
274275
t.Run(tc.name, func(t *testing.T) {
275-
mockDA := &mocks.DA{}
276+
mockDA := &goDAMock.MockDA{}
276277
m := getManager(t, mockDA)
277278
m.conf.DABlockTime = time.Millisecond
278279
m.conf.DAMempoolTTL = 1
@@ -617,7 +618,7 @@ func Test_isProposer(t *testing.T) {
617618

618619
func Test_publishBlock_ManagerNotProposer(t *testing.T) {
619620
require := require.New(t)
620-
m := getManager(t, &mocks.DA{})
621+
m := getManager(t, &goDAMock.MockDA{})
621622
m.isProposer = false
622623
err := m.publishBlock(context.Background())
623624
require.ErrorIs(err, ErrNotProposer)

da/da_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import (
1717
"google.golang.org/grpc/credentials/insecure"
1818

1919
"github.com/rollkit/go-da"
20+
damock "github.com/rollkit/go-da/mocks"
2021
proxygrpc "github.com/rollkit/go-da/proxy/grpc"
2122
proxyjsonrpc "github.com/rollkit/go-da/proxy/jsonrpc"
2223
goDATest "github.com/rollkit/go-da/test"
23-
"github.com/rollkit/rollkit/test/mocks"
2424
testServer "github.com/rollkit/rollkit/test/server"
2525
"github.com/rollkit/rollkit/types"
2626
)
@@ -69,7 +69,7 @@ func TestMain(m *testing.M) {
6969

7070
func TestMockDAErrors(t *testing.T) {
7171
t.Run("submit_timeout", func(t *testing.T) {
72-
mockDA := &mocks.DA{}
72+
mockDA := &damock.MockDA{}
7373
dalc := NewDAClient(mockDA, -1, -1, nil, nil, log.TestingLogger())
7474
header, _ := types.GetRandomBlock(1, 0)
7575
headers := []*types.SignedHeader{header}
@@ -88,14 +88,14 @@ func TestMockDAErrors(t *testing.T) {
8888
doTestSubmitTimeout(t, dalc, headers)
8989
})
9090
t.Run("max_blob_size_error", func(t *testing.T) {
91-
mockDA := &mocks.DA{}
91+
mockDA := &damock.MockDA{}
9292
dalc := NewDAClient(mockDA, -1, -1, nil, nil, log.TestingLogger())
9393
// Set up the mock to return an error for MaxBlobSize
9494
mockDA.On("MaxBlobSize", mock.Anything).Return(uint64(0), errors.New("unable to get DA max blob size"))
9595
doTestMaxBlockSizeError(t, dalc)
9696
})
9797
t.Run("tx_too_large", func(t *testing.T) {
98-
mockDA := &mocks.DA{}
98+
mockDA := &damock.MockDA{}
9999
dalc := NewDAClient(mockDA, -1, -1, nil, nil, log.TestingLogger())
100100
header, _ := types.GetRandomBlock(1, 0)
101101
headers := []*types.SignedHeader{header}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/multiformats/go-multiaddr v0.13.0
2323
github.com/pkg/errors v0.9.1
2424
github.com/prometheus/client_golang v1.20.4
25-
github.com/rollkit/go-da v0.7.0
25+
github.com/rollkit/go-da v0.8.0
2626
github.com/rs/cors v1.11.1
2727
github.com/spf13/cobra v1.8.1
2828
github.com/spf13/viper v1.19.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,8 @@ github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4
14431443
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
14441444
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
14451445
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
1446-
github.com/rollkit/go-da v0.7.0 h1:b4o5dWCCqwH0fbbhfNOoLraAsCHjN5PV1Z2rNkUB+pU=
1447-
github.com/rollkit/go-da v0.7.0/go.mod h1:9YCbEhUkF/QHbbKPBe5uvu93Co/mgPRtYjlwj6GPuhI=
1446+
github.com/rollkit/go-da v0.8.0 h1:oJKojC421eRC4mNqbujf40GzLFNp7HapgeB7Z/r0tyc=
1447+
github.com/rollkit/go-da v0.8.0/go.mod h1:3eHWK5gkv8lhwq6bjOZOi82WwHyS2B9rQOlUrE1GGws=
14481448
github.com/rollkit/go-sequencing v0.1.0 h1:LL6QT5pekydPLxeU8ncRoRlkdbJpM8fcsu+Uw15H4sE=
14491449
github.com/rollkit/go-sequencing v0.1.0/go.mod h1:s/3XzHYeY+bximgM8PDdQmoe9aWBSOa4NDQmBxpMJ4A=
14501450
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=

node/full_node_integration_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/stretchr/testify/require"
3030

3131
goDA "github.com/rollkit/go-da"
32+
damock "github.com/rollkit/go-da/mocks"
3233
"github.com/rollkit/rollkit/block"
3334
"github.com/rollkit/rollkit/config"
3435
"github.com/rollkit/rollkit/da"
@@ -674,7 +675,7 @@ func doTestMaxPending(maxPending uint64, t *testing.T) {
674675
MaxPendingBlocks: maxPending,
675676
}, types.TestChainID, false, t)
676677
seq := nodes[0]
677-
mockDA := &mocks.DA{}
678+
mockDA := &damock.MockDA{}
678679

679680
// make sure mock DA is not accepting any submissions
680681
mockDA.On("MaxBlobSize", mock.Anything).Return(uint64(123456789), nil)

node/full_node_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
testutils "github.com/celestiaorg/utils/test"
2929

3030
goDA "github.com/rollkit/go-da"
31+
damock "github.com/rollkit/go-da/mocks"
3132
"github.com/rollkit/rollkit/block"
3233
"github.com/rollkit/rollkit/config"
3334
"github.com/rollkit/rollkit/da"
@@ -198,7 +199,7 @@ func TestInvalidBlocksIgnored(t *testing.T) {
198199
func TestPendingBlocks(t *testing.T) {
199200
ctx := context.Background()
200201

201-
mockDA := new(mocks.DA)
202+
mockDA := new(damock.MockDA)
202203
mockDA.On("MaxBlobSize", mock.Anything).Return(uint64(10240), nil)
203204
mockDA.On("Submit", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, errors.New("DA not available"))
204205

test/mocks/DA.go

Lines changed: 0 additions & 267 deletions
This file was deleted.

0 commit comments

Comments
 (0)