Skip to content

Commit 1b51616

Browse files
committed
test: improve rogue calls in mining functions
1 parent 41a2ce9 commit 1b51616

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

test/functional/test_framework/test_framework.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -716,22 +716,22 @@ def no_op(self):
716716
pass
717717

718718
def generate(self, generator, *args, sync_fun=None, **kwargs):
719-
blocks = generator.generate(*args, invalid_call=False, **kwargs)
719+
blocks = generator.generate(*args, called_by_framework=True, **kwargs)
720720
sync_fun() if sync_fun else self.sync_all()
721721
return blocks
722722

723723
def generateblock(self, generator, *args, sync_fun=None, **kwargs):
724-
blocks = generator.generateblock(*args, invalid_call=False, **kwargs)
724+
blocks = generator.generateblock(*args, called_by_framework=True, **kwargs)
725725
sync_fun() if sync_fun else self.sync_all()
726726
return blocks
727727

728728
def generatetoaddress(self, generator, *args, sync_fun=None, **kwargs):
729-
blocks = generator.generatetoaddress(*args, invalid_call=False, **kwargs)
729+
blocks = generator.generatetoaddress(*args, called_by_framework=True, **kwargs)
730730
sync_fun() if sync_fun else self.sync_all()
731731
return blocks
732732

733733
def generatetodescriptor(self, generator, *args, sync_fun=None, **kwargs):
734-
blocks = generator.generatetodescriptor(*args, invalid_call=False, **kwargs)
734+
blocks = generator.generatetodescriptor(*args, called_by_framework=True, **kwargs)
735735
sync_fun() if sync_fun else self.sync_all()
736736
return blocks
737737

test/functional/test_framework/test_node.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,16 @@ def generate(self, nblocks, maxtries=1000000, **kwargs):
352352
self.log.debug("TestNode.generate() dispatches `generate` call to `generatetoaddress`")
353353
return self.generatetoaddress(nblocks=nblocks, address=self.get_deterministic_priv_key().address, maxtries=maxtries, **kwargs)
354354

355-
def generateblock(self, *args, invalid_call, **kwargs):
356-
assert not invalid_call
355+
def generateblock(self, *args, called_by_framework, **kwargs):
356+
assert called_by_framework, "Direct call of this mining RPC is discouraged. Please use one of the self.generate* methods on the test framework, which sync the nodes to avoid intermittent test issues. You may use sync_fun=self.no_op to disable the sync explicitly."
357357
return self.__getattr__('generateblock')(*args, **kwargs)
358358

359-
def generatetoaddress(self, *args, invalid_call, **kwargs):
360-
assert not invalid_call
359+
def generatetoaddress(self, *args, called_by_framework, **kwargs):
360+
assert called_by_framework, "Direct call of this mining RPC is discouraged. Please use one of the self.generate* methods on the test framework, which sync the nodes to avoid intermittent test issues. You may use sync_fun=self.no_op to disable the sync explicitly."
361361
return self.__getattr__('generatetoaddress')(*args, **kwargs)
362362

363-
def generatetodescriptor(self, *args, invalid_call, **kwargs):
364-
assert not invalid_call
363+
def generatetodescriptor(self, *args, called_by_framework, **kwargs):
364+
assert called_by_framework, "Direct call of this mining RPC is discouraged. Please use one of the self.generate* methods on the test framework, which sync the nodes to avoid intermittent test issues. You may use sync_fun=self.no_op to disable the sync explicitly."
365365
return self.__getattr__('generatetodescriptor')(*args, **kwargs)
366366

367367
def setmocktime(self, timestamp):

0 commit comments

Comments
 (0)