@@ -7,8 +7,10 @@ import (
7
7
"path/filepath"
8
8
"testing"
9
9
10
- coremocks "github.com/ChainSafe/gossamer/dot/core/mocks"
10
+ "github.com/ChainSafe/gossamer/dot/network"
11
+ "github.com/ChainSafe/gossamer/dot/peerset"
11
12
"github.com/ChainSafe/gossamer/dot/state"
13
+ "github.com/ChainSafe/gossamer/dot/types"
12
14
"github.com/ChainSafe/gossamer/internal/log"
13
15
"github.com/ChainSafe/gossamer/lib/common"
14
16
"github.com/ChainSafe/gossamer/lib/crypto/sr25519"
@@ -19,21 +21,23 @@ import (
19
21
"github.com/ChainSafe/gossamer/lib/runtime/wasmer"
20
22
"github.com/ChainSafe/gossamer/lib/utils"
21
23
"github.com/golang/mock/gomock"
22
- "github.com/stretchr/testify/mock "
24
+ "github.com/libp2p/go-libp2p-core/peer "
23
25
"github.com/stretchr/testify/require"
24
26
)
25
27
26
28
// NewTestService creates a new test core service
27
29
func NewTestService (t * testing.T , cfg * Config ) * Service {
28
30
t .Helper ()
31
+ ctrl := gomock .NewController (t )
29
32
30
33
if cfg == nil {
31
34
cfg = & Config {}
32
35
}
33
36
34
37
if cfg .DigestHandler == nil {
35
- cfg .DigestHandler = new (coremocks.DigestHandler )
36
- cfg .DigestHandler .(* coremocks.DigestHandler ).On ("HandleDigests" , mock .AnythingOfType ("*types.Header" ))
38
+ digestHandler := NewMockDigestHandler (ctrl )
39
+ digestHandler .EXPECT ().HandleDigests (gomock .AssignableToTypeOf (new (types.Header )))
40
+ cfg .DigestHandler = digestHandler
37
41
}
38
42
39
43
if cfg .Keystore == nil {
@@ -56,7 +60,6 @@ func NewTestService(t *testing.T, cfg *Config) *Service {
56
60
if cfg .BlockState == nil || cfg .StorageState == nil ||
57
61
cfg .TransactionState == nil || cfg .EpochState == nil ||
58
62
cfg .CodeSubstitutedState == nil {
59
- ctrl := gomock .NewController (t )
60
63
telemetryMock := NewMockClient (ctrl )
61
64
telemetryMock .EXPECT ().SendMessage (gomock .Any ()).AnyTimes ()
62
65
@@ -123,10 +126,13 @@ func NewTestService(t *testing.T, cfg *Config) *Service {
123
126
cfg .BlockState .StoreRuntime (cfg .BlockState .BestBlockHash (), cfg .Runtime )
124
127
125
128
if cfg .Network == nil {
126
- net := new (coremocks.Network )
127
- net .On ("GossipMessage" , mock .AnythingOfType ("*network.TransactionMessage" ))
128
- net .On ("IsSynced" ).Return (true )
129
- net .On ("ReportPeer" , mock .AnythingOfType ("peerset.ReputationChange" ), mock .AnythingOfType ("peer.ID" ))
129
+ net := NewMockNetwork (ctrl )
130
+ net .EXPECT ().GossipMessage (gomock .AssignableToTypeOf (new (network.TransactionMessage )))
131
+ net .EXPECT ().IsSynced ().Return (true )
132
+ net .EXPECT ().ReportPeer (
133
+ gomock .AssignableToTypeOf (peerset.ReputationChange {}),
134
+ gomock .AssignableToTypeOf (peer .ID ("" )),
135
+ )
130
136
cfg .Network = net
131
137
}
132
138
0 commit comments