Skip to content

Conversation

@achow101
Copy link
Member

@achow101 achow101 commented Oct 29, 2020

This PR fixes tests for when BDB is not compiled. Tests which rely on or test legacy wallet behavior are disabled and skipped when BDB is not compiled. For the components of some tests that are for legacy wallet things, those parts of the tests are skipped.

For the majority of tests, changes are made so that they can be run with either legacy wallets or descriptor wallets without materially effecting the test. Most tests only need the wallet for balance and transactions, so the type of wallet is not an important part of those tests. Additionally, some tests are wallet agnostic and modified to instead use the test framework's MiniWallet.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 30, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

Comment on lines 850 to 860
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble figuring out the logic here. Is there a more clear and concise way to determine descriptors?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really.

The purpose of this function is to enable or disable features depending on whether support is compiled and the current settings, for those tests where the descriptors setting is not important to the test and only need to just work.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjdietzx , you can use Quine-McCluskey to derive a minimal function:

>>> from newqm import QM
>>> qm = QM(['A','B','C'])
>>> def aj(a,b,c): # a is self.options.descriptors, b is bdb, c is sqlite compilation
...      descriptors = a
...      if not b and c and not a:
...          descriptors = True
...      elif b and not c and a:
...          descriptors = False
...      return descriptors
... 
>>> from itertools import product
>>> values = [idx for (idx,x) in enumerate(product([False,True], repeat=3)) if aj(*x)]
>>> qm.get_function(qm.solve(values,[])[1])
'(((NOT B) AND C) OR (A AND (NOT B)) OR (A AND C))'

If we color each conjunctive element separately, you can see which elements of the truth table it covers: https://imgur.com/vOVyQP8

Expanded out using the original bindings:

option_set = self.options.descriptors
bdb = self.is_bdb_compiled()
sqlite = self.is_sqlite_compiled()

return ((NOT bdb) AND sqlite) \
  OR (option_set AND (NOT bdb)) \
  OR (option_set AND sqlite)

Comment on lines 783 to 797
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to use self. get_use_descriptors() here? To me it seems like logic might be getting duplicated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, get_use_descriptors() is used to switch between legacy and descriptors for the tests where the type is not explicitly being set. This is different from the wallet tests (that will call this skip_if_no_wallet()) which are testing specific descriptor and legacy behavior.

Comment on lines 1016 to 1021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like usually you're doing: #ifdef USE_BDB ... #elif USE_SQLITE, but here you're doing #ifdef USE_BDB ... #ifdef USE_SQLITE

Should this be consistent, or does it matter? I'm guessing USE_BDB and USE_SQLITE can never both be set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's supposed to #ifdef ... #ifdef because both USE_BDB and USE_SQLITE can both be set, and in fact, is the default.

The instances where #ifdef...#elif is used is only because one wallet type must be defaulted to, and for now, we default to BDB.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, should it be #elif USE_SQLITE here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, if both are compiled, then we need both headers.

Comment on lines +40 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be condensed to a one-liner: check_wallet_filelock(self.is_sqlite_compiled())

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When both are compiled, we want to test both cases.

@maflcko
Copy link
Member

maflcko commented Nov 4, 2020

libbitcoin_wallet.lib(wallet_walletutil.obj) : error LNK2001: unresolved external symbol "bool __cdecl ExistsSQLiteDatabase(class boost::filesystem::path const &)" (?ExistsSQLiteDatabase@@YA_NAEBVpath@filesystem@boost@@@Z) [C:\projects\bitcoin\build_msvc\bench_bitcoin\bench_bitcoin.vcxproj]
The subject line of commit hash 8ea48f202d800895abea798385ac0e67f7f3034d is followed by a non-empty line. Subject lines should always be followed by a blank line.

^---- failure generated from test/lint/lint-git-commit-check.sh

@achow101 achow101 force-pushed the tests-opt-sqlite-bdb branch from 1cae522 to d4a85b6 Compare November 4, 2020 17:36
@achow101
Copy link
Member Author

achow101 commented Nov 4, 2020

Fixed the linter error.

I'm not sure what is causing the appveyor failure, nor how to fix it.

@ryanofsky
Copy link
Contributor

I'm not sure what is causing the appveyor failure, nor how to fix it.

I dug up the old link https://ci.appveyor.com/project/DrahtBot/bitcoin/builds/36097732 and the link errors for unresolved symbols just come from removing wallet/bdb.cpp and wallet/salvage.cpp from original libbitcoin_wallet_a_SOURCES setting in Makefile.am. You might need to add these explicitly to build_msvc/libbitcoin_wallet/libbitcoin_wallet.vcxproj.in. Example of how to do this: 9eaeb7f

Some tests are intended to test only legacy wallet behavior. With
automatic switching of wallet type, we need to make them explicit
Fixes the wallet setup so this test works with descriptor wallets. Also
enabled explicit descriptor and legacy wallet testing in the test
runner.
@achow101
Copy link
Member Author

CI fail looks like an actual issue:

Should be resolved now.

@achow101 achow101 force-pushed the tests-opt-sqlite-bdb branch from 91a364b to a831ba6 Compare January 27, 2021 17:53
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK a831ba6014827d5afc9b423773361350359c94d5. Changes since last review: implementing many review suggestions (thanks!) adding comments, tweaking logic in small ways, and simplifying the PR description. Also dropped rpc_deprecated.py commit 42b627a3a3ab8ee30db5fa3f6b14be5869c2fcfe no longer needed after #20891

Would encourage others to review this. There are a lot of commits but almost all the commits are trivial (make sure to tick the ignore whitespace option).

Two things it would be good to clean up later:

  1. It would be good to remove duplicate code added to wallet_send and feature_notifications tests (#20267 (comment) and #20267 (comment)) that creates different descriptor wallets with the same seeds. From comments it sounds like when more descriptor import stuff is implemented this code can be simplified by reusing existing seeds instead of hardcoding new seeds, but it seems like the tests could be more readable and maintainable even before this if they were refactored to call a common helper function to set up the wallets, instead of adding extra setup to already complicated tests.
  2. IMO, handling of sqlite/bdb test variants is moving in a bad direction here and in followup #20892. I think individual test invocations should be as small and fast as possible, and broken up much as possible. I think invoking a test should run one single variant and test runner should responsible for iterating over variants. Advantages of this approach:
    • Faster debug cycles. Tests that fail faster can be debugged faster. Broken up tests can also be parallelized more.
    • More accurate reporting. There's an increasing number of tests that are skipping checks based on compile options and misleadingly reporting skipped checks as passing. We could fix this by expanding test result status from Passing / Failed / Skipped to include a new Passing but partially skipped status. But it would be clearer to avoid this and to break these tests up so "Passing" can go back to meaning fully passing with no checks skipped.
    • More straightforward usage. A few tests are ignoring descriptor/legacy options which is inconsistent and confusing.
    • More readable code. Smaller tests are easier to understand and debug, and some tests are doing things like repeating code or defining unnecessary functions and calling them twice to cover multiple variants. Tests would be simpler if test_runner managed all the variations, and tests could just obey options instead of listing variants.

@S3RK
Copy link
Contributor

S3RK commented Feb 4, 2021

Started doing review. Have only one small question, but I'll get back with more detailed feedback later

@achow101 achow101 force-pushed the tests-opt-sqlite-bdb branch from a831ba6 to 49797c3 Compare February 4, 2021 17:39
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 49797c3. Only change since last review is dropping last commit. Previous review w/ suggestions for future followup is #20267 (review)

@laanwj
Copy link
Member

laanwj commented Feb 5, 2021

IMO, handling of sqlite/bdb test variants is moving in a bad direction here and in followup #20892. I think individual test invocations should be as small and fast as possible,

Yes, I think so too. And agree it's good if skipping tests is reported explicitly. However I don't think this PR makes this much worse. But yes it does add some if self.is_wallet_compiled():.

ACK 49797c3

@laanwj
Copy link
Member

laanwj commented Feb 5, 2021

UBsan error in the CI (https://github.com/bitcoin/bitcoin/pull/20267/checks?check_run_id=1832884065) is:

test/fuzz/system.cpp:57:159: runtime error: implicit conversion from type 'int' of value -2049 (32-bit, signed) to type 'unsigned int' changed the value to 4294965247 (32-bit, unsigned)

during the fuzz tests. As these are not touched here, I don't think it needs to block merge.

@laanwj laanwj merged commit a6b1bf6 into bitcoin:master Feb 5, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 5, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
Fixes the wallet setup so this test works with descriptor wallets. Also
enabled explicit descriptor and legacy wallet testing in the test
runner.

Github-Pull: bitcoin#20267
Rebased-From: 1194cf9
fanquake added a commit that referenced this pull request Jul 15, 2021
0c845e3 test: Fix wallet_listdescriptors.py if bdb is not compiled (Hennadii Stepanov)

Pull request description:

  If build system is configured `--without-bdb`, the `wallet_listdescriptors.py` fails:
  ```
  $ test/functional/wallet_listdescriptors.py --descriptors
  2021-07-14T13:20:52.931000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_02p7o1c9
  2021-07-14T13:21:23.377000Z TestFramework (INFO): Test that the command is not available for legacy wallets.
  2021-07-14T13:21:23.381000Z TestFramework (ERROR): JSONRPC error
  Traceback (most recent call last):
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/test_framework.py", line 128, in main
      self.run_test()
    File "test/functional/wallet_listdescriptors.py", line 34, in run_test
      node.createwallet(wallet_name='w1', descriptors=False)
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/test_node.py", line 685, in createwallet
      return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup, external_signer)
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/coverage.py", line 47, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/authproxy.py", line 146, in __call__
      raise JSONRPCException(response['error'], status)
  test_framework.authproxy.JSONRPCException: Compiled without bdb support (required for legacy wallets) (-4)
  2021-07-14T13:21:23.436000Z TestFramework (INFO): Stopping nodes
  2021-07-14T13:21:24.092000Z TestFramework (WARNING): Not cleaning up dir /tmp/bitcoin_func_test_02p7o1c9
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/bitcoin_func_test_02p7o1c9/test_framework.log
  2021-07-14T13:21:24.092000Z TestFramework (ERROR):
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): Hint: Call /home/hebasto/GitHub/bitcoin/test/functional/combine_logs.py '/tmp/bitcoin_func_test_02p7o1c9' to consolidate all logs
  2021-07-14T13:21:24.092000Z TestFramework (ERROR):
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
  2021-07-14T13:21:24.092000Z TestFramework (ERROR):
  ```

  This PR fixes this issue.

  Also see #20267.

ACKs for top commit:
  achow101:
    ACK 0c845e3

Tree-SHA512: d7116a9ae30c7b7e3f55f55d2eea66f9e293c38d6757ed66d0477e4256ff5fedca5ddedafa0ef0c09f4dc1f7f973163e5a46090da26b067fdddbd9ea2ee76633
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 23, 2021
…t compiled

0c845e3 test: Fix wallet_listdescriptors.py if bdb is not compiled (Hennadii Stepanov)

Pull request description:

  If build system is configured `--without-bdb`, the `wallet_listdescriptors.py` fails:
  ```
  $ test/functional/wallet_listdescriptors.py --descriptors
  2021-07-14T13:20:52.931000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_02p7o1c9
  2021-07-14T13:21:23.377000Z TestFramework (INFO): Test that the command is not available for legacy wallets.
  2021-07-14T13:21:23.381000Z TestFramework (ERROR): JSONRPC error
  Traceback (most recent call last):
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/test_framework.py", line 128, in main
      self.run_test()
    File "test/functional/wallet_listdescriptors.py", line 34, in run_test
      node.createwallet(wallet_name='w1', descriptors=False)
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/test_node.py", line 685, in createwallet
      return self.__getattr__('createwallet')(wallet_name, disable_private_keys, blank, passphrase, avoid_reuse, descriptors, load_on_startup, external_signer)
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/coverage.py", line 47, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
    File "/home/hebasto/GitHub/bitcoin/test/functional/test_framework/authproxy.py", line 146, in __call__
      raise JSONRPCException(response['error'], status)
  test_framework.authproxy.JSONRPCException: Compiled without bdb support (required for legacy wallets) (-4)
  2021-07-14T13:21:23.436000Z TestFramework (INFO): Stopping nodes
  2021-07-14T13:21:24.092000Z TestFramework (WARNING): Not cleaning up dir /tmp/bitcoin_func_test_02p7o1c9
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/bitcoin_func_test_02p7o1c9/test_framework.log
  2021-07-14T13:21:24.092000Z TestFramework (ERROR):
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): Hint: Call /home/hebasto/GitHub/bitcoin/test/functional/combine_logs.py '/tmp/bitcoin_func_test_02p7o1c9' to consolidate all logs
  2021-07-14T13:21:24.092000Z TestFramework (ERROR):
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
  2021-07-14T13:21:24.092000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
  2021-07-14T13:21:24.092000Z TestFramework (ERROR):
  ```

  This PR fixes this issue.

  Also see bitcoin#20267.

ACKs for top commit:
  achow101:
    ACK 0c845e3

Tree-SHA512: d7116a9ae30c7b7e3f55f55d2eea66f9e293c38d6757ed66d0477e4256ff5fedca5ddedafa0ef0c09f4dc1f7f973163e5a46090da26b067fdddbd9ea2ee76633
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants