Skip to content

Commit 92eca36

Browse files
mzumsandedenavila
authored andcommitted
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.
1 parent 4bb7f9c commit 92eca36

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/functional/test_framework/messages.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,11 @@ class msg_tx:
12941294
__slots__ = ("tx",)
12951295
msgtype = b"tx"
12961296

1297-
def __init__(self, tx=CTransaction()):
1298-
self.tx = tx
1297+
def __init__(self, tx=None):
1298+
if tx is None:
1299+
self.tx = CTransaction()
1300+
else:
1301+
self.tx = tx
12991302

13001303
def deserialize(self, f):
13011304
self.tx.deserialize(f)

0 commit comments

Comments
 (0)