mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
qa: Avoid cleanup when exception is raised
If an exception is raised before we get to cleanup, do not swallow it and attempt to reset the state. Doing so could trigger knock-on exceptions and extra tracebacks.
This commit is contained in:
@@ -30,9 +30,8 @@ def weight_to_vsize(weight):
|
||||
|
||||
def cleanup(func):
|
||||
def wrapper(self, *args, **kwargs):
|
||||
try:
|
||||
func(self, *args, **kwargs)
|
||||
finally:
|
||||
|
||||
# Mine blocks to clear the mempool and replenish the wallet's confirmed UTXOs.
|
||||
while (len(self.nodes[0].getrawmempool()) > 0):
|
||||
self.generate(self.nodes[0], 1)
|
||||
|
||||
@@ -29,11 +29,10 @@ TRUC_CHILD_MAX_VSIZE = 1000
|
||||
def cleanup(extra_args=None):
|
||||
def decorator(func):
|
||||
def wrapper(self):
|
||||
try:
|
||||
if extra_args is not None:
|
||||
self.restart_node(0, extra_args=extra_args)
|
||||
func(self)
|
||||
finally:
|
||||
|
||||
# Clear mempool again after test
|
||||
self.generate(self.nodes[0], 1)
|
||||
if extra_args is not None:
|
||||
|
||||
@@ -58,9 +58,8 @@ GETDATA_WAIT = 60
|
||||
|
||||
def cleanup(func):
|
||||
def wrapper(self, *args, **kwargs):
|
||||
try:
|
||||
func(self, *args, **kwargs)
|
||||
finally:
|
||||
|
||||
self.nodes[0].disconnect_p2ps()
|
||||
# Do not clear the node's mempool, as each test requires mempool min feerate > min
|
||||
# relay feerate. However, do check that this is the case.
|
||||
|
||||
@@ -50,9 +50,8 @@ TXREQUEST_TIME_SKIP = NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY + OVERLOADED_PEER
|
||||
|
||||
def cleanup(func):
|
||||
def wrapper(self):
|
||||
try:
|
||||
func(self)
|
||||
finally:
|
||||
|
||||
# Clear mempool
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.nodes[0].disconnect_p2ps()
|
||||
|
||||
@@ -18,9 +18,8 @@ from test_framework.util import (
|
||||
# Decorator to reset activewallet to zero utxos
|
||||
def cleanup(func):
|
||||
def wrapper(self):
|
||||
try:
|
||||
func(self)
|
||||
finally:
|
||||
|
||||
if 0 < self.wallet.getbalances()["mine"]["trusted"]:
|
||||
self.wallet.sendall([self.remainder_target])
|
||||
assert_equal(0, self.wallet.getbalances()["mine"]["trusted"]) # wallet is empty
|
||||
|
||||
@@ -38,10 +38,9 @@ from test_framework.mempool_util import (
|
||||
# sweep alice and bob's wallets and clear the mempool
|
||||
def cleanup(func):
|
||||
def wrapper(self, *args):
|
||||
try:
|
||||
self.generate(self.nodes[0], 1)
|
||||
func(self, *args)
|
||||
finally:
|
||||
|
||||
self.generate(self.nodes[0], 1)
|
||||
for wallet in [self.alice, self.bob]:
|
||||
txs = set(tx["txid"] for tx in wallet.listtransactions("*", 1000) if tx["confirmations"] == 0 and not tx["abandoned"])
|
||||
|
||||
Reference in New Issue
Block a user