Skip to content

Commit e4e5605

Browse files
fanquakePastaPastaPasta
authored andcommitted
Merge bitcoin#30552: test: fix constructor of msg_tx
ec5e294 test: fix constructor of msg_tx (Martin Zumsande) Pull request description: In python, if the default value is a mutable object (here: a class) it is shared over all instances, so that one instance being changed would affect others to be changed as well. This was the source of bitcoin#30543, and possibly various other intermittent bugs in the functional tests, see bitcoin#29621 (comment). Fixes bitcoin#30543 Fixes bitcoin#29621 Fixes bitcoin#25128 ACKs for top commit: sipa: utACK ec5e294. I believe some linters even warn about doing this. maflcko: ACK ec5e294 vasild: ACK ec5e294 ❤️ theStack: ACK ec5e294 Tree-SHA512: a6204fb1a326de3f9aa965f345fd658f6a4dcf78731db25cc905ff6eb8d4eeb65d14cc316305eebd89387aec8748c57c3a4f4ca62408f8e5ee53f535b88b1411
1 parent df3c239 commit e4e5605

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/functional/test_framework/messages.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1724,8 +1724,11 @@ class msg_tx:
17241724
__slots__ = ("tx",)
17251725
msgtype = b"tx"
17261726

1727-
def __init__(self, tx=CTransaction()):
1728-
self.tx = tx
1727+
def __init__(self, tx=None):
1728+
if tx is None:
1729+
self.tx = CTransaction()
1730+
else:
1731+
self.tx = tx
17291732

17301733
def deserialize(self, f):
17311734
self.tx.deserialize(f)

0 commit comments

Comments
 (0)