HomePhabricator

[tests] Add generate method to TestNode

Description

[tests] Add generate method to TestNode

Summary:
Adds a generate() method to the TestNode class in the test framework.
This method intercepts calls to generate, imports a dewterministic
private key to the node and then calls generatetoaddress to generate the
block to that address.

Note that repeated calls to importprivkey for the same private keys are
no-ops, so it's fine to call the generate() method many times.

This is a partial backport of Core PR14468 : https://github.com/bitcoin/bitcoin/pull/14468/commits/aab81720de237b258ed4e15f1b1831c11abf74f0

The code was slightly tweaked because we have some tests for which self.rpc is None because they've been created after PR14631 which remove the call to importprivkey

Depends on D5969

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D5970

Details

Provenance
John Newbery <john@johnnewbery.com>Authored on Oct 5 2018, 07:51
deadalnixCommitted on May 6 2020, 13:52
deadalnixPushed on May 6 2020, 13:52
Reviewer
majcosta
Differential Revision
D5970: [tests] Add generate method to TestNode
Parents
rABC2eea6849e381: [tests] Small fixups before deprecating generate
Branches
Unknown
Tags
Unknown