Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Mar 19, 2024
1 parent 1cfa63b commit 4609285
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions PeerManager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ func TestNewPeerManager(t *testing.T) {
peerHandler := NewMockPeerHandler()

peer, err := NewPeer(logger, "localhost:18333", peerHandler, wire.TestNet)
defer peer.Shutdown()
require.NoError(t, err)

err = pm.AddPeer(peer)
require.NoError(t, err)
assert.Len(t, pm.GetPeers(), 1)
peer.Shutdown()
})

t.Run("1 peer - de dup", func(t *testing.T) {
peers := []string{
peerAddresses := []string{
"localhost:18333",
"localhost:18333",
"localhost:18333",
Expand All @@ -55,13 +55,18 @@ func TestNewPeerManager(t *testing.T) {

peerHandler := NewMockPeerHandler()

for _, peerAddress := range peers {
peers := make([]*Peer, len(peerAddresses))
for i, peerAddress := range peerAddresses {
peer, _ := NewPeer(logger, peerAddress, peerHandler, wire.TestNet)
_ = pm.AddPeer(peer)
defer peer.Shutdown()
peers[i] = peer
}

assert.Len(t, pm.GetPeers(), 4)

for _, peer := range peers {
peer.Shutdown()
}
})
}

Expand All @@ -75,7 +80,6 @@ func TestAnnounceNewTransaction(t *testing.T) {

peer, _ := NewPeerMock("localhost:18333", peerHandler, wire.TestNet)
err := pm.AddPeer(peer)
defer peer.Shutdown()

require.NoError(t, err)

Expand All @@ -87,6 +91,8 @@ func TestAnnounceNewTransaction(t *testing.T) {
announcements := peer.GetAnnouncements()
require.Len(t, announcements, 1)
assert.Equal(t, tx1Hash, announcements[0])

peer.Shutdown()
})

t.Run("announce tx - multiple peers", func(t *testing.T) {
Expand Down Expand Up @@ -123,9 +129,3 @@ func TestAnnounceNewTransaction(t *testing.T) {
assert.GreaterOrEqual(t, peersMessaged, len(peers)/2)
})
}

func TestPeerManager_addPeer(t *testing.T) {
}

func TestPeerManager_sendInvBatch(t *testing.T) {
}

0 comments on commit 4609285

Please sign in to comment.