aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
AgeCommit message (Collapse)Author
2019-11-18test: skip tool_wallet test when bitcoin-wallet isn't compiledfanquake
2019-11-14test: Remove fragile assert_memory_usage_stableMarcoFalke
2019-11-05TestShell: Return self from setup()James Chiang
This allows user to chain setup() to the initializer. test-shell.md code examples have been updated to reflect this.
2019-11-05TestShell: Simplify default setting of num_nodesJames Chiang
2019-11-05TestShell: Fix typo in TestShell warning printoutJames Chiang
2019-11-04Add TestShell classJames Chiang
A BitcoinTestFramework child class which can be imported by an external user or project. TestShell.setup() initiates an underlying BitcoinTestFramework object with bitcoind subprocesses, rpc interfaces and test logging. TestShell.shutdown() safely tears down the BitcoinTestFramework object.
2019-11-03Move argparse() to init()JamesC
This ensures TestFramework default parameters are set before setup is called. A child class will therefore have access to defaults when overriding setup.
2019-11-03Move assert num_nodes is set into main()JamesC
This allows a BitcoinTestFramework child class to set test parameters in an overridden setup() rather than in an overridden set_test_params().
2019-11-03Clear TestNode objects after shutdownJamesC
TestNode objects need to be removed during shutdown, as setup_nodes does not remove previous TestNode objects from previous test runs during setup.
2019-11-03Add closing and flushing of logging handlersJamesC
In order for BitcoinTestFramework to correctly restart after shutdown, the previous logging handlers need to be removed, or else logging will continue in the previous temp directory. "Flush" ensures buffers are emptied, and "close" ensures file handler close logging file.
2019-11-03Refactor TestFramework main() into setup/shutdownJamesC
Setup and shutdown code now moved into dedicated methods. Test "success" is added as a BitcoinTestFramework member, which can be accessed outside of main. Argument parsing also moved into separate method and called from main.
2019-11-03Remove network_event_loop instance in close()JamesC
The asyncio.new_event_loop() instance is now removed from the NetworkThread class during shutdown. This enables a NetworkThread instance to be restarted after being closed. The current NetworkThread class guards against an existing new_event_loop during initialization.
2019-10-31[qa] Add shrinkdebugfile=0 to regtest bitcoin.confSuhas Daftuar
This helps avoid accidentally truncating the debug.log while manually debugging.
2019-10-30rpc: Add generatetodescriptorMarcoFalke
2019-10-14[test] rename SegwitVersion1SignatureHash()John Newbery
The function implementing segwit v0 signature hash was originally named SegwitVersion1SignatureHash() (presumably before segwit v0 was named segwit v0). Rename it to SegwitV0SignatureHash(). Also rename SignatureHash() to LegacySignatureHash() for disambiguation.
2019-10-14test: fix "tx-size-small" errors after default address changeSebastian Falbesoner
Addresses #17043, affects RBF and BIP68 functional tests. The "tx-size-small" policy rule rejects transactions with a non-witness size of smaller than 82 bytes (see src/validation.cpp:MemPoolAccept::PreChecks(...)), which corresponds to a transaction with 1 segwit input and 1 P2WPKH output. Through the default address change, the created test transactions have segwit inputs now and sending to short scriptPubKeys might violate this rule. By bumping the dummy scriptPubKey size to 22 bytes (= the size of a P2WPKH scriptPubKey), on all occurences the problem is solved. The dummy scriptPubKey has the format: 21 <21-byte-long string of 'a' or 1s> former commit messages, now squashed: test: rbf, bip68: use constant DUMMY_P2WPKH_SCRIPT for bumped scriptPubKey test: rbf, bip68: use constant DUMMY_P2WPKH_SCRIPT for dummy scriptPubKeys (b'a' * 35) test: rbf, bip68: comment DUMMY_P2WPKH_SCRIPT constant, put into common (new) module
2019-10-09Merge #15437: p2p: Remove BIP61 reject messagesWladimir J. van der Laan
fa25f43ac5692082dba3f90456c501eb08f1b75c p2p: Remove BIP61 reject messages (MarcoFalke) Pull request description: Reject messages (BIP 61) appear in the following settings: * Parsing of reject messages (in case `-debug=net` is set, off by default). This has only been used for a single `LogPrint` call for several releases now. Such logging is completely meaningless to us and should thus be removed. * The sending of reject messages (in case `-enablebip61` is set, off by default). This can be used to debug a node that is under our control. Instead of hacking this debugging into the p2p protocol, it could be more easily achieved by parsing the debug log. (Use `-printtoconsole` to have it as stream, or read from the `debug.log` file like our python function `assert_debug_log` in the test framework does) Having to maintain all of this logic and code to accommodate debugging, which can be achieved by other means a lot easier, is a burden. It makes review on net processing changes a lot harder, since the reject message logic has to be carried around without introducing any errors or DOS vectors. ACKs for top commit: jnewbery: utACK fa25f43ac5692082dba3f90456c501eb08f1b75c laanwj: I'm still not 100% convinced that I like getting rid of BIP61 conceptually, but apparently everyone wants it, code review ACK fa25f43ac5692082dba3f90456c501eb08f1b75c. ryanofsky: Code review ACK fa25f43ac5692082dba3f90456c501eb08f1b75c Tree-SHA512: daf55254202925e56be3d6cfb3c1c804e7a82cecb1dd1e5bd7b472bae989fd68ac4f21ec53fc46751353056fd645f7f877bebcb0b40920257991423a3d99e0be
2019-10-06Fix Python Docstring to include all Args.John Bampton
2019-10-02Merge #16524: Wallet: Disable -fallbackfee by defaultMarcoFalke
ea4cc3a7b36a9c77dbf0aff439da3ef0ea58e6e4 Truly decouple wallet from chainparams for -fallbackfee (Jorge Timón) Pull request description: Before it was 0 by default for main and 20000 for test and regtest. Now it is 0 by default for all chains, thus there's no need to call Params(). Also now the default for main is properly documented. Suggestion for release notes: -fallbackfee was 0 (disabled) by default for the main chain, but 20000 by default for the test chains. Now it is 0 by default for all chains. Testnet and regtest users will have to add fallbackfee=20000 to their configuration if they weren't setting it and they want it to keep working like before. Should I propose them to the wiki for the release notes or only after merge? For more context, see https://github.com/bitcoin/bitcoin/pull/16402#issuecomment-515701042 ACKs for top commit: MarcoFalke: ACK ea4cc3a7b36a9c77dbf0aff439da3ef0ea58e6e4 Tree-SHA512: fdfaba5d813da4221e405e0988bef44f3856d10f897a94f9614386d14b7716f4326ab8a6646e26d41ef3f4fa61b936191e216b1b605e9ab0520b0657fc162e6c
2019-10-02Truly decouple wallet from chainparams for -fallbackfeeJorge Timón
Before it was 0 by default for main and 20000 for test and regtest. Now it is 0 by default for all chains, thus there's no need to call Params(). Also now the default for main is properly documented
2019-10-02p2p: Remove BIP61 reject messagesMarcoFalke
2019-09-22Merge #16918: test: Make PORT_MIN in test runner configurableMarcoFalke
fa69588537bc91c0aedbc89ef1760d89cbffad75 test: Make PORT_MIN in test runner configurable (MarcoFalke) Pull request description: This is needed when some ports in the port range are used by other processes. Note that simply assigning the ports dynamically does not work: * We spin up several nodes per test (each node gets its own port) * We run several tests in parallel So to avoid nodes from different tests colliding on ports, the port assignment must be deterministic (can not be dynamic). Fixes: #10869 ACKs for top commit: practicalswift: ACK fa69588537bc91c0aedbc89ef1760d89cbffad75 -- diff looks correct promag: ACK fa69588537bc91c0aedbc89ef1760d89cbffad75. Tree-SHA512: e79adb015e7de79064e2d14336c38bc9672bd779ad6c52917721897e73f617c39d32c068a369c26670002a6c4ab95a71ef3a6878ebdd9710e02f410e2f7bcd14
2019-09-19test: Make PORT_MIN in test runner configurableMarcoFalke
2019-09-19Test: Move common function assert_approx() into util.pyfridokus
2019-09-17test: Remove unused connect_nodes_biMarcoFalke
2019-09-17scripted-diff: test: Replace connect_nodes_bi with connect_nodesMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/connect_nodes_bi\(self.nodes,\s*(.),\s*/connect_nodes(self.nodes[\1], /g' $(git grep -l connect_nodes_bi) sed -i --regexp-extended -e 's/connect_nodes_bi(,| )/connect_nodes\1/g' $(git grep -l connect_nodes_bi) -END VERIFY SCRIPT-
2019-09-17test: Use connect_nodes when connecting nodes in the test_frameworkMarcoFalke
2019-09-12Merge #16551: test: Test that low difficulty chain fork is rejectedMarcoFalke
333317ce6b67aa92f7363d48cd750712190b4b6b test: Test that low difficulty chain fork is rejected (MarcoFalke) fa31dc1bf4ee471c4641eef8de02702ba0619ae7 test: Pass down correct chain name in tests (MarcoFalke) Pull request description: To prevent OOM, Bitcoin Core will reject chain forks at low difficulty by default. This is the only use-case of checkpoints, so add a test for it to make sure the feature works as expected. If it didn't work, checkpoints would have no use-case and we might as well remove them ACKs for top commit: Sjors: Thanks for adding the node 1 example. Code review ACK 333317c Tree-SHA512: 90dffa540d0904f3cffb61d2382b1a26f84fe9560b7013e4461546383add31a8757b350616a6d43217c59ef7b8b2a1b62bb3bab582c679cbb2c660a782ce7be1
2019-09-11tests: add a test for the 'servicesnames' RPC fielddarosior
In getpeerinfo and getnetworkinfo
2019-09-09Merge #16796: wallet: Fix segfault in CreateWalletFromFileSamuel Dobson
fa734603b78ba31ebf0da5d2dbe87386eafff01a wallet: Fix segmentation fault in CreateWalletFromFile (MarcoFalke) fab3c34412379598b812631e3c123e9467cdc485 test: Print both messages on failure in assert_raises_message (MarcoFalke) faa13539d5262bb7a512e9ff82e80083e04315ee wallet: Fix documentation around WalletParameterInteraction (MarcoFalke) Pull request description: Comes with a test to aid review. The test should fail without the fix to bitcoind The following `CreateWalletFromFile` issues are fixed: * `walletFile` refers to freed memory and will thus corrupt the debug.log and/or crash the node if read * `WalletParameterInteraction` was moved to `CreateWalletFromFile` and `WalletInit::ParameterInteraction` without updating the documentation ACKs for top commit: promag: ACK fa734603b78ba31ebf0da5d2dbe87386eafff01a. darosior: ACK fa734603b78ba31ebf0da5d2dbe87386eafff01a meshcollider: LGTM, code-read ACK fa734603b78ba31ebf0da5d2dbe87386eafff01a Tree-SHA512: 2aceb63a3f25b90a840cfa08d37f5874aad4eb3df8c2ebf94e2ed18b55809b185e6920bdb345b988bff1fcea5e68a214fe06c361f7da2c01a3cc29e0cc421cb4
2019-09-04test: Remove incorrect and unused try-block in assert_debug_logMarcoFalke
2019-09-03test: Print both messages on failure in assert_raises_messageMarcoFalke
2019-08-28Merge #16726: tests: Avoid common Python default parameter gotcha when ↵MarcoFalke
mutable dict/list:s are used as default parameter values e4f4ea47ebf7774fb6f445adde7bf7ea71fa05a1 lint: Catch use of [] or {} as default parameter values in Python functions (practicalswift) 25dd86715039586d92176eee16e9c6644d2547f0 Avoid using mutable default parameter values (practicalswift) Pull request description: Avoid common Python default parameter gotcha when mutable `dict`/`list`:s are used as default parameter values. Examples of this gotcha caught during review: * https://github.com/bitcoin/bitcoin/pull/16673#discussion_r317415261 * https://github.com/bitcoin/bitcoin/pull/14565#discussion_r241942304 Perhaps surprisingly this is how mutable list and dictionary default parameter values behave in Python: ``` >>> def f(i, j=[], k={}): ... j.append(i) ... k[i] = True ... return j, k ... >>> f(1) ([1], {1: True}) >>> f(1) ([1, 1], {1: True}) >>> f(2) ([1, 1, 2], {1: True, 2: True}) ``` In contrast to: ``` >>> def f(i, j=None, k=None): ... if j is None: ... j = [] ... if k is None: ... k = {} ... j.append(i) ... k[i] = True ... return j, k ... >>> f(1) ([1], {1: True}) >>> f(1) ([1], {1: True}) >>> f(2) ([2], {2: True}) ``` The latter is typically the intended behaviour. This PR fixes two instances of this and adds a check guarding against this gotcha going forward :-) ACKs for top commit: Sjors: Oh Python... ACK e4f4ea47ebf7774fb6f445adde7bf7ea71fa05a1. Testing tip: swap the two commits. Tree-SHA512: 56e14d24fc866211a20185c9fdb274ed046c3aed2dc0e07699e58b6f9fa3b79f6d0c880fb02d72b7fe5cc5eb7c0ff6da0ead33123344e1a872209370c2e49e3f
2019-08-26Avoid using mutable default parameter valuespracticalswift
2019-08-21QA: fix rpc_setban.py raceJonas Schnelli
2019-08-19Bugfix: QA: Run tests with UPnP disabledLuke Dashjr
Needed for builds configured with --enable-upnp-default
2019-08-16test: Pass down correct chain name in testsMarcoFalke
2019-08-15Merge #16060: Bury bip9 deploymentsMarcoFalke
e78aaf41f43d0e2ad78fa6d8dad61032c8ef73d0 [docs] Add release notes for burying bip 9 soft fork deployments (John Newbery) 8319e738f9f118025b332e4fa804d4c31e4113f4 [tests] Add coverage for the content of getblockchaininfo.softforks (James O'Beirne) 0328dcdcfcb56dc8918697716d7686be048ad0b3 [Consensus] Bury segwit deployment (John Newbery) 1c93b9b31c2ab7358f9d55f52dd46340397c906d [Consensus] Bury CSV deployment height (John Newbery) 3862e473f0cb71a762c0306b171b591341d58142 [rpc] Tidy up reporting of buried and ongoing softforks (John Newbery) Pull request description: This hardcodes CSV and segwit activation heights, similar to the BIP 90 buried deployments for BIPs 34, 65 and 66. CSV and segwit have been active for over 18 months. Hardcoding the activation height is a code simplification, makes it easier to understand segwit activation status, and reduces technical debt. This was originally attempted by jl2012 in #11398 and again by me in #12360. ACKs for top commit: ajtowns: ACK e78aaf41f43d0e2ad78fa6d8dad61032c8ef73d0 ; checked diff to previous acked commit, checked tests still work ariard: ACK e78aaf4, check diff, run the tests again and successfully activated csv/segwit heights on mainnet as expected. MarcoFalke: ACK e78aaf41f43d0e2ad78fa6d8dad61032c8ef73d0 (still didn't check if the mainnet block heights are correct, but the code looks good now) Tree-SHA512: 7e951829106e21a81725f7d3e236eddbb59349189740907bb47e33f5dbf95c43753ac1231f47ae7bee85c8c81b2146afcdfdc11deb1503947f23093a9c399912
2019-08-15Merge #16465: test: Test p2sh-witness and bech32 in wallet_import_rescanMarcoFalke
fa3c6575cac5e3841797980fe60b8368ae579dba lint: Add false positive to python dead code linter (MarcoFalke) fa25668e1c8982548f1c6f94780709c625811469 test: Test p2sh-witness and bech32 in wallet_import_rescan (MarcoFalke) fa79af298917d501cee26370fdf9d44d05133d15 test: Replace fragile "rng" with call to random() (MarcoFalke) fac3dcf7d052586548f2100a0d576618a85741f9 test: Generate one block for each send in wallet_import_rescan (MarcoFalke) Pull request description: This adds test coverage for segwit in the `wallet_import_rescan` test, among other cleanups. ACKs for top commit: jnewbery: ACK fa3c6575cac5e3841797980fe60b8368ae579dba Tree-SHA512: 877741763c62c1bf9d868864a1e3f0699857e8c028e9fcd65c7eeb73600c22cbe97b7b51093737743d9e87bcb991c1fe1086f673e18765aef0fcfe27951402f0
2019-08-14test: Test p2sh-witness and bech32 in wallet_import_rescanMarcoFalke
2019-08-14[Consensus] Bury segwit deploymentJohn Newbery
Hardcode segwit deployment height to 481824 for mainnet.
2019-08-14[Consensus] Bury CSV deployment heightJohn Newbery
Hard code CSV deployment height to 419328 for mainnet.
2019-08-14Merge #16248: Make whitebind/whitelist permissions more flexibleWladimir J. van der Laan
c5b404e8f1973afe071a07c63ba1038eefe13f0f Add functional tests for flexible whitebind/list (nicolas.dorier) d541fa391844f658bd7035659b5b16695733dd56 Replace the use of fWhitelisted by permission checks (nicolas.dorier) ecd5cf7ea4c3644a30092100ffc399e30e193275 Do not disconnect peer for asking mempool if it has NO_BAN permission (nicolas.dorier) e5b26deaaa6842f7dd7c4537ede000f965ea0189 Make whitebind/whitelist permissions more flexible (nicolas.dorier) Pull request description: # Motivation In 0.19, bloom filter will be disabled by default. I tried to make [a PR](https://github.com/bitcoin/bitcoin/pull/16176) to enable bloom filter for whitelisted peers regardless of `-peerbloomfilters`. Bloom filter have non existent privacy and server can omit filter's matches. However, both problems are completely irrelevant when you connect to your own node. If you connect to your own node, bloom filters are the most bandwidth efficient way to synchronize your light client without the need of some middleware like Electrum. It is also a superior alternative to BIP157 as it does not require to maintain an additional index and it would work well on pruned nodes. When I attempted to allow bloom filters for whitelisted peer, my proposal has been NACKed in favor of [a more flexible approach](https://github.com/bitcoin/bitcoin/pull/16176#issuecomment-500762907) which should allow node operator to set fine grained permissions instead of a global `whitelisted` attribute. Doing so will also make follow up idea very easy to implement in a backward compatible way. # Implementation details The PR propose a new format for `--white{list,bind}`. I added a way to specify permissions granted to inbound connection matching `white{list,bind}`. The following permissions exists: * ForceRelay * Relay * NoBan * BloomFilter * Mempool Example: * `-whitelist=bloomfilter@127.0.0.1/32`. * `-whitebind=bloomfilter,relay,noban@127.0.0.1:10020`. If no permissions are specified, `NoBan | Mempool` is assumed. (making this PR backward compatible) When we receive an inbound connection, we calculate the effective permissions for this peer by fetching the permissions granted from `whitelist` and add to it the permissions granted from `whitebind`. To keep backward compatibility, if no permissions are specified in `white{list,bind}` (e.g. `--whitelist=127.0.0.1`) then parameters `-whitelistforcerelay` and `-whiterelay` will add the permissions `ForceRelay` and `Relay` to the inbound node. `-whitelistforcerelay` and `-whiterelay` are ignored if the permissions flags are explicitly set in `white{bind,list}`. # Follow up idea Based on this PR, other changes become quite easy to code in a trivially review-able, backward compatible way: * Changing `connect` at rpc and config file level to understand the permissions flags. * Changing the permissions of a peer at RPC level. ACKs for top commit: laanwj: re-ACK c5b404e8f1973afe071a07c63ba1038eefe13f0f Tree-SHA512: adfefb373d09e68cae401247c8fc64034e305694cdef104bdcdacb9f1704277bd53b18f52a2427a5cffdbc77bda410d221aed252bc2ece698ffbb9cf1b830577
2019-08-13[rpc] Tidy up reporting of buried and ongoing softforksJohn Newbery
This combines reporting of buried (formally ISM) softfork deployments and BIP9 versionbits softfork deployments into one JSON object in the getblockchaininfo return object.
2019-08-13Moved and renamed hash256 from util.py to zmq_interface.pyElichai Turkel
2019-08-11Add functional tests for flexible whitebind/listnicolas.dorier
2019-08-05Merge #16363: test: Add test for BIP30 duplicate txMarcoFalke
fa8489a15511f61a372473927e73c34692bbec23 test: Add test for BIP30 duplicate tx (MarcoFalke) 77770d95e2838d7665fa8f621e9e83d79f9b3196 test: Properly serialize BIP34 coinbase height (MarcoFalke) Pull request description: This adds a test for BIP30 to check that duplicate txs can exist in the blockchain given the first one was completely spent when the second one is added. (Requested by ajtowns in https://github.com/bitcoin/bitcoin/pull/16333#issuecomment-508604071) We can not add a test that a later duplicate tx overwrites a previous one, because BIP30 is always enforced on regtest. If someone feels strongly about such a test, some Bitcoin Core code would have to be modified, which can be done in a follow up pull request. Also, add a commit to fix the BIP34 test failures reported in https://github.com/bitcoin/bitcoin/pull/14633#issue-227712540 ACKs for top commit: laanwj: Code review ACK fa8489a15511f61a372473927e73c34692bbec23 Tree-SHA512: c707d0bdc93937263876b603425b53322a2a9f9ec3f50716ae2fa9de8ddc644beb22b26c1bfde7f4aab102633e096b354ef380db919176bd2cb44a2828f884aa
2019-08-05Merge #16509: test: Adapt test framework for chains other than "regtest"MarcoFalke
faf36838bdba7393960fce6ad0c56dc1f93f5870 test: Avoid hardcoding the chain name in combine_logs (MarcoFalke) fa8a1d7ba30040f8c74f93fc41a61276c255a6a6 test: Adapt test framework for chains other than "regtest" (MarcoFalke) 68f546635d5de2ccfedadeabc7bc79e12e5eca6a test: Fix “local variable 'e' is assigned to but never used” (Ben Woosley) Pull request description: This is required for various work in progress: * testchains #8994 * signet #16411 * some of my locally written tests While it will be unused in the master branch as of now, it will make all of those pull requests shorter. Thus review for non-regtest tests can focus on the actual changes and not some test framework changes. ACKs for top commit: jonatack: ACK faf36838bdba7393960fce6ad0c56dc1f93f5870, ran tests and reviewed the code. Tree-SHA512: 35add66c12cab68f2fac8f7c7d47c604d3f24eae9336ff78f83e2c92b3dc08a25e7f4217199bac5393dd3fb72f945bba9c001d6fbb8efd298c88858075fcb3d6
2019-07-31test: Adapt test framework for chains other than "regtest"MarcoFalke
Co-Authored-By: Jorge Timón <jtimon@jtimon.cc>
2019-07-31test: Fix “local variable 'e' is assigned to but never used”Ben Woosley
flake8 F841 lints, as of flake8 3.6.0