Skip to content

Commit

Permalink
test: fix constructor of msg_tx
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mzumsande committed Jul 30, 2024
1 parent d367a4e commit ec5e294
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/functional/test_framework/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,8 +1294,11 @@ class msg_tx:
__slots__ = ("tx",)
msgtype = 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)
Expand Down

0 comments on commit ec5e294

Please sign in to comment.