This tests an important feature: how the wallet handles changes in transaction history caused by funny business on-chain.
Details
- Reviewers
Fabien bytesofman - Group Reviewers
Restricted Project - Commits
- rABCbfb68bb3d2da: [electrum] add a functional test for a reorg situation
pytest electrumabc/tests/regtest/test_reorg.py
Diff Detail
- Repository
- rABC Bitcoin ABC
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
electrum/electrumabc/tests/regtest/test_reorg.py | ||
---|---|---|
63 ↗ | (On Diff #43079) | $ as a JSONPath means the root element of the JSON response (which here is just a boolean) See https://goessner.net/articles/JsonPath/ for the documentation about JSONPath |
98 ↗ | (On Diff #43079) | Here the RPC call returns a list of dicts. So the JSON path gets the "height" field in the first dict. >>> from jsonpath_ng import parse >>> parse("[0].height") Child(Index(index=0), Fields('height')) |
so is this a case of expected behavior just happening to be how electrum is currently working? Seems kinda fortunate.
The main reason for this test, besides demonstrating that we currently do the right thing, is to give us some more confidence that we are not breaking things when optimizing performance critical codepaths (D14703)
electrum/electrumabc/tests/regtest/test_reorg.py | ||
---|---|---|
81 ↗ | (On Diff #43079) | After reading it until the end I feel like this test would be easier to read if:
|
87 ↗ | (On Diff #43079) | You could make a wait_until() function similar to what the test framework does to avoid code duplication and bugs, e.g. you're missing a time.sleep() in the loop |
92 ↗ | (On Diff #43079) | This could really be a single assert |
95 ↗ | (On Diff #43079) | Block height is == current tip height because the tx is back to mempool ? |
electrum/electrumabc/tests/regtest/test_reorg.py | ||
---|---|---|
81 ↗ | (On Diff #43079) | For now the tests all share a same chain, and can run in any order. When I find a way to restart a clean instance of bitcoind + fulcrum between tests, hardcoding the expected block height will be done. |