Commit graph

34 commits

Author SHA1 Message Date
Hennadii Stepanov
a0473442d1
scripted-diff: Add __file__ argument to BitcoinTestFramework.init()
-BEGIN VERIFY SCRIPT-
sed -i -e 's/\s*().main\s*()/(__file__).main()/' $(git ls-files test/functional/*.py)
sed -i -e 's/def __init__(self)/def __init__(self, test_file)/' test/functional/test_framework/test_framework.py
-END VERIFY SCRIPT-
2024-07-16 22:06:47 +01:00
Ava Chow
548ecd1155 tests: Test for concurrent writes with db tx
There are occasions where a multi-statement tx is begun in one batch,
and a second batch is created which does a normal write (without a
multi-statement tx). These should not conflict with each other and all
of the data should end up being written to disk.
2024-02-06 12:24:36 -05:00
fanquake
091d29c495
Merge bitcoin/bitcoin#28617: test: Add Wallet Unlock Context Manager
004903ebad test: Add Wallet Unlock Context Manager (Brandon Odiwuor)

Pull request description:

  Fixes #28601, see https://github.com/bitcoin/bitcoin/pull/28403#discussion_r1325426430

  Add Context Manager to manage the locking and unlocking of locked wallets with a passphrase during testing.

ACKs for top commit:
  kevkevinpal:
    lgtm ACK [004903e](004903ebad)
  maflcko:
    lgtm ACK 004903ebad

Tree-SHA512: ab234c167e71531df0d974ff9a31d444f7ce2a1d05aba5ea868cc9452f139845eeb24ca058d88f058bc02482b762adf2d99e63a6640b872cc71a57a0068abfe8
2023-10-19 10:23:44 +01:00
Brandon Odiwuor
004903ebad test: Add Wallet Unlock Context Manager
Add Context Manager to manage wallet locking/unlocking with passphrase
2023-10-10 18:12:31 +03:00
ns-xvrn
bfa0bd632a test: Use pathlib over os.path #28362
revert netutil chgs py3.8 compliant

fixes based on PR review
2023-10-10 09:26:56 -04:00
MarcoFalke
fa28f5a381
test: Bump walletpassphrase timeouts to avoid intermittent issues 2023-10-05 12:57:33 +02:00
Hennadii Stepanov
703b758e18
qa: Close SQLite connection properly
Connection object used as context manager only commits or rollbacks
transactions, so the connection object should be closed manually.

Fixes the following error on Windows:
```
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ...
```
2023-08-02 19:29:01 +01:00
MarcoFalke
fa41614a0a
scripted-diff: Use wallets_path and chain_path where possible
Instead of passing the datadir and chain name to os.path.join, just use
the existing properties, which are the same.

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's|\.datadir, self\.chain, .wallets.|.wallets_path|g' $(git grep -l '\.datadir, self\.chain,')
 sed -i --regexp-extended 's|\.datadir, self\.chain,|.chain_path,|g'            $(git grep -l '\.datadir, self\.chain,')
-END VERIFY SCRIPT-
2023-06-21 08:48:34 +02:00
Sjors Provoost
bd13dc2f46
Switch hardened derivation marker to h in descriptors
This makes it easier to handle descriptor strings manually. E.g. an RPC call that takes an array of descriptors can now use '["desc": ".../0h/..."]'.

Both markers can still be parsed. The default for new descriptors is changed to h. In normalized form h is also used. For private keys the chosen marker is preserved in a round trip.

The hdkeypath field in getaddressinfo is also impacted by this change.
2023-04-04 18:33:08 +02:00
fanquake
7799f53542
Merge bitcoin/bitcoin#26039: refactor: Run type check against RPCArgs (1/2)
fa9f6d7bcd rpc: Run type check against RPCArgs (MarcoFalke)
faf96721a6 test: Fix wrong types passed to RPCs (MarcoFalke)

Pull request description:

  It seems brittle to require `RPCTypeCheck` being called inside the code logic. Without compile-time enforcement this will lead to places where it is forgotten and thus to inconsistencies and bugs. Fix this by removing the calls to `RPCTypeCheck` and doing the check internally.

  The changes should be reviewed as refactoring changes. However, if they change behavior, it will be a bugfix. For example the changes here happen to also detect/fix bugs like the one fixed in commit 3b5fb6e77a.

ACKs for top commit:
  ajtowns:
    ACK fa9f6d7bcd

Tree-SHA512: fb2c0981fe6e24da3ca7dbc06898730779ea4e02ea485458505a281cf421015e44dad0221a04023fc547ea2c660d94657909843fc85d92b847611ec097532439
2023-01-17 09:39:26 +00:00
fanquake
eea73d465e
test: skip sqlite3 tests if it isn't available
Fixes #26819. Related too #26873.
2023-01-12 13:37:15 +00:00
MarcoFalke
faf96721a6
test: Fix wrong types passed to RPCs 2023-01-11 17:41:34 +01:00
Hennadii Stepanov
306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00
Andrew Chow
2ce3d26757
Merge bitcoin/bitcoin#26462: wallet: fix crash on loading descriptor wallet containing legacy key type entries
3198e4239e test: check that loading descriptor wallet with legacy entries throws error (Sebastian Falbesoner)
349ed2a0ee wallet: throw error if legacy entries are present on loading descriptor wallets (Sebastian Falbesoner)

Pull request description:

  Loading a descriptor wallet currently leads to a segfault if a legacy key type entry is present that can be deserialized successfully and needs SPKman-interaction. To reproduce with a "cscript" entry (see second commit for details):

  ```
  $ ./src/bitcoin-cli createwallet crashme
  $ ./src/bitcoin-cli unloadwallet crashme
  $ sqlite3 ~/.bitcoin/wallets/crashme/wallet.dat
  SQLite version 3.38.2 2022-03-26 13:51:10
  Enter ".help" for usage hints.
  sqlite> INSERT INTO main VALUES(x'07637363726970740000000000000000000000000000000000000000', x'00');
  $ ./src/bitcoin-cli loadwallet crashme

  --- bitcoind output: ---
  2022-11-06T13:51:01Z Using SQLite Version 3.38.2
  2022-11-06T13:51:01Z Using wallet /home/honey/.bitcoin/wallets/crashme
  2022-11-06T13:51:01Z init message: Loading wallet…
  2022-11-06T13:51:01Z [crashme] Wallet file version = 10500, last client version = 249900

  Segmentation fault (core dumped)
  ```

  Background: In the wallet key-value-loading routine, most legacy type entries require a `LegacyScriptPubKeyMan` instance after successful deserialization. On a descriptor wallet, creating that (via method `GetOrCreateLegacyScriptPubKeyMan`) fails and then leads to a null-pointer dereference crash. E.g. for CSCRIPT: 50422b770a/src/wallet/walletdb.cpp (L589-L594)

  ~~This PR fixes this by simply ignoring legacy entries if the wallet flags indicate that we have a descriptor wallet. The second commits adds a regression test to the descriptor wallet's functional test (fortunately Python includes sqlite3 support in the standard library).~~

  ~~Probably it would be even better to throw a warning to the user if unexpected legacy entries are found in descriptor wallets, but I think as a first mitigation everything is obvisouly better than crashing. As far as I'm aware, descriptor wallets created/migrated by Bitcoin Core should never end up in a state containing legacy type entries though.~~

  This PR fixes this by throwing an error if legacy entries are found in descriptor wallets on loading.

ACKs for top commit:
  achow101:
    ACK 3198e4239e
  aureleoules:
    ACK 3198e4239e

Tree-SHA512: ee43da3f61248e0fde55d9a705869202cb83df678ebf4816f0e77263f0beac0d7bae9490465d1753159efb093ee37182931d76b2e2b6e8c6f8761285700ace1c
2022-12-05 17:37:48 -05:00
MacroFake
555519d082
test: Remove wallet option from non-wallet tests
Review note: The changes are complete, because self.options.descriptors
is set to None in parse_args (test_framework.py).

A value of None implies -disablewallet, see the previous commit.

So if a call to add_wallet_options is missing, it will lead to a test
failure when the wallet is compiled in.
2022-11-10 17:19:13 +01:00
Sebastian Falbesoner
887d85e43d test: add missing bech32m / BIP86 test-cases to wallet_descriptor.py 2022-11-08 18:43:39 +01:00
Sebastian Falbesoner
3198e4239e test: check that loading descriptor wallet with legacy entries throws error 2022-11-08 12:29:16 +01:00
BrokenProgrammer
e3609cdc01 doc: Update importaddress mention incompatibility with descriptor wallet 2022-06-14 20:54:45 +02:00
Andrew Chow
8fb57845ee Create a tr() descriptor bech32m DescriptorScriptPubKeyMan by default 2021-11-16 12:20:13 -05:00
MarcoFalke
fac23c2114
scripted-diff: Bump copyright headers
The previous diff touched most files in ./test/, so bump the headers to
avoid having to touch them again for a bump later.

-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2021-11-10 11:10:24 +01:00
MarcoFalke
fac7f6102f
test: Use generate* node RPC, not wallet RPC 2021-10-06 13:39:44 +02:00
MarcoFalke
fab2e23b57
Use generate* from TestFramework
The changes in feature_rbf can be reviewed with
--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2021-08-19 19:02:11 +02:00
Kiminuo
bfa9309ad6 Use COINBASE_MATURITY constant in functional tests. 2021-05-31 07:32:28 +02:00
Samuel Dobson
db656db2ed
Merge #19136: wallet: add parent_desc to getaddressinfo
de6b389d5d tests: Test getaddressinfo parent_desc (Andrew Chow)
e4ac869a0a rpc: Add parent descriptor to getaddressinfo output (Andrew Chow)
bbe4a36152 wallet: Add GetDescriptorString to DescriptorScriptPubKeyMan (Andrew Chow)
9be1437c49 descriptors: Add ToNormalizedString and tests (Andrew Chow)

Pull request description:

  Adds `parent_desc` field to the `getaddressinfo` RPC to export a public descriptor. Using the given address, `getaddressinfo` will look up which `DescriptorScriptPubKeyMan` can be used to produce that address. It will then return the descriptor for that `DescriptorScriptPubKeyMan` in the `parent_desc` field. The descriptor will be in a normalized form where the xpub at the last hardened step is derived so that the descriptor can be imported to other wallets. Tests are added to check that the correct descriptor is being returned for the wallet's addresses and that these descriptors can be imported and used in other wallets.

  As part of this PR, a `ToNormalizedString` function is added to the descriptor classes. This really only has an effect on `BIP32PubkeyProvider`s that have hardened derivation steps. Tests are added to check that normalized descriptors are returned.

ACKs for top commit:
  Sjors:
    utACK de6b389d5d
  S3RK:
    Tested ACK de6b389
  jonatack:
    Tested ACK de6b389d5d modulo a few minor comments
  fjahr:
    Code review ACK de6b389d5d
  meshcollider:
    Tested ACK de6b389d5d

Tree-SHA512: a633e4a39f2abbd95afd7488484cfa66fdd2651dac59fe59f2b80a0940a2a4a13acf889c534a6948903d701484a2ba1218e3081feafe0b9a720dccfa9e43ca2b
2021-02-18 21:51:16 +13:00
Andrew Chow
1f20cac9d4 Disable wallet_descriptor.py bdb format check if BDB is not compiled 2021-01-27 12:52:46 -05:00
MarcoFalke
fa0074e2d8
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2020-12-31 09:45:41 +01:00
Andrew Chow
7411876c75 Ensure a legacy wallet for BDB format check 2020-10-29 14:59:29 -04:00
Andrew Chow
586640381a Skip --descriptor tests if sqlite is not compiled 2020-10-29 12:34:16 -04:00
Jon Atack
624bab00dd
test: add coverage for getwalletinfo format field 2020-10-15 16:46:34 +02:00
Andrew Chow
de6b389d5d tests: Test getaddressinfo parent_desc 2020-10-09 09:04:18 -04:00
Russell Yanofsky
ed3acda33b test, refactor: add default_wallet_name and wallet_data_filename variables
No changes in behavior
2020-09-29 04:35:01 -04:00
Sebastian Falbesoner
dac7a111bd refactor: test: use _ variable for unused loop counters
substitutes "for x in range(N):" by "for _ in range(N):"
indicates to the reader that a block is just repeated N times, and
that the loop counter is not used in the body
2020-08-06 18:39:33 +02:00
Andrew Chow
869f7ab30a tests: Add RPCOverloadWrapper which overloads some disabled RPCs
RPCOverloadWrapper overloads some deprecated or disabled RPCs with
an implementation using other RPCs to avoid having a ton of code churn
around replacing those RPCs.
2020-04-23 13:59:48 -04:00
Andrew Chow
1346e14831 Functional tests for descriptor wallets 2020-04-23 13:59:48 -04:00