@@ -11,22 +11,22 @@ import (
11
11
"time"
12
12
13
13
"github.com/ethereum/go-ethereum/p2p/enr"
14
+ "github.com/libp2p/go-libp2p"
14
15
pubsub "github.com/libp2p/go-libp2p-pubsub"
15
16
core "github.com/libp2p/go-libp2p/core"
16
17
"github.com/libp2p/go-libp2p/core/control"
17
18
"github.com/libp2p/go-libp2p/core/host"
18
19
"github.com/libp2p/go-libp2p/core/network"
19
20
"github.com/libp2p/go-libp2p/core/peer"
20
21
"github.com/libp2p/go-libp2p/core/protocol"
21
- bhost "github.com/libp2p/go-libp2p/p2p/host/blank"
22
- swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
23
22
"github.com/multiformats/go-multiaddr"
24
23
ssz "github.com/prysmaticlabs/fastssz"
25
24
"github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/encoder"
26
25
"github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/peers"
27
26
"github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/peers/scorers"
28
27
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
29
28
"github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/metadata"
29
+ "github.com/prysmaticlabs/prysm/v5/testing/require"
30
30
"github.com/sirupsen/logrus"
31
31
"google.golang.org/protobuf/proto"
32
32
)
@@ -52,7 +52,8 @@ type TestP2P struct {
52
52
// NewTestP2P initializes a new p2p test service.
53
53
func NewTestP2P (t * testing.T ) * TestP2P {
54
54
ctx := context .Background ()
55
- h := bhost .NewBlankHost (swarmt .GenSwarm (t , swarmt .OptDisableQUIC ))
55
+ h , err := libp2p .New (libp2p .ResourceManager (& network.NullResourceManager {}))
56
+ require .NoError (t , err )
56
57
ps , err := pubsub .NewFloodSub (ctx , h ,
57
58
pubsub .WithMessageSigning (false ),
58
59
pubsub .WithStrictSignatureVerification (false ),
@@ -92,7 +93,8 @@ func connect(a, b host.Host) error {
92
93
93
94
// ReceiveRPC simulates an incoming RPC.
94
95
func (p * TestP2P ) ReceiveRPC (topic string , msg proto.Message ) {
95
- h := bhost .NewBlankHost (swarmt .GenSwarm (p .t ))
96
+ h , err := libp2p .New (libp2p .ResourceManager (& network.NullResourceManager {}))
97
+ require .NoError (p .t , err )
96
98
if err := connect (h , p .BHost ); err != nil {
97
99
p .t .Fatalf ("Failed to connect two peers for RPC: %v" , err )
98
100
}
@@ -122,7 +124,8 @@ func (p *TestP2P) ReceiveRPC(topic string, msg proto.Message) {
122
124
123
125
// ReceivePubSub simulates an incoming message over pubsub on a given topic.
124
126
func (p * TestP2P ) ReceivePubSub (topic string , msg proto.Message ) {
125
- h := bhost .NewBlankHost (swarmt .GenSwarm (p .t ))
127
+ h , err := libp2p .New (libp2p .ResourceManager (& network.NullResourceManager {}))
128
+ require .NoError (p .t , err )
126
129
ps , err := pubsub .NewFloodSub (context .Background (), h ,
127
130
pubsub .WithMessageSigning (false ),
128
131
pubsub .WithStrictSignatureVerification (false ),
@@ -136,7 +139,7 @@ func (p *TestP2P) ReceivePubSub(topic string, msg proto.Message) {
136
139
137
140
// PubSub requires some delay after connecting for the (*PubSub).processLoop method to
138
141
// pick up the newly connected peer.
139
- time .Sleep (time .Millisecond * 100 )
142
+ time .Sleep (time .Millisecond * 1000 )
140
143
141
144
castedMsg , ok := msg .(ssz.Marshaler )
142
145
if ! ok {
0 commit comments