test: fix constructor of msg_tx

In python, if the default value is a mutable object (here: a class)
its shared over all instances, so that one instance being changed
would affect others to be changed as well.
This was likely the source of various intermittent bugs in the
functional tests.

Github-Pull: #30552
Rebased-From: ec5e294e4b
This commit is contained in:
Martin Zumsande 2024-07-30 17:49:04 -04:00 committed by Luke Dashjr
parent 9d9c4185fa
commit a845dd03da

View File

@ -993,8 +993,11 @@ class msg_getblocks():
class msg_tx():
command = b"tx"
def __init__(self, tx=CTransaction()):
self.tx = tx
def __init__(self, tx=None):
if tx is None:
self.tx = CTransaction()
else:
self.tx = tx
def deserialize(self, f):
self.tx.deserialize(f)