Skip to content

Commit be96929

Browse files
committed
Merge bitcoin/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 #30543, and possibly various other intermittent bugs in the functional tests, see bitcoin/bitcoin#29621 (comment). Fixes #30543 Fixes #29621 Fixes #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
2 parents 2ed8206 + ec5e294 commit be96929

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)