mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
Merge bitcoin/bitcoin#31415: test: fix TestShell initialization and reset()
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
Some checks are pending
CI / test each commit (push) Waiting to run
CI / macOS 14 native, arm64, no depends, sqlite only, gui (push) Waiting to run
CI / macOS 14 native, arm64, fuzz (push) Waiting to run
CI / Win64 native, VS 2022 (push) Waiting to run
CI / Win64 native fuzz, VS 2022 (push) Waiting to run
CI / ASan + LSan + UBSan + integer, no depends, USDT (push) Waiting to run
303f8cca05
test: fix TestShell initialization and reset() (Brandon Odiwuor) Pull request description: Fixes TestShell initialization issues caused by resolving symlinks and looking for config.ini in the source path instead of the build path after migration to CMake (see https://github.com/bitcoin/bitcoin/issues/31131#issuecomment-2433056070)ebe4cac38b/test/functional/test_framework/test_shell.py (L77)
also fixes https://github.com/bitcoin/bitcoin/issues/31131 **How to test:** ``` $ python3 >>> import sys >>> sys.path.insert(0, "./path/to/bitcoin/build/test/functional") >>> from test_framework.test_shell import TestShell >>> TestShell().setup(num_nodes=2, setup_clean_chain=True) >>> TestShell().shutdown() >>> TestShell.reset() ``` ACKs for top commit: pinheadmz: ACK303f8cca05
theStack: Tested ACK303f8cca05
pablomartin4btc: re-ACK303f8cca05
Tree-SHA512: 25396eb2f7e4bf14426399b1eb3d2c988903ab1f3d38a58f1044b67dd7200c11c01686578fb49b0f2943864166c5c9ccbf122b45202a1e723bf3dbf0c90020fa
This commit is contained in:
commit
c12a2528ce
2 changed files with 13 additions and 9 deletions
|
@ -24,13 +24,16 @@ user inputs. Such environments include the Python3 command line interpreter or
|
||||||
|
|
||||||
## 2. Importing `TestShell` from the Bitcoin Core repository
|
## 2. Importing `TestShell` from the Bitcoin Core repository
|
||||||
|
|
||||||
We can import the `TestShell` by adding the path of the Bitcoin Core
|
We can import the `TestShell` by adding the path of the configured Bitcoin Core
|
||||||
`test_framework` module to the beginning of the PATH variable, and then
|
`test_framework` module to the beginning of the PATH variable, and then
|
||||||
importing the `TestShell` class from the `test_shell` sub-package.
|
importing the `TestShell` class from the `test_shell` sub-package. Since
|
||||||
|
the build system creates a copy of the `test_framework` module into a new `build/`
|
||||||
|
directory along with the required configuration file, the path to the build copy
|
||||||
|
must be used.
|
||||||
|
|
||||||
```
|
```
|
||||||
>>> import sys
|
>>> import sys
|
||||||
>>> sys.path.insert(0, "/path/to/bitcoin/test/functional")
|
>>> sys.path.insert(0, "/path/to/bitcoin/build/test/functional")
|
||||||
>>> from test_framework.test_shell import TestShell
|
>>> from test_framework.test_shell import TestShell
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -155,7 +158,7 @@ To prevent the logs from being removed after a shutdown, simply set the
|
||||||
The following utility consolidates logs from the bitcoind nodes and the
|
The following utility consolidates logs from the bitcoind nodes and the
|
||||||
underlying `BitcoinTestFramework`:
|
underlying `BitcoinTestFramework`:
|
||||||
|
|
||||||
* `/path/to/bitcoin/test/functional/combine_logs.py
|
* `/path/to/bitcoin/build/test/functional/combine_logs.py
|
||||||
'/path/to/bitcoin_func_test_XXXXXXX'`
|
'/path/to/bitcoin_func_test_XXXXXXX'`
|
||||||
|
|
||||||
## 6. Custom `TestShell` parameters
|
## 6. Custom `TestShell` parameters
|
||||||
|
@ -170,9 +173,9 @@ can be called after the TestShell is shut down.
|
||||||
| Test parameter key | Default Value | Description |
|
| Test parameter key | Default Value | Description |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `bind_to_localhost_only` | `True` | Binds bitcoind P2P services to `127.0.0.1` if set to `True`.|
|
| `bind_to_localhost_only` | `True` | Binds bitcoind P2P services to `127.0.0.1` if set to `True`.|
|
||||||
| `cachedir` | `"/path/to/bitcoin/test/cache"` | Sets the bitcoind datadir directory. |
|
| `cachedir` | `"/path/to/bitcoin/build/test/cache"` | Sets the bitcoind datadir directory. |
|
||||||
| `chain` | `"regtest"` | Sets the chain-type for the underlying test bitcoind processes. |
|
| `chain` | `"regtest"` | Sets the chain-type for the underlying test bitcoind processes. |
|
||||||
| `configfile` | `"/path/to/bitcoin/test/config.ini"` | Sets the location of the test framework config file. |
|
| `configfile` | `"/path/to/bitcoin/build/test/config.ini"` | Sets the location of the test framework config file. |
|
||||||
| `coveragedir` | `None` | Records bitcoind RPC test coverage into this directory if set. |
|
| `coveragedir` | `None` | Records bitcoind RPC test coverage into this directory if set. |
|
||||||
| `loglevel` | `INFO` | Logs events at this level and higher. Can be set to `DEBUG`, `INFO`, `WARNING`, `ERROR` or `CRITICAL`. |
|
| `loglevel` | `INFO` | Logs events at this level and higher. Can be set to `DEBUG`, `INFO`, `WARNING`, `ERROR` or `CRITICAL`. |
|
||||||
| `nocleanup` | `False` | Cleans up temporary test directory if set to `True` during `shutdown`. |
|
| `nocleanup` | `False` | Cleans up temporary test directory if set to `True` during `shutdown`. |
|
||||||
|
|
|
@ -61,7 +61,8 @@ class TestShell:
|
||||||
print("Shutdown TestShell before resetting!")
|
print("Shutdown TestShell before resetting!")
|
||||||
else:
|
else:
|
||||||
self.num_nodes = None
|
self.num_nodes = None
|
||||||
super().__init__()
|
dummy_testshell_file = pathlib.Path(__file__).absolute().parent.parent / "testshell_dummy.py"
|
||||||
|
super().__init__(dummy_testshell_file)
|
||||||
|
|
||||||
instance = None
|
instance = None
|
||||||
|
|
||||||
|
@ -74,8 +75,8 @@ class TestShell:
|
||||||
# cache. Since TestShell is meant for interactive use, there is no concrete
|
# cache. Since TestShell is meant for interactive use, there is no concrete
|
||||||
# test; passing a dummy name is fine though, as only the containing directory
|
# test; passing a dummy name is fine though, as only the containing directory
|
||||||
# is relevant for successful initialization.
|
# is relevant for successful initialization.
|
||||||
tests_directory = pathlib.Path(__file__).resolve().parent.parent
|
dummy_testshell_file = pathlib.Path(__file__).absolute().parent.parent / "testshell_dummy.py"
|
||||||
TestShell.instance = TestShell.__TestShell(tests_directory / "testshell_dummy.py")
|
TestShell.instance = TestShell.__TestShell(dummy_testshell_file)
|
||||||
TestShell.instance.running = False
|
TestShell.instance.running = False
|
||||||
return TestShell.instance
|
return TestShell.instance
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue