Skip to content

Commit

Permalink
add comments in python code (#630)
Browse files Browse the repository at this point in the history
* add comments in python code

* fix
  • Loading branch information
sparkmiw authored Sep 9, 2019
1 parent 074264d commit 44705f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/remote_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def run_test(self):
self.log.info("Best block: {}".format(RpcClient(self.nodes[0]).best_block_hash()))

def sync_blocks(self):
"""
Wait for all nodes to reach same block count and best block
"""
self.log.info("wait for all nodes to sync blocks ...")

executor = ThreadPoolExecutor()
Expand Down Expand Up @@ -445,4 +448,4 @@ def run(self):


if __name__ == "__main__":
RemoteSimulate().main()
RemoteSimulate().main()
12 changes: 12 additions & 0 deletions tests/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ def disconnect_nodes(nodes, from_connection, node_num):


def check_handshake(from_connection, target_node_id):
"""
Check whether node 'from_connection' has already
added node 'target_node_id' into its peer set.
"""
peers = from_connection.getpeerinfo()
for peer in peers:
if peer["nodeid"] == target_node_id and len(peer['caps']) > 0:
Expand All @@ -370,6 +374,9 @@ def get_peer_addr(connection):


def connect_nodes(nodes, a, node_num):
"""
Let node[a] connect to node[node_num]
"""
from_connection = nodes[a]
to_connection = nodes[node_num]
key = nodes[node_num].key
Expand Down Expand Up @@ -518,6 +525,11 @@ def checktx(node, tx_hash):


def connect_sample_nodes(nodes, log, sample=3, latency_min=0, latency_max=300, timeout=30):
"""
Establish connections among nodes with each node having 'sample' outgoing peers.
It first lets all the nodes link as a loop, then randomly pick 'sample-1'
outgoing peers for each node.
"""
peer = [[] for _ in nodes]
latencies = [{} for _ in nodes]
threads = []
Expand Down

0 comments on commit 44705f8

Please sign in to comment.