Skip to content

Commit

Permalink
qa: Remove unused NodeConn members
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Nov 13, 2017
1 parent 5e46899 commit fafdad0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
13 changes: 7 additions & 6 deletions test/functional/p2p-segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def get_virtual_size(witness_block):
return vsize

class TestNode(NodeConnCB):
def __init__(self):
def __init__(self, rpc):
super().__init__()
self.getdataset = set()
self.rpc = rpc

def on_getdata(self, conn, message):
for inv in message.inv:
Expand Down Expand Up @@ -73,7 +74,7 @@ def test_transaction_acceptance(self, tx, with_witness, accepted, reason=None):
tx_message = msg_witness_tx(tx)
self.send_message(tx_message)
self.sync_with_ping()
assert_equal(tx.hash in self.connection.rpc.getrawmempool(), accepted)
assert_equal(tx.hash in self.rpc.getrawmempool(), accepted)
if (reason != None and not accepted):
# Check the rejection reason as well.
with mininode_lock:
Expand All @@ -86,7 +87,7 @@ def test_witness_block(self, block, accepted, with_witness=True):
else:
self.send_message(msg_block(block))
self.sync_with_ping()
assert_equal(self.connection.rpc.getbestblockhash() == block.hash, accepted)
assert_equal(self.rpc.getbestblockhash() == block.hash, accepted)

# Used to keep track of anyone-can-spend outputs that we can use in the tests
class UTXO():
Expand Down Expand Up @@ -1869,11 +1870,11 @@ def test_non_standard_witness(self):
def run_test(self):
# Setup the p2p connections and start up the network thread.
# self.test_node sets NODE_WITNESS|NODE_NETWORK
self.test_node = self.nodes[0].add_p2p_connection(TestNode(), services=NODE_NETWORK|NODE_WITNESS)
self.test_node = self.nodes[0].add_p2p_connection(TestNode(self.nodes[0].rpc), services=NODE_NETWORK|NODE_WITNESS)
# self.old_node sets only NODE_NETWORK
self.old_node = self.nodes[0].add_p2p_connection(TestNode(), services=NODE_NETWORK)
self.old_node = self.nodes[0].add_p2p_connection(TestNode(self.nodes[0].rpc), services=NODE_NETWORK)
# self.std_node is for testing node1 (fRequireStandard=true)
self.std_node = self.nodes[1].add_p2p_connection(TestNode(), services=NODE_NETWORK|NODE_WITNESS)
self.std_node = self.nodes[1].add_p2p_connection(TestNode(self.nodes[1].rpc), services=NODE_NETWORK|NODE_WITNESS)

NetworkThread().start() # Start up network handling in another thread

Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/comptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def add_all_connections(self, nodes):
# Create a p2p connection to each node
test_node = TestNode(self.block_store, self.tx_store)
self.test_nodes.append(test_node)
self.connections.append(NodeConn('127.0.0.1', p2p_port(i), nodes[i], test_node))
self.connections.append(NodeConn('127.0.0.1', p2p_port(i), test_node))
# Make sure the TestNode (callback class) has a reference to its
# associated NodeConn
test_node.add_connection(self.connections[-1])
Expand Down
6 changes: 1 addition & 5 deletions test/functional/test_framework/mininode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,6 @@ def on_ping(self, conn, message):
conn.send_message(msg_pong(message.nonce))

def on_verack(self, conn, message):
conn.ver_recv = conn.ver_send
self.verack_received = True

def on_version(self, conn, message):
Expand Down Expand Up @@ -1516,16 +1515,14 @@ class NodeConn(asyncore.dispatcher):
"regtest": b"\xfa\xbf\xb5\xda", # regtest
}

def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", services=NODE_NETWORK|NODE_WITNESS, send_version=True):
def __init__(self, dstaddr, dstport, callback, net="regtest", services=NODE_NETWORK|NODE_WITNESS, send_version=True):
asyncore.dispatcher.__init__(self, map=mininode_socket_map)
self.dstaddr = dstaddr
self.dstport = dstport
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.sendbuf = b""
self.recvbuf = b""
self.ver_send = 209
self.ver_recv = 209
self.last_sent = 0
self.state = "connecting"
self.network = net
Expand All @@ -1549,7 +1546,6 @@ def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", services=NODE
self.connect((dstaddr, dstport))
except:
self.handle_close()
self.rpc = rpc

def handle_connect(self):
if self.state != "connected":
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def add_p2p_connection(self, p2p_conn, **kwargs):
if 'dstaddr' not in kwargs:
kwargs['dstaddr'] = '127.0.0.1'
self.p2ps.append(p2p_conn)
kwargs.update({'rpc': self.rpc, 'callback': p2p_conn})
kwargs.update({'callback': p2p_conn})
p2p_conn.add_connection(NodeConn(**kwargs))

return p2p_conn
Expand Down

0 comments on commit fafdad0

Please sign in to comment.