mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
* Included API end points Included 3 API end points: ###/api/specter ["GET"] Basic Specter info from app.specter class ###/api/full_txlist/ ["GET"] Full Transaction list for all wallets ###"/api/wallet_info/<wallet_alias>/ ["GET"] More detailed wallet info and transactions from the app.specter.wallet_manager class * Update src/cryptoadvance/specter/controller.py Include `wallet.check_unused()` Co-authored-by: benk10 <ben.kaufman10@gmail.com> * API Update Made a few changes: - Flattened the wallet list to be similar to full transaction list - included versioning on url `/v1alpha/` - Included `wallet.utxo` data - Improved `safe_serialize` for better json output Pending Updates: - Create a separate file for API (as a blueprint) - Explore using Flask-restful for improved authentication (downside is that it is another dependency - not sure if already a requirement for specter) * adding a rest-api * Implemented API end points inside of example.py * Merging with remote * Fixed API.md * Removing example-resources * migrating to focal due to cryptography needs newer pip * fix the image * black and tidy up * Deleted more useless stuff * first take for psbt (still broken) * get tests to work * fix devices_signed undefined * fix part2 * fix part 3 * fix part 4 * Rest Get-Requests for psbt working * fix part 5 * extending psbt_creator with json format * tests finished. bitcoind_regtest changed to scope session * speed up tests * fix tests * tiny test for LiquidRpc, probes improvements * try fixing testing-infra * kick * finally fix infra, hopefully * removing assertion * refactoring and fixing API * fix the rest-tests * fix last liquid failing test * polishing: error_handling via decorator * split-up docs * fix requirements.in * polishing REST-API * optimize startup for internal_nodes * Update src/cryptoadvance/specter/internal_node.py Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <40473443+pxsocs@users.noreply.github.com> Co-authored-by: benk10 <ben.kaufman10@gmail.com> Co-authored-by: Alpha Zeta <alphazeta@protonmail.com> Co-authored-by: Stepan Snigirev <snigirev.stepan@gmail.com>
105 lines
4.2 KiB
Python
105 lines
4.2 KiB
Python
import logging
|
|
import os
|
|
|
|
import pytest
|
|
from cryptoadvance.specter.process_controller.bitcoind_docker_controller import (
|
|
BitcoindDockerController,
|
|
)
|
|
from cryptoadvance.specter.process_controller.bitcoind_controller import (
|
|
BitcoindPlainController,
|
|
)
|
|
from cryptoadvance.specter.process_controller.elementsd_controller import (
|
|
ElementsPlainController,
|
|
)
|
|
from cryptoadvance.specter.process_controller.node_controller import (
|
|
NodePlainController,
|
|
fetch_wallet_addresses_for_mining,
|
|
find_node_executable,
|
|
)
|
|
from cryptoadvance.specter.util.shell import which
|
|
|
|
from cryptoadvance.specter.cli.cli_noded import prepare_elements_default_wallet
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@pytest.mark.slow
|
|
@pytest.mark.skip("interferes with conftest fixtures")
|
|
def test_node_running_bitcoin(caplog, docker, request):
|
|
# TODO: Refactor this to use conftest.instantiate_bitcoind_controller
|
|
# to reduce redundant code?
|
|
caplog.set_level(logging.INFO)
|
|
caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
|
|
requested_version = request.config.getoption("--bitcoind-version")
|
|
try:
|
|
if docker:
|
|
my_bitcoind = BitcoindDockerController(
|
|
rpcport=18456, docker_tag=requested_version
|
|
)
|
|
pass
|
|
else:
|
|
my_bitcoind = BitcoindPlainController(
|
|
bitcoind_path=find_node_executable("bitcoin"),
|
|
rpcport=18456, # Non-standardport to not interfer
|
|
)
|
|
|
|
rpcconn = my_bitcoind.start_node(cleanup_at_exit=True, cleanup_hard=True)
|
|
requested_version = request.config.getoption("--bitcoind-version")
|
|
assert my_bitcoind.version() == requested_version
|
|
assert rpcconn.get_rpc() != None
|
|
assert rpcconn.get_rpc().ipaddress != None
|
|
bci = rpcconn.get_rpc().getblockchaininfo()
|
|
assert bci["blocks"] == 100
|
|
# you can use the testcoin_faucet:
|
|
random_address = "mruae2834buqxk77oaVpephnA5ZAxNNJ1r"
|
|
my_bitcoind.testcoin_faucet(random_address, amount=25)
|
|
finally:
|
|
my_bitcoind.stop_node()
|
|
logger.info("Bitcoind for test_node_running_bitcoin stopped")
|
|
|
|
|
|
def test_fetch_wallet_addresses_for_mining(caplog, wallets_filled_data_folder):
|
|
caplog.set_level(logging.INFO)
|
|
caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
|
|
# Todo: instantiate a specter-testwallet
|
|
addresses = fetch_wallet_addresses_for_mining("bitcoin", wallets_filled_data_folder)
|
|
assert addresses # make more sense out of this test
|
|
|
|
|
|
@pytest.mark.slow
|
|
@pytest.mark.skip("interferes with conftest fixtures")
|
|
def test_node_running_elements(caplog, docker, request):
|
|
# TODO: Refactor this to use conftest.instantiate_bitcoind_controller
|
|
# to reduce redundant code?
|
|
caplog.set_level(logging.INFO)
|
|
caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
|
|
requested_version = request.config.getoption("--elementsd-version")
|
|
try:
|
|
if docker:
|
|
# The NodeController is not available on docker
|
|
return
|
|
else:
|
|
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
|
|
|
|
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
|
|
assert rpcconn.get_rpc() != None
|
|
assert rpcconn.get_rpc().ipaddress != None
|
|
bci = rpcconn.get_rpc().getblockchaininfo()
|
|
# assert bci["blocks"] == 100
|
|
# you can use the testcoin_faucet:
|
|
prepare_elements_default_wallet(my_elementsd)
|
|
random_address = "el1qqf6tv4n8qp55qc04v4xts5snd9v5uurkry4vskef6lmecahj6c42jt9lnj0432287rs67z9vzq2zvuer036s5mahptwxgyd8k"
|
|
my_elementsd.testcoin_faucet(random_address, amount=25)
|
|
finally:
|
|
my_elementsd.stop_node()
|