Skip to content

Commit 106c7be

Browse files
committed
fix problems with CI
1 parent 0717de7 commit 106c7be

File tree

5 files changed

+622
-55
lines changed

5 files changed

+622
-55
lines changed

.mockery.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ packages:
7272
dir: ./block/internal/da
7373
pkgname: da
7474
filename: blob_api_mock.go
75+
github.com/evstack/ev-node/pkg/da/jsonrpc:
76+
interfaces:
77+
BlobModule:
78+
config:
79+
dir: ./pkg/da/jsonrpc/mocks
80+
pkgname: mocks
81+
filename: blob_module_mock.go

pkg/da/jsonrpc/client_test.go

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,48 @@
1-
package blob
1+
package blob_test
22

33
import (
44
"context"
55
"net/http/httptest"
66
"testing"
77

8-
"github.com/filecoin-project/go-jsonrpc"
8+
fcjsonrpc "github.com/filecoin-project/go-jsonrpc"
9+
"github.com/stretchr/testify/mock"
910
"github.com/stretchr/testify/require"
1011

1112
libshare "github.com/celestiaorg/go-square/v3/share"
12-
)
13-
14-
type mockBlobModule struct {
15-
submitHeight uint64
16-
submitErr error
17-
18-
blob *Blob
19-
proof *Proof
20-
included bool
21-
commitProof *CommitmentProof
22-
}
23-
24-
func (m *mockBlobModule) Submit(_ context.Context, _ []*Blob, _ *SubmitOptions) (uint64, error) {
25-
return m.submitHeight, m.submitErr
26-
}
27-
28-
func (m *mockBlobModule) Get(_ context.Context, _ uint64, _ libshare.Namespace, _ Commitment) (*Blob, error) {
29-
return m.blob, nil
30-
}
31-
32-
func (m *mockBlobModule) GetAll(_ context.Context, _ uint64, _ []libshare.Namespace) ([]*Blob, error) {
33-
return []*Blob{m.blob}, nil
34-
}
3513

36-
func (m *mockBlobModule) GetProof(_ context.Context, _ uint64, _ libshare.Namespace, _ Commitment) (*Proof, error) {
37-
return m.proof, nil
38-
}
39-
40-
func (m *mockBlobModule) Included(_ context.Context, _ uint64, _ libshare.Namespace, _ *Proof, _ Commitment) (bool, error) {
41-
return m.included, nil
42-
}
43-
44-
func (m *mockBlobModule) GetCommitmentProof(_ context.Context, _ uint64, _ libshare.Namespace, _ []byte) (*CommitmentProof, error) {
45-
return m.commitProof, nil
46-
}
47-
48-
func (m *mockBlobModule) Subscribe(_ context.Context, _ libshare.Namespace) (<-chan *SubscriptionResponse, error) {
49-
ch := make(chan *SubscriptionResponse, 1)
50-
ch <- &SubscriptionResponse{Height: 11}
51-
close(ch)
52-
return ch, nil
53-
}
14+
blob "github.com/evstack/ev-node/pkg/da/jsonrpc"
15+
"github.com/evstack/ev-node/pkg/da/jsonrpc/mocks"
16+
)
5417

5518
func newTestServer(t *testing.T, module any) *httptest.Server {
5619
t.Helper()
57-
rpc := jsonrpc.NewServer()
20+
rpc := fcjsonrpc.NewServer()
5821
rpc.Register("blob", module)
5922
return httptest.NewServer(rpc)
6023
}
6124

6225
func TestClient_CallsAreForwarded(t *testing.T) {
6326
ns := libshare.MustNewV0Namespace([]byte("namespace"))
64-
blb, err := NewBlobV0(ns, []byte("data"))
27+
blb, err := blob.NewBlobV0(ns, []byte("data"))
6528
require.NoError(t, err)
6629

67-
module := &mockBlobModule{
68-
submitHeight: 7,
69-
blob: blb,
70-
proof: &Proof{},
71-
included: true,
72-
commitProof: &CommitmentProof{},
73-
}
30+
module := mocks.NewMockBlobModule(t)
31+
module.On("Submit", mock.Anything, mock.Anything, mock.Anything).Return(uint64(7), nil)
32+
module.On("Get", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(blb, nil)
33+
module.On("GetAll", mock.Anything, mock.Anything, mock.Anything).Return([]*blob.Blob{blb}, nil)
34+
module.On("GetProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&blob.Proof{}, nil)
35+
module.On("Included", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(true, nil)
36+
module.On("GetCommitmentProof", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&blob.CommitmentProof{}, nil)
37+
7438
srv := newTestServer(t, module)
7539
t.Cleanup(srv.Close)
7640

77-
client, err := NewClient(context.Background(), srv.URL, "", "")
41+
client, err := blob.NewClient(context.Background(), srv.URL, "", "")
7842
require.NoError(t, err)
7943
t.Cleanup(client.Close)
8044

81-
height, err := client.Blob.Submit(context.Background(), []*Blob{blb}, nil)
45+
height, err := client.Blob.Submit(context.Background(), []*blob.Blob{blb}, nil)
8246
require.NoError(t, err)
8347
require.Equal(t, uint64(7), height)
8448

0 commit comments

Comments
 (0)