started get new peers test

This commit is contained in:
Kevin F 2022-05-13 00:17:06 -05:00
parent 5bdfbd7c43
commit 2be0175326
3 changed files with 16 additions and 6 deletions

View File

@ -94,13 +94,19 @@ def start_gossip_client():
# transport plugin handles the new peer
add_onionr_thread(
get_new_peers,
120, initial_sleep=5)
60, initial_sleep=120)
# Start a new thread to stream blocks from peers
# These blocks are being diffused and are stored in
# the peer's block database
add_onionr_thread(
stream_from_peers,
3, initial_sleep=10
)
# Blocks we receive or create through all means except
# Diffusal are put into block queues, we decide to either
# stem or diffuse a block from the queue based on the current
# dandelion++ phase
while True:
block_queue_processing()

View File

@ -36,8 +36,8 @@ def _ask_peer(peer):
def get_new_peers():
while not len(gossip_peer_set):
sleep(0.5)
if not len(gossip_peer_set):
raise ValueError("Peer set empty")
# Deep copy the peer list
peer_list: Peer = list(gossip_peer_set)

View File

@ -23,8 +23,7 @@ import onionrblocks
from filepaths import gossip_server_socket_file
from gossip.client import block_queue_processing
from gossip import client
from gossip.blockqueues import gossip_block_queues
from gossip.client import get_new_peers
from gossip.peerset import gossip_peer_set
@ -53,9 +52,14 @@ class MockPeer:
class OnionrGossipClientGetNewPeers(unittest.TestCase):
def test_get_new_peers_no_peers(self):
gossip_peer_set.clear()
self.assertRaises(ValueError, get_new_peers)
def test_get_new_peers(self):
return
p = MockPeer()
gossip_peer_set.add(p)
get_new_peers()
unittest.main()