diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2024-07-30 17:49:04 -0400 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2024-07-30 17:49:07 -0400 |
commit | ec5e294e4b830766dcc4a80add0613d3705c1794 (patch) | |
tree | 10bb188bae41b2a28365d484037f52d78cca5640 /test/functional/test_framework/messages.py | |
parent | d367a4e36f7357c4ebd018e8e1c9c5071db2e1c2 (diff) |
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.
Diffstat (limited to 'test/functional/test_framework/messages.py')
-rwxr-xr-x | test/functional/test_framework/messages.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 005f7546a8..1f566a1348 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -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) |