|
|
@ -32,9 +32,10 @@ def get_virtual_size(witness_block): |
|
|
|
return vsize |
|
|
|
return vsize |
|
|
|
|
|
|
|
|
|
|
|
class TestNode(NodeConnCB): |
|
|
|
class TestNode(NodeConnCB): |
|
|
|
def __init__(self): |
|
|
|
def __init__(self, rpc): |
|
|
|
super().__init__() |
|
|
|
super().__init__() |
|
|
|
self.getdataset = set() |
|
|
|
self.getdataset = set() |
|
|
|
|
|
|
|
self.rpc = rpc |
|
|
|
|
|
|
|
|
|
|
|
def on_getdata(self, conn, message): |
|
|
|
def on_getdata(self, conn, message): |
|
|
|
for inv in message.inv: |
|
|
|
for inv in message.inv: |
|
|
@ -73,7 +74,7 @@ class TestNode(NodeConnCB): |
|
|
|
tx_message = msg_witness_tx(tx) |
|
|
|
tx_message = msg_witness_tx(tx) |
|
|
|
self.send_message(tx_message) |
|
|
|
self.send_message(tx_message) |
|
|
|
self.sync_with_ping() |
|
|
|
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): |
|
|
|
if (reason != None and not accepted): |
|
|
|
# Check the rejection reason as well. |
|
|
|
# Check the rejection reason as well. |
|
|
|
with mininode_lock: |
|
|
|
with mininode_lock: |
|
|
@ -86,7 +87,7 @@ class TestNode(NodeConnCB): |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.send_message(msg_block(block)) |
|
|
|
self.send_message(msg_block(block)) |
|
|
|
self.sync_with_ping() |
|
|
|
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 |
|
|
|
# Used to keep track of anyone-can-spend outputs that we can use in the tests |
|
|
|
class UTXO(): |
|
|
|
class UTXO(): |
|
|
@ -1869,11 +1870,11 @@ class SegWitTest(BitcoinTestFramework): |
|
|
|
def run_test(self): |
|
|
|
def run_test(self): |
|
|
|
# Setup the p2p connections and start up the network thread. |
|
|
|
# Setup the p2p connections and start up the network thread. |
|
|
|
# self.test_node sets NODE_WITNESS|NODE_NETWORK |
|
|
|
# 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 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 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 |
|
|
|
NetworkThread().start() # Start up network handling in another thread |
|
|
|
|
|
|
|
|
|
|
|