HomePhabricator

Remove func test code duplication

Description

Remove func test code duplication

Summary:
Backport of core's PR10169

Depends on D977

From 52e15aa4d067fc4ace12c80be5c82e85c04fcfec :

Adds helper functions to NodeConnCB

This commit adds some helper functions to NodeConnCB which are useful
for many tests:

  • NodeConnCB now keeps track of the number of each message type that

it's received and the most recent message of each type. Many tests
assert on the most recent block, tx or reject message.

  • NodeConnCB now keeps track of its connection state by setting a

connected boolean in on_open() and on_close()

  • NodeConnCB now has wait_for_block, wait_for_getdata,

wait_for_getheaders, wait_for_inv and wait_for_verack methods

I have updated the individual test cases to make sure that there are no
namespace problems that cause them to fail with these new definitions.
Future commits will remove the duplicate code.

From 2a52ae63bfdde948250df1c876dcdd5af99f03b5 :

Remove duplicate method definitions in NodeConnCB subclasses

All Node classes in individual test cases subclass from NodeConnCB. Many
have duplicate definitions for methods that are defined in the base
class. This commit removes those duplicate definitions.

This commit removes ~290 lines of duplicate code.

Test Plan:

make check
./test/functional/test_runner.py

Reviewers: #bitcoin_abc, schancel

Reviewed By: #bitcoin_abc, schancel

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

Details

Provenance
John Newbery <john@johnnewbery.com>Authored on Mar 29 2017, 18:07
deadalnixCommitted on Jan 19 2018, 15:40
deadalnixPushed on Jan 19 2018, 15:40
Reviewer
Restricted Project
Differential Revision
D978: Remove func test code duplication
Parents
rABC5b42e167f51f: Kill OutputChecker, use assert_start_raises_init_error instead
Branches
Unknown
Tags
Unknown

Event Timeline