Skip to content

Commit cf2646f

Browse files
committed
Fix broken tests
Signed-off-by: Gustavo Sampaio <[email protected]>
1 parent 919a2d4 commit cf2646f

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

fetcher_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func TestFetcherReadWholeBlock(t *testing.T) {
9090

9191
host := mocks.NewMockHost(ctrl)
9292
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
93+
host.EXPECT().Provide(gomock.Any(), block.Cid())
9394

9495
peerCh := make(chan libp2pPeerstore.PeerInfo, 1)
9596
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -123,6 +124,7 @@ func TestFetcherReadOverCap(t *testing.T) {
123124

124125
host := mocks.NewMockHost(ctrl)
125126
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
127+
host.EXPECT().Provide(gomock.Any(), block.Cid())
126128

127129
peerCh := make(chan libp2pPeerstore.PeerInfo, 1)
128130
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -166,6 +168,7 @@ func TestFetcherReadMidBlock(t *testing.T) {
166168
peerCh := make(chan libp2pPeerstore.PeerInfo, 1)
167169
peerCh <- libp2pPeerstore.PeerInfo{}
168170

171+
host.EXPECT().Provide(gomock.Any(), block.Cid())
169172
host.EXPECT().FindProviders(gomock.Any(), gomock.Any()).Return((<-chan libp2pPeerstore.PeerInfo)(peerCh))
170173
host.EXPECT().CreateBlockStream(gomock.Any(), gomock.Any(), gomock.Any()).Return(bytes.NewReader(block.RawData()), nil)
171174

@@ -219,6 +222,7 @@ func TestFetcherReadBetweenBlocks(t *testing.T) {
219222

220223
host := mocks.NewMockHost(ctrl)
221224
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
225+
host.EXPECT().Provide(gomock.Any(), gomock.Any()).AnyTimes()
222226

223227
peerCh := make(chan libp2pPeerstore.PeerInfo, 2)
224228
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -275,6 +279,7 @@ func TestFetcherReadFinalBlock(t *testing.T) {
275279

276280
host := mocks.NewMockHost(ctrl)
277281
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
282+
host.EXPECT().Provide(gomock.Any(), gomock.Any()).AnyTimes()
278283

279284
peerCh := make(chan libp2pPeerstore.PeerInfo, 2)
280285
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -331,6 +336,7 @@ func TestFetcherBigBlocks(t *testing.T) {
331336

332337
host := mocks.NewMockHost(ctrl)
333338
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
339+
host.EXPECT().Provide(gomock.Any(), gomock.Any()).AnyTimes()
334340

335341
peerCh := make(chan libp2pPeerstore.PeerInfo, 2)
336342
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -521,6 +527,7 @@ func TestFetcherDownloadInvalidData(t *testing.T) {
521527

522528
host := mocks.NewMockHost(ctrl)
523529
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
530+
host.EXPECT().Provide(gomock.Any(), gomock.Any()).AnyTimes()
524531

525532
peerCh := make(chan libp2pPeerstore.PeerInfo, 2)
526533
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -560,6 +567,7 @@ func TestFetcherDownloadShortRead(t *testing.T) {
560567

561568
host := mocks.NewMockHost(ctrl)
562569
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
570+
host.EXPECT().Provide(gomock.Any(), gomock.Any()).AnyTimes()
563571

564572
peerCh := make(chan libp2pPeerstore.PeerInfo, 2)
565573
peerCh <- libp2pPeerstore.PeerInfo{}
@@ -599,6 +607,7 @@ func TestFetcherDownloadErrorCreateStream(t *testing.T) {
599607

600608
host := mocks.NewMockHost(ctrl)
601609
fs.(*mocks.MockCore).EXPECT().Host().AnyTimes().Return(host)
610+
host.EXPECT().Provide(gomock.Any(), gomock.Any()).AnyTimes()
602611

603612
peerCh := make(chan libp2pPeerstore.PeerInfo, 2)
604613
peerCh <- libp2pPeerstore.PeerInfo{}

relay.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/runletapp/crabfs/identity"
77

8-
libp2pHost "github.com/libp2p/go-libp2p-core/host"
98
"github.com/runletapp/crabfs/interfaces"
109
"github.com/runletapp/crabfs/options"
1110
)
@@ -16,8 +15,7 @@ type Relay struct {
1615

1716
port uint
1817

19-
p2pRelayHost libp2pHost.Host
20-
host interfaces.Core
18+
host interfaces.Core
2119
}
2220

2321
// RelayNew creates a new relay instance
@@ -43,11 +41,7 @@ func RelayNew(ctx context.Context, port uint, bootstrapPeers []string, id identi
4341

4442
// Close closes this relay instance
4543
func (relay *Relay) Close() error {
46-
if err := relay.host.Close(); err != nil {
47-
return err
48-
}
49-
50-
return relay.p2pRelayHost.Close()
44+
return relay.host.Close()
5145
}
5246

5347
// GetAddrs get the addresses that this node is bound to

0 commit comments

Comments
 (0)