forked from Bitcoin-ABC/bitcoin-abc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rare timing-related failures in dsproof functional tests
Summary --- As described in issue Bitcoin-ABC#291, these tests sometimes fail when they shouldn't. The errors turn out to be timing-related. It's possible for e.g. node0 to send the `firstDSTx` to node1 via the p2p network before we can issue the `secondDSTx` to node1 ourselves from the Python side via RPC. When this happens -- the test would throw a `JSONRPCException` for `txn-mempool-conflict`. The fix is to allow for this rare timing-related event and just catch the exception and proceed. In either case (no exception or exception), a dsproof will be generated (which is what we are testing for in this test). In order to implement the fix we extended the `TestNode` interface in the python test framework with a new method, `call_rpc` which takes an optional kwarg `ignore_error=<str>`. If this kwarg is specified, then the test will proceed as normal without raising an exception, should `<std>` match the expected `JSONRPCException` message. Closes issue Bitcoin-ABC#291. Test Plan --- - `ninja all check check-functional` OPTIONAL: - Try and reproduce the failures described in Bitcoin-ABC#291 on master. Then try this MR and see it no longer fail. - May require a similar setup to Bitcoin-ABC#291. - A "poor man's hack" for reproducing Bitcoin-ABC#291 on a non-slow machine would be to add `time.sleep(1)` calls in the bchn-feature-doublespend-proof test manually after `firstDSTx` is sent but before `secondDSTx` is sent (on master). Then, try the same with this MR in the same places and see it never fail.
- Loading branch information
Showing
3 changed files
with
37 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters