Commit graph

983 commits

Author SHA1 Message Date
MacroFake
faeea28753
test: Avoid race in disconnect_nodes helper 2022-09-20 15:48:05 +02:00
glozow
5291933fed
Merge bitcoin/bitcoin#25768: wallet: Properly rebroadcast unconfirmed transaction chains
3405f3eed5 test: Test that an unconfirmed not-in-mempool chain is rebroadcast (Andrew Chow)
10d91c5abe wallet: Deduplicate Resend and ReacceptWalletTransactions (Andrew Chow)

Pull request description:

  Currently `ResendWalletTransactions` (used for normal rebroadcasts) will attempt to rebroadcast all of the transactions in the wallet in the order they are stored in `mapWallet`. This ends up being random as `mapWallet` is a `std::unordered_map`. However `ReacceptWalletTransactions` (used for adding to the mempool on loading) first sorts the txs by wallet insertion order, then submits them. The result is that `ResendWalletTranactions` will fail to rebroadcast child transactions if their txids happen to be lexicographically less than their parent's txid. This PR resolves this issue by combining `ReacceptWalletTransactions` and `ResendWalletTransactions` into a new `ResubmitWalletTransactions` so that the iteration code and basic checks are shared.

  A test has also been added that checks that such transaction chains are rebroadcast correctly.

ACKs for top commit:
  naumenkogs:
    utACK 3405f3eed5
  1440000bytes:
    reACK 3405f3eed5
  furszy:
    Late code review ACK 3405f3ee
  stickies-v:
    ACK 3405f3eed5

Tree-SHA512: 1240d9690ecc2ae8d476286b79e2386f537a90c41dd2b8b8a5a9c2a917aa3af85d6aee019fbbb05e772985a2b197e2788305586d9d5dac78ccba1ee5aa31d77a
2022-09-05 13:54:36 +01:00
Andrew Chow
3405f3eed5 test: Test that an unconfirmed not-in-mempool chain is rebroadcast
The test checks that parent txs are broadcast before child txs.

The previous behavior is that the rebroadcasting would simply iterate mapWallet. As
mapWallet is a std::unsorted_map, the child can sometimes come before the parent and thus
be rebroadcast in the wrong order and fail the test.
2022-08-29 12:41:50 -04:00
Jon Atack
45f9282162 Create BCLog::Level::Trace log severity level
for verbose log messages for development or debugging only, as bitcoind may run
more slowly, that are more granular/frequent than the Debug log level, i.e. for
very high-frequency, low-level messages to be logged distinctly from
higher-level, less-frequent debug logging that could still be usable in production.

An example would be to log higher-level peer events (connection, disconnection,
misbehavior, eviction) as Debug, versus Trace for low-level, high-volume p2p
messages in the BCLog::NET category. This will enable the user to log only the
former without the latter, in order to focus on high-level peer management events.

With respect to the name, "trace" is suggested as the most granular level
in resources like the following:
- https://sematext.com/blog/logging-levels
- https://howtodoinjava.com/log4j2/logging-levels

Update the test framework and add test coverage.
2022-08-20 11:55:17 +02:00
klementtan
8fe3457dbb Update LogAcceptCategory() and unit tests with log severity levels
Co-authored-by: "Jon Atack <jon@atack.com>"
2022-08-20 11:30:51 +02:00
w0xlt
8b3d2bbd0d
test: add tests for datacarrier and datacarriersize options
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
2022-08-11 12:05:09 -03:00
Sebastian Falbesoner
b4a5ab96b4 test: refactor: deduplicate DEFAULT_{ANCESTOR,DESCENDANT}_LIMIT constants 2022-08-09 15:22:38 +02:00
Andrew Chow
35305c759a
Merge bitcoin/bitcoin#22751: rpc/wallet: add simulaterawtransaction RPC
db10cf8ae3 rpc/wallet: add simulaterawtransaction RPC (Karl-Johan Alm)
701a64f548 test: add support for Decimal to assert_approx (Karl-Johan Alm)

Pull request description:

  (note: this was originally titled "add analyzerawtransaction RPC")

  This command iterates over the inputs and outputs of the given transactions, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally.

  I originally proposed this to Elements (https://github.com/ElementsProject/elements/pull/1016) and it was suggested that I propose this upstream.

  There is an alternative #22776 to instead add this info to `getbalances` when providing an optional transaction as argument.

ACKs for top commit:
  jonatack:
    ACK db10cf8ae3
  achow101:
    re-ACK db10cf8ae3

Tree-SHA512: adf222ec7dcdc068d007ae6f465dbc35b692dc7bb2db337be25340ad0c2f9c64cfab4124df23400995c700f41c83c29a2c34812121782c26063b100c7969b89d
2022-08-05 15:19:03 -04:00
MacroFake
fa2537cf0a
test: Target exact weight in MiniWallet _bulk_tx
Also, replace broad -acceptnonstdtxn=1 with -datacarriersize=100000
2022-08-03 12:02:20 +02:00
Karl-Johan Alm
701a64f548
test: add support for Decimal to assert_approx 2022-08-02 10:11:12 +09:00
Andreas Kouloumos
f2f6068b69 test: MiniWallet: add send_self_transfer_chain to create chain of txns
With this new method, a chain of transactions can be created. This
method is introduced to further simplify the mempool_package_limits.py
tests.
2022-08-01 19:11:36 +03:00
Andreas Kouloumos
1d6b438ef0 test: use MiniWallet to simplify mempool_package_limits.py tests
Moved `bulk_transaction` into MiniWallet class as `_bulk_tx` private
helper method to be used when the newly added `target_weight` option is
passed to `create_self_transfer*`
2022-08-01 19:11:35 +03:00
Sebastian Falbesoner
2a428c7989 test: support passing PSBTMaps directly to PSBT ctor
This will allow to create simple PSBTs as short one-liners, without the
need to have three individual assignments (globals, inputs, outputs).
2022-07-23 08:48:08 +02:00
Sebastian Falbesoner
faf43378e2 refactor: move helper random_bytes to util library
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19 17:42:35 +02:00
Sebastian Falbesoner
fdc1ca3896 test: add constants for PSBT key types (BIP 174)
Also take use of the constants in the signet miner to get rid of
magic numbers and increase readability and maintainability.
2022-07-19 15:40:51 +02:00
Sebastian Falbesoner
1b035c03f9 refactor: move PSBT(Map) helpers from signet miner to test framework
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19 15:40:51 +02:00
Sebastian Falbesoner
7c0dfec2dd refactor: move from_binary helper from signet miner to test framework
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19 15:40:51 +02:00
MacroFake
fa0404dbb7
scripted-diff: [test] Rename BIP125_SEQUENCE_NUMBER to MAX_BIP125_RBF_SEQUENCE
-BEGIN VERIFY SCRIPT-
 sed -i 's:BIP125_SEQUENCE_NUMBER:MAX_BIP125_RBF_SEQUENCE:g' $(git grep -l BIP125_SEQUENCE_NUMBER ./test)
-END VERIFY SCRIPT-
2022-07-12 18:49:08 +02:00
Sebastian Falbesoner
6cbe65c5d7 test: refactor: pass absolute fee in create_lots_of_big_transactions helper 2022-07-10 13:09:51 +02:00
MacroFake
fa5059b7df
test: Make the scriptPubKey of MiniWallet created txs mutable
This makes individual bytes of the scriptPubKey mutable, previously it
could only be re-assigned as a whole.
2022-07-01 12:29:23 +02:00
MacroFake
fa29245827
test: Allow setting sequence per input in MiniWallet create_self_transfer_multi
Previously it was only possible to set the same sequence in all inputs
2022-07-01 12:29:22 +02:00
MacroFake
fac3800d2c
test: Allow amount_per_output in MiniWallet create_self_transfer_multi 2022-07-01 12:29:14 +02:00
MacroFake
2222842ae7
test: Allow absolute fee in MiniWallet create_self_transfer 2022-07-01 12:29:00 +02:00
MacroFake
5d68d6840d
Merge bitcoin/bitcoin#25364: test: remove wallet dependency from feature_nulldummy.py
50ba6697f3 remove unused functions (Ayush Sharma)
eec23dad1e test: remove wallet dependency from feature_nulldummy.py (Ayush Sharma)

Pull request description:

  This PR enables one of the non-wallet functional tests (`feature_nulldummy.py`) to be run even with the Bitcoin Core wallet disabled.

  Commit 1: removes wallet dependency and `test_runner.py` is edited to make sure the test only runs once.
  Commit 2: the functions `create_transaction()` and `create_raw_transaction()` in `blocktools.py` are no longer needed and hence removed.

ACKs for top commit:
  kouloumos:
    re-ACK 50ba6697f3, all comments have been addressed.

Tree-SHA512: 3bc3d2766e53dba3d56a03f2c476442608ac693f51d84f4632a22a2cf169bc02c10bf92b676f7d57acb4f0ad86f307d37ab63f936b44b3585ee3c9d08cd0335f
2022-06-30 17:39:45 +02:00
Sebastian Falbesoner
b1ba3ed155 test: let gen_return_txouts create a single large OP_RETURN output
Transactions with more than one datacarrier (OP_RETURN) output
are never considered standard, i.e. this change is necessary in
order to to get rid of the `acceptnonstdtxn` option for some
tests.
2022-06-29 17:42:51 +02:00
Sebastian Falbesoner
f319287d81 test: assert serialized txouts size of gen_return_txouts helper
This assures that changing the internals of the helper function
still leads to the expected outcome sizewise (preparation for the
next commit).
2022-06-29 17:28:33 +02:00
Andrew Chow
b80de4c505 test: Test signing psbts without explicitly having scripts 2022-06-27 16:48:04 -04:00
MacroFake
fa13375aa3
test: Sync MiniWallet utxo state after each generate call 2022-06-27 11:08:50 +02:00
MacroFake
dddd7c4d39
test: Drop spent utxos in MiniWallet scan_tx 2022-06-27 11:08:29 +02:00
MacroFake
fa04ff61b6
test: Return new_utxos from create_self_transfer_multi in MiniWallet 2022-06-27 11:07:34 +02:00
MacroFake
fa34e44e98
test: Return new_utxo from create_self_transfer in MiniWallet 2022-06-27 11:07:29 +02:00
Ayush Sharma
50ba6697f3 remove unused functions
the functions `create_transaction()` and `create_raw_transaction()` were no longer used hence removed.
2022-06-24 18:04:48 +05:30
MacroFake
faee330c7b
test: Fail if connect_nodes fails
Also replace the use of wait_until_helper, which is not allowed to be
called directly. Otherwise, --timeout-factor will not be honoured.
2022-06-22 09:15:33 +02:00
MacroFake
fa8421bc5b
test: Remove from_node from create_self_transfer* MiniWallet helpers
The from_node argument is no longer used as of commit
a55606c3bd
2022-06-21 12:02:01 +02:00
Sebastian Falbesoner
be8d0dba15 test: refactor: save MiniWallet mode explicitly
Rather than abusing the member variables self._priv_key and
self._address to determine the MiniWallet mode, save it explicitly
instead in the constructor to increase the readability and
maintainability of the code.
2022-06-21 10:54:42 +02:00
laanwj
f8586b25f6
Merge bitcoin/bitcoin#25289: test: implement 'bech32m' mode for getnewdestination() helper
dcf36fe8e3 test: implement 'bech32m' mode for `getnewdestination()` helper (Sebastian Falbesoner)
1999dcfa40 test: add helpers for creating P2TR scripts/addresses from output key (Sebastian Falbesoner)

Pull request description:

  This PR adds the missing 'bech32m' mode for the `getnewdestination()` helper and sets it as default, i.e. the function returns a tuple (output x-only-pubkey, scriptPubKey, taproot address) now if not specified otherwise. In a preparation commit, the helpers `output_key_to_p2tr{_script}` are introduced. Note that in contrast to all other common script output types, there are usually _two_ keys involved in creating a taproot output (internal key and output key), hence the prefix `output_` is used to clarify that the  output key is expected and the helpers don't do any key tweaking.

  Thanks to michaelfolkson (for pointing out this TODO that I forgot about) and sipa (for patiently explaining basic things about BIP341).

ACKs for top commit:
  michaelfolkson:
    ACK dcf36fe8e3
  w0xlt:
    reACK dcf36fe8e3

Tree-SHA512: 5bb8d5fd96c63092ede10c3f022ffb2e13c14e333c4aa73348d95deb70cbf0a74745218dc4a7c419eb846793dd69e8217a7b4332a13ae2b2758e100b51fb1a9f
2022-06-17 22:51:42 +02:00
Sebastian Falbesoner
42b2fdfd5f test: remove unused create_confirmed_utxos helper
Confirmed UTXOs in functional tests can simply be created by using
MiniWallet's `send_self_transfer_multi` method with a subsequent
`generate` call to mine a block.
2022-06-15 00:58:02 +02:00
Sebastian Falbesoner
dcf36fe8e3 test: implement 'bech32m' mode for getnewdestination() helper 2022-06-14 13:37:18 +02:00
Sebastian Falbesoner
1999dcfa40 test: add helpers for creating P2TR scripts/addresses from output key 2022-06-14 13:32:57 +02:00
MacroFake
fa779de665
test: Remove MiniWallet mempool_valid option 2022-06-13 18:09:16 +02:00
MacroFake
506d9b25a3
Merge bitcoin/bitcoin#24839: test: use MiniWallet for mining_prioritisetransaction.py
b167e536d0 test: refactor: use `create_lots_of_big_transactions` to dedup where possible (Sebastian Falbesoner)
8973eeb412 test: use MiniWallet for mining_prioritisetransaction.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (mining_prioritisetransaction.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in #20078. Note that the adapted helper function `create_lots_of_big_transactions` is currently only used in this test, i.e. there was no need to change any others.

ACKs for top commit:
  ayush933:
    tACK b167e53
  danielabrozzoni:
    tACK b167e536d0
  kouloumos:
    ACK b167e536d0
  furszy:
    ACK b167e536

Tree-SHA512: ccae20d7d414a720efdeea9c2ae399aa53a3a0e7db72bff8d0cb75d90621a7ae7c019ba68d24f9d06f7b111f87ff33bb9d8e5aa08b763e606cf10268780e205c
2022-06-13 17:59:01 +02:00
dergoegge
f9682e75ac [test_framework] Set PortSeed.n directly after initialising params
This allows us to use `p2p_port()` with `set_test_params()`.
2022-06-08 21:00:18 +02:00
MacroFake
455780b1ae
Merge bitcoin/bitcoin#25294: test: Fix wait_for_debug_log UnicodeDecodeError
fa74b63c01 test: Fix wait_for_debug_log UnicodeDecodeError (MacroFake)

Pull request description:

  Fix the intermittent `UnicodeDecodeError` when the debug log is truncated on an (multi-byte) unicode character by treating everything as bytes.

  Also, remove the `ignore_case` option and the`re.search+re.escape` wrap. All of this is unused and doesn't exist on raw byte strings.

  Fixes https://github.com/bitcoin/bitcoin/issues/24575

ACKs for top commit:
  jonatack:
    ACK fa74b63c01
  brunoerg:
    ACK fa74b63c01

Tree-SHA512: c67c9355073e784fa8d9d48b8e79ff0c98f5ae9cd4d704ad12a76d2604733946054bc74b8ab346aa2184db23d740b85c8c13eb892d76cba92e42ebfd73f2f1bf
2022-06-08 17:53:06 +02:00
MacroFake
fa74b63c01
test: Fix wait_for_debug_log UnicodeDecodeError 2022-06-07 20:54:37 +02:00
laanwj
e282764e04
Merge bitcoin/bitcoin#25228: test: add BIP-125 rule 5 testcase with default mempool
687addaf13 test: add BIP-125 rule 5 testcase with default mempool (James O'Beirne)
6120e8e287 test: allow passing sequence through create_self_transfer_multi (James O'Beirne)

Pull request description:

  Currently, we only test rule 5 of BIP-125 (replacement transactions cannot evict more than 100 transactions) by changing default mempool parameters to allow for more descendants. The current test works on a single transaction graph that has over 100 descendants.

  This patch adds a test to exercise rule 5 using the default mempool parameters. The case is a little more sophisticated: instead of working on a single transaction graph, it uses a replacement transaction to "unite" several UTXOs which join independent transaction graphs. The total number of transactions in these graphs sum to more than the max allowable replacement.

  I think the difference in transaction topology makes this a worthwhile testcase to have, setting aside the fact that this testcase works without having to use atypical mempool params.

  See also: [relevant discussion from IRC](https://www.erisian.com.au/bitcoin-core-dev/log-2022-05-27.html#l-126)

ACKs for top commit:
  laanwj:
    Code review ACK 687addaf13
  LarryRuane:
    ACK 687addaf13

Tree-SHA512: e589aeaf9d6f137d546b7809f8795d6f6043d87b15e97c2efe85b42ce8b49d977ee7d79440c542ca4b0b5ca2de527488029841a1ffc0d96c5771897df4b3f324
2022-06-07 20:49:33 +02:00
MacroFake
fafaad98f7
test: Set maxfeerate=0 in MiniWallet sendrawtransaction() 2022-06-01 17:07:05 +02:00
MacroFake
9cc010f5a9
Merge bitcoin/bitcoin#25087: test: use MiniWallet for feature_dbcrash.py
1da5e45725 test: use MiniWallet for feature_dbcrash.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (feature_dbcrash.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078.

ACKs for top commit:
  laanwj:
    Code review ACK 1da5e45725
  brunoerg:
    crACK 1da5e45725

Tree-SHA512: 75ee9a32fd1451254004797d695d18032bd0fcb66ebd88cf737e147e43812525f6e884ec05fcc4f76f566dc71174c8ed7347bcdce16567db6511746ae64cead0
2022-06-01 16:43:49 +02:00
James O'Beirne
6120e8e287 test: allow passing sequence through create_self_transfer_multi
And some little type annotation additions.
2022-05-27 13:40:06 -04:00
Sebastian Falbesoner
1da5e45725 test: use MiniWallet for feature_dbcrash.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-05-19 17:53:30 +02:00
MacroFake
bb83aba6c9
Merge bitcoin/bitcoin#25161: rpc: Put undocumented JSON failure mode behind a runtime flag
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag (Suhail Saqan)

Pull request description:

  Fixes #24695 (Put undocumented JSON failure mode behind a runtime flag)

ACKs for top commit:
  luke-jr:
    utACK b953ea6cc6
  vincenzopalazzo:
    ACK b953ea6cc6

Tree-SHA512: 2005ee1b1f3b637918390b2ecd4166f2fd8c86e3c59fba3da8a0cbd5b1dffd03190c92f6dca3c489ecce4276eaf3108b2edcf9cd6224b713adb52f5bb848163b
2022-05-19 06:44:55 +02:00