Page MenuHomePhabricator

[backport#18727] test: Add CreateWalletFromFile test
ClosedPublic

Authored by majcosta on Jan 26 2021, 17:11.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCa8ce4f8ed85e: [backport#18727] test: Add CreateWalletFromFile test
Summary

7918c1b019a36a8f9aa55daae422c6b6723b2a39 test: Add CreateWalletFromFile test (Russell Yanofsky)

Pull request description:

Add unit test calling CreateWalletFromFile, which isn't currently called from other unit tests, with some basic checks to make sure it rescans and registers for notifications correctly.

Motivation for this change was to try to write a test that would fail without the early `handleNotifications` call in ef8c6ca60767cac589d98ca57ee33179608ccda8 from https://github.com/bitcoin/bitcoin/pull/16426, but succeed with it:

https://github.com/bitcoin/bitcoin/blob/ef8c6ca60767cac589d98ca57ee33179608ccda8/src/wallet/wallet.cpp#L3978-L3986

However, writing a full test for the race condition that call prevents isn't possible without the locking changes from #16426. So this PR just adds as much test coverage as is possible now.

This new test is also useful for https://github.com/bitcoin/bitcoin/pull/15719, since it detects the stale notifications.transactionAddedToMempool notifications that PR eliminates.

Backport of Core PR18727

Test Plan
ninja all check check-functional

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Tail of the build log:

wallet_encryption.py                             | ✓ Passed  | 5 s
wallet_hd.py                                     | ✓ Passed  | 5 s
wallet_import_rescan.py                          | ✓ Passed  | 9 s
wallet_import_with_label.py                      | ✓ Passed  | 1 s
wallet_importdescriptors.py                      | ✓ Passed  | 6 s
wallet_importmulti.py                            | ✓ Passed  | 5 s
wallet_importprunedfunds.py                      | ✓ Passed  | 2 s
wallet_keypool.py                                | ✓ Passed  | 3 s
wallet_keypool_topup.py                          | ✓ Passed  | 3 s
wallet_labels.py                                 | ✓ Passed  | 3 s
wallet_listreceivedby.py                         | ✓ Passed  | 17 s
wallet_listsinceblock.py                         | ✓ Passed  | 6 s
wallet_listtransactions.py                       | ✓ Passed  | 9 s
wallet_multiwallet.py                            | ✓ Passed  | 11 s
wallet_multiwallet.py --usecli                   | ✓ Passed  | 12 s
wallet_reorgsrestore.py                          | ✓ Passed  | 4 s
wallet_resendwallettransactions.py               | ✓ Passed  | 11 s
wallet_txn_clone.py                              | ✓ Passed  | 3 s
wallet_txn_clone.py --mineblock                  | ✓ Passed  | 3 s
wallet_txn_doublespend.py                        | ✓ Passed  | 3 s
wallet_txn_doublespend.py --mineblock            | ✓ Passed  | 3 s
wallet_watchonly.py                              | ✓ Passed  | 1 s
wallet_watchonly.py --usecli                     | ✓ Passed  | 2 s
wallet_zapwallettxes.py                          | ✓ Passed  | 6 s

ALL                                              | ✓ Passed  | 1021 s (accumulated) 
Runtime: 206 s

[28/438] Test Bitcoin RPC authentication...
...
----------------------------------------------------------------------
Ran 3 tests in 0.004s

OK
[30/438] cd /work/contrib/devtools/chainparams && /usr/bin/python3.7 ./test_make_chainparams.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.001s

OK
[182/438] Running avalanche test suite
PASSED: avalanche test suite
[195/438] Running seeder test suite
PASSED: seeder test suite
[200/438] Running bitcoin-qt test suite
PASSED: bitcoin-qt test suite
[203/438] Running pow test suite
PASSED: pow test suite
[372/438] bitcoin: testing wallet_tests
FAILED: src/test/CMakeFiles/check-bitcoin-wallet_tests 
cd /work/abc-ci-builds/build-debug/src/test && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-debug/test/junit && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-debug/test/log && /usr/bin/cmake -E env /work/cmake/utils/log-and-print-on-failure.sh /work/abc-ci-builds/build-debug/test/log/bitcoin-wallet_tests.log /work/abc-ci-builds/build-debug/src/test/test_bitcoin --run_test=wallet_tests --logger=HRF,message:JUNIT,message,bitcoin-wallet_tests.xml --catch_system_errors=no
Running 12 test cases...
Assertion failed: lock ::cs_main not held in ../../src/wallet/test/wallet_tests.cpp:782; locks held:
walletInstance->cs_wallet ../../src/wallet/wallet.cpp:4390 (in thread )
Aborted (core dumped)
[429/438] Running secp256k1 test suite
PASSED: secp256k1 test suite
[435/438] Running utility command for check-bitcoin-coins_tests
ninja: build stopped: cannot make progress due to previous errors.
Build build-debug failed with exit code 1
This revision is now accepted and ready to land.Jan 26 2021, 17:28

investigate failure

updated diff with changes that would've been in PR16426 (and renamed a lambda parameter to avoid a -Wshadow). this solved the build-debug error, but uncovered a TSAN warning. investigating that.

This revision is now accepted and ready to land.Jan 26 2021, 19:09