Summary:
- Primary: Adds a
debug_only=trueflag for peertimeout, defaults to 60 sec., the current hard-coded setting. - Secondary: Drastically speeds up
p2p_timeout.pytest. - Secondary: Tests that the correct code path is being tested by adding log assertions to the test.
Rationale:
- P2P timeout was hard-coded: make it explicitly specified and configurable, instead of a magic number.
- Addresses #13518;
p2p_timeout.pytakes 4 sec. to run instead of 61 sec. - Makes
p2p_timeout.pymore explicit. Previously, we relied on a comment to inform us of the timeout amount being tested. Now it is specified directly in the test via passing in the new arg;-peertimeout=3. - Opens us up to testing more P2P scenarios; oftentimes slow tests are the reason we don't test.
Locally verified changes:
With Proposed Change (4.7 sec.):
$ time ./test/functional/p2p_timeouts.py
2018-11-19T00:04:19.077000Z TestFramework (INFO): Initializing test directory /tmp/testhja7g2n7
2018-11-19T00:04:23.479000Z TestFramework (INFO): Stopping nodes
2018-11-19T00:04:23.683000Z TestFramework (INFO): Cleaning up /tmp/testhja7g2n7 on exit
2018-11-19T00:04:23.683000Z TestFramework (INFO): Tests successful
real 0m4.743s
Currently on master (62.8 sec.):
$ time ./test/functional/p2p_timeouts.py
2018-11-19T00:06:10.948000Z TestFramework (INFO): Initializing test directory /tmp/test6mo6k21h
2018-11-19T00:07:13.376000Z TestFramework (INFO): Stopping nodes
2018-11-19T00:07:13.631000Z TestFramework (INFO): Cleaning up /tmp/test6mo6k21h on exit
2018-11-19T00:07:13.631000Z TestFramework (INFO): Tests successful
real 1m2.836s
Error message demonstrated for new argument -peertimeout:
$ ./bitcoind -peertimeout=-5
...
Error: peertimeout cannot be configured with a negative value.