Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install_noded.sh #2422

Merged
merged 3 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,18 @@ _note: you may need to add `$HOME/.cargo/bin` to your path in `.env/bin/activate
## How to run the tests
_TODO: Need more thorough tests!_

In order to run the tests, you need bitcoind and elementsd binaries available. For Linux/Mac, there is some support for installing/compiling them. So you can:
In order to run the tests, you need bitcoind and elementsd binaries available. For Linux/Mac, there is some support for installing/compiling them.

For bitcoind you can do:

* `./tests/install_noded.sh --bitcoin binary` will install bitcoind in tests/bitcoin

or:

* `./tests/install_noded.sh --bitcoin compile` will compile bitcoind in tests/bitcoin

For elementsd:

* `./tests/install_noded.sh --elements compile` will compile elements in tests/elements

If you're not interested in elements, you can skip the liquid specific tests as described below.
Expand Down
14 changes: 4 additions & 10 deletions tests/install_noded.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@ function maybe_update {
# Determine if we need to pull. From https://stackoverflow.com/a/3278427
UPSTREAM=origin/master
LOCAL=$(git describe --all | sed 's/heads\///' | sed 's/tags\///') # gives either a tag or "master"
if cat ../../pyproject.toml | grep "addopts = --${node_impl}d-version" ; then
# in this case, we use the expected version from the test also as the tag to be checked out
# i admit that this is REALLY ugly. Happy for any recommendations to do that more easy
PINNED=$(cat ../../pyproject.toml | grep "addopts = " | cut -d'=' -f2 | sed 's/--/+/g' | tr '+' '\n' | grep ${node_impl} | cut -d' ' -f2)
if [ "$node_impl" = "elements" ]; then
# in the case of elements, the tags have a "elements-" prefix
PINNED=$(echo "$PINNED" | sed 's/v//' | sed 's/^/elements-/')
fi
fi

cd ..
PINNED=$(calc_pytestinit_nodeimpl_version $node_impl)
cd bitcoin

# the version in pyproject.toml is (also) used to check the version via getnetworkinfo()["subversion"]
# However, this might not be a valid git rev. So we need another way to specify the git-rev used
# as we want to be able to test against specific commits
Expand Down
21 changes: 9 additions & 12 deletions tests/test_node_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,10 @@ def test_node_running_elements(caplog, request):
caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
requested_version = request.config.getoption("--elementsd-version")
try:
try:
my_elementsd = ElementsPlainController(
elementsd_path=find_node_executable(node_impl="elements"),
rpcport=18123, # Non-standardport to not interfer
)
except Exception as e:
if "Couldn't find executable elementsd" in str(e):
pytest.skip(str(e))
else:
raise e

my_elementsd = ElementsPlainController(
elementsd_path=find_node_executable(node_impl="elements"),
rpcport=18123, # Non-standardport to not interfer
)
rpcconn = my_elementsd.start_node(cleanup_at_exit=True, cleanup_hard=True)
requested_version = request.config.getoption("--elementsd-version")
assert my_elementsd.version() == requested_version
Expand All @@ -87,5 +80,9 @@ def test_node_running_elements(caplog, request):
prepare_elements_default_wallet(my_elementsd)
random_address = "el1qqf6tv4n8qp55qc04v4xts5snd9v5uurkry4vskef6lmecahj6c42jt9lnj0432287rs67z9vzq2zvuer036s5mahptwxgyd8k"
my_elementsd.testcoin_faucet(random_address, amount=25)
finally:
Copy link
Contributor

@k9ert k9ert May 15, 2024

Choose a reason for hiding this comment

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

The finally is still needed, no? Stopping the node should be done in any case.

my_elementsd.stop_node()
except Exception as e:
if "Couldn't find executable elementsd" in str(e):
pytest.skip(str(e))
else:
raise e
Loading