mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 05:48:20 +01:00
Merge bitcoin/bitcoin#28199: test: tx orphan handling
9eac5a0529[functional test] transaction orphan handling (glozow)61e77bb901[test framework] make it easier to fast-forward setmocktime (glozow) Pull request description: I was doing some mutation testing (through reckless refactoring) locally and found some specific behaviors in orphan handling that weren't picked up by tests. Adding some of these test cases now can maybe help with reviewing refactors like #28031. - Parent requests aren't sent immediately. A delay is added and the requests are filtered by AlreadyHaveTx before they are sent, which means you can't use fake orphans to probe precise arrival timing of a tx. - Parent requests include all that are not AlreadyHaveTx. This means old confirmed parents may be requested. - The node does not give up on orphans if the peer responds to a parent request with notfound. This means that if a parent is an old confirmed transaction (in which notfound is expected), the orphan should still be resolved. - Rejected parents can cause an orphan to be dropped, but it depends on the reason and only based on txid. - Rejected parents can cause an orphan to be rejected too, by both wtxid and txid. - Requests for orphan parents should be de-duplicated with "regular" txrequest. If a missing parent has the same hash as an in-flight request, it shouldn't be requested. - Multiple orphans with overlapping parents should not cause duplicated parent requests. ACKs for top commit: instagibbs: reACK9eac5a0529dergoegge: reACK9eac5a0529achow101: ACK9eac5a0529fjahr: Code review ACK9eac5a0529Tree-SHA512: 85488dc6a3f62cf0c38e7dfe7839c01215b44b172d1755b18164d41d01038f3a749451241e4eba8b857fd344a445740b21d6382c45977234b21460e3f53b1b2a
This commit is contained in:
@@ -144,6 +144,8 @@ class TestNode():
|
||||
self.p2ps = []
|
||||
self.timeout_factor = timeout_factor
|
||||
|
||||
self.mocktime = None
|
||||
|
||||
AddressKeyPair = collections.namedtuple('AddressKeyPair', ['address', 'key'])
|
||||
PRIV_KEYS = [
|
||||
# address , privkey
|
||||
@@ -324,6 +326,15 @@ class TestNode():
|
||||
assert not invalid_call
|
||||
return self.__getattr__('generatetodescriptor')(*args, **kwargs)
|
||||
|
||||
def setmocktime(self, timestamp):
|
||||
"""Wrapper for setmocktime RPC, sets self.mocktime"""
|
||||
if timestamp == 0:
|
||||
# setmocktime(0) resets to system time.
|
||||
self.mocktime = None
|
||||
else:
|
||||
self.mocktime = timestamp
|
||||
return self.__getattr__('setmocktime')(timestamp)
|
||||
|
||||
def get_wallet_rpc(self, wallet_name):
|
||||
if self.use_cli:
|
||||
return RPCOverloadWrapper(self.cli("-rpcwallet={}".format(wallet_name)), True, self.descriptors)
|
||||
@@ -704,6 +715,13 @@ class TestNode():
|
||||
|
||||
wait_until_helper(lambda: self.num_test_p2p_connections() == 0, timeout_factor=self.timeout_factor)
|
||||
|
||||
def bumpmocktime(self, seconds):
|
||||
"""Fast forward using setmocktime to self.mocktime + seconds. Requires setmocktime to have
|
||||
been called at some point in the past."""
|
||||
assert self.mocktime
|
||||
self.mocktime += seconds
|
||||
self.setmocktime(self.mocktime)
|
||||
|
||||
|
||||
class TestNodeCLIAttr:
|
||||
def __init__(self, cli, command):
|
||||
|
||||
Reference in New Issue
Block a user