mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-13 10:24:40 +02:00
test: Make msg_tx a witness tx
This commit is contained in:
@ -31,7 +31,7 @@ from test_framework.messages import (
|
|||||||
msg_inv,
|
msg_inv,
|
||||||
msg_tx,
|
msg_tx,
|
||||||
msg_block,
|
msg_block,
|
||||||
msg_witness_tx,
|
msg_no_witness_tx,
|
||||||
ser_uint256,
|
ser_uint256,
|
||||||
ser_vector,
|
ser_vector,
|
||||||
sha256,
|
sha256,
|
||||||
@ -125,10 +125,11 @@ def test_transaction_acceptance(node, p2p, tx, with_witness, accepted, reason=No
|
|||||||
- use the getrawmempool rpc to check for acceptance."""
|
- use the getrawmempool rpc to check for acceptance."""
|
||||||
reason = [reason] if reason else []
|
reason = [reason] if reason else []
|
||||||
with node.assert_debug_log(expected_msgs=reason):
|
with node.assert_debug_log(expected_msgs=reason):
|
||||||
p2p.send_message(msg_witness_tx(tx) if with_witness else msg_tx(tx))
|
p2p.send_message(msg_tx(tx) if with_witness else msg_no_witness_tx(tx))
|
||||||
p2p.sync_with_ping()
|
p2p.sync_with_ping()
|
||||||
assert_equal(tx.hash in node.getrawmempool(), accepted)
|
assert_equal(tx.hash in node.getrawmempool(), accepted)
|
||||||
|
|
||||||
|
|
||||||
def test_witness_block(node, p2p, block, accepted, with_witness=True, reason=None):
|
def test_witness_block(node, p2p, block, accepted, with_witness=True, reason=None):
|
||||||
"""Send a block to the node and check that it's accepted
|
"""Send a block to the node and check that it's accepted
|
||||||
|
|
||||||
@ -311,9 +312,9 @@ class SegWitTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# Check that serializing it with or without witness is the same
|
# Check that serializing it with or without witness is the same
|
||||||
# This is a sanity check of our testing framework.
|
# This is a sanity check of our testing framework.
|
||||||
assert_equal(msg_tx(tx).serialize(), msg_witness_tx(tx).serialize())
|
assert_equal(msg_no_witness_tx(tx).serialize(), msg_tx(tx).serialize())
|
||||||
|
|
||||||
self.test_node.send_message(msg_witness_tx(tx))
|
self.test_node.send_message(msg_tx(tx))
|
||||||
self.test_node.sync_with_ping() # make sure the tx was processed
|
self.test_node.sync_with_ping() # make sure the tx was processed
|
||||||
assert tx.hash in self.nodes[0].getrawmempool()
|
assert tx.hash in self.nodes[0].getrawmempool()
|
||||||
# Save this transaction for later
|
# Save this transaction for later
|
||||||
|
@ -1105,17 +1105,17 @@ class msg_tx:
|
|||||||
self.tx.deserialize(f)
|
self.tx.deserialize(f)
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
return self.tx.serialize_without_witness()
|
return self.tx.serialize_with_witness()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "msg_tx(tx=%s)" % (repr(self.tx))
|
return "msg_tx(tx=%s)" % (repr(self.tx))
|
||||||
|
|
||||||
|
|
||||||
class msg_witness_tx(msg_tx):
|
class msg_no_witness_tx(msg_tx):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
return self.tx.serialize_with_witness()
|
return self.tx.serialize_without_witness()
|
||||||
|
|
||||||
|
|
||||||
class msg_block:
|
class msg_block:
|
||||||
|
Reference in New Issue
Block a user