@@ -11,50 +11,12 @@ import (
1111 "github.com/stretchr/testify/require"
1212
1313 datypes "github.com/evstack/ev-node/pkg/da/types"
14- )
15-
16- // MockClient is a mock implementation of the Client interface
17- type MockClient struct {
18- mock.Mock
19- }
20-
21- func (m * MockClient ) Submit (ctx context.Context , data [][]byte , gasPrice float64 , namespace []byte , options []byte ) datypes.ResultSubmit {
22- args := m .Called (ctx , data , gasPrice , namespace , options )
23- return args .Get (0 ).(datypes.ResultSubmit )
24- }
25-
26- func (m * MockClient ) Retrieve (ctx context.Context , height uint64 , namespace []byte ) datypes.ResultRetrieve {
27- args := m .Called (ctx , height , namespace )
28- return args .Get (0 ).(datypes.ResultRetrieve )
29- }
30-
31- func (m * MockClient ) Get (ctx context.Context , ids []datypes.ID , namespace []byte ) ([]datypes.Blob , error ) {
32- args := m .Called (ctx , ids , namespace )
33- return args .Get (0 ).([]datypes.Blob ), args .Error (1 )
34- }
3514
36- func (m * MockClient ) GetHeaderNamespace () []byte {
37- args := m .Called ()
38- return args .Get (0 ).([]byte )
39- }
40-
41- func (m * MockClient ) GetDataNamespace () []byte {
42- args := m .Called ()
43- return args .Get (0 ).([]byte )
44- }
45-
46- func (m * MockClient ) GetForcedInclusionNamespace () []byte {
47- args := m .Called ()
48- return args .Get (0 ).([]byte )
49- }
50-
51- func (m * MockClient ) HasForcedInclusionNamespace () bool {
52- args := m .Called ()
53- return args .Bool (0 )
54- }
15+ mocks "github.com/evstack/ev-node/test/mocks"
16+ )
5517
5618func TestAsyncEpochFetcher_Creation (t * testing.T ) {
57- client := & MockClient {}
19+ client := & mocks. MockClient {}
5820 logger := zerolog .Nop ()
5921
6022 fetcher := NewAsyncEpochFetcher (client , logger , 100 , 10 , 2 , 100 * time .Millisecond )
@@ -66,7 +28,7 @@ func TestAsyncEpochFetcher_Creation(t *testing.T) {
6628}
6729
6830func TestAsyncEpochFetcher_SetAndGetDAHeight (t * testing.T ) {
69- client := & MockClient {}
31+ client := & mocks. MockClient {}
7032 logger := zerolog .Nop ()
7133
7234 fetcher := NewAsyncEpochFetcher (client , logger , 100 , 10 , 1 , time .Second )
@@ -82,7 +44,7 @@ func TestAsyncEpochFetcher_SetAndGetDAHeight(t *testing.T) {
8244}
8345
8446func TestAsyncEpochFetcher_GetCachedEpoch_NotAtEpochEnd (t * testing.T ) {
85- client := & MockClient {}
47+ client := & mocks. MockClient {}
8648 fiNs := datypes .NamespaceFromString ("test-fi-ns" ).Bytes ()
8749 client .On ("HasForcedInclusionNamespace" ).Return (true )
8850 client .On ("GetForcedInclusionNamespace" ).Return (fiNs )
@@ -102,7 +64,7 @@ func TestAsyncEpochFetcher_GetCachedEpoch_NotAtEpochEnd(t *testing.T) {
10264}
10365
10466func TestAsyncEpochFetcher_GetCachedEpoch_NoNamespace (t * testing.T ) {
105- client := & MockClient {}
67+ client := & mocks. MockClient {}
10668 client .On ("HasForcedInclusionNamespace" ).Return (false )
10769
10870 logger := zerolog .Nop ()
@@ -114,7 +76,7 @@ func TestAsyncEpochFetcher_GetCachedEpoch_NoNamespace(t *testing.T) {
11476}
11577
11678func TestAsyncEpochFetcher_GetCachedEpoch_CacheMiss (t * testing.T ) {
117- client := & MockClient {}
79+ client := & mocks. MockClient {}
11880 fiNs := datypes .NamespaceFromString ("test-fi-ns" ).Bytes ()
11981 client .On ("HasForcedInclusionNamespace" ).Return (true )
12082 client .On ("GetForcedInclusionNamespace" ).Return (fiNs )
@@ -137,7 +99,7 @@ func TestAsyncEpochFetcher_FetchAndCache(t *testing.T) {
13799 []byte ("tx3" ),
138100 }
139101
140- client := & MockClient {}
102+ client := & mocks. MockClient {}
141103 fiNs := datypes .NamespaceFromString ("test-fi-ns" ).Bytes ()
142104 client .On ("HasForcedInclusionNamespace" ).Return (true )
143105 client .On ("GetForcedInclusionNamespace" ).Return (fiNs )
@@ -182,7 +144,7 @@ func TestAsyncEpochFetcher_BackgroundPrefetch(t *testing.T) {
182144 []byte ("tx2" ),
183145 }
184146
185- client := & MockClient {}
147+ client := & mocks. MockClient {}
186148 fiNs := datypes .NamespaceFromString ("test-fi-ns" ).Bytes ()
187149 client .On ("HasForcedInclusionNamespace" ).Return (true )
188150 client .On ("GetForcedInclusionNamespace" ).Return (fiNs )
@@ -276,7 +238,7 @@ func TestAsyncEpochFetcher_SerializationEmpty(t *testing.T) {
276238}
277239
278240func TestAsyncEpochFetcher_HeightFromFuture (t * testing.T ) {
279- client := & MockClient {}
241+ client := & mocks. MockClient {}
280242 fiNs := datypes .NamespaceFromString ("test-fi-ns" ).Bytes ()
281243 client .On ("HasForcedInclusionNamespace" ).Return (true )
282244 client .On ("GetForcedInclusionNamespace" ).Return (fiNs )
@@ -300,7 +262,7 @@ func TestAsyncEpochFetcher_HeightFromFuture(t *testing.T) {
300262}
301263
302264func TestAsyncEpochFetcher_StopGracefully (t * testing.T ) {
303- client := & MockClient {}
265+ client := & mocks. MockClient {}
304266 client .On ("HasForcedInclusionNamespace" ).Return (false )
305267
306268 logger := zerolog .Nop ()
0 commit comments