mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
* change Node persistence format
* Removing the Singleton
* mainly refactoring
* intermediate commit
* fix test
* Updated diagram
* fix tests
* removing simplejsons references
* fix tests
* remove update, tests working
* abstract Node
* refining Migration framework: run migrations until they suceed
* BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes
* clicking redirects to node config if there is no node connection
* AbstractNode
* BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes
* clicking redirects to node config if there is no node connection
* handling broken connection when there is no other error superseding (i.e. no wallets)
* Abstract Node improvements and issue fixing
* improving node_info handling
* fix test results, property device_manager in user, bcce in get_rpc in node, improved rpc property in node
* typos
* provide data_folders for extensions
* parametrizing include for node_info
* Remove initial_node_contribution refactoring welcome
* adding convenience methods
* extension data-storage
* Tests green
* Better failure resistence
* Enabling Node settings
* error handling
* adjust_view_model callback
* exception Handling
* Shielding core from extension flaws
* More consistent logging
* Refactoring wallets endpoints
* Make wallet_overview extendable
* butgifex and cleanup
* feedback by Manolis
* rename BusinessObject to PersistentObject
* fix Error-management and rollback information
* Nodes.md corrections
* frontend-aspects.md (small) corrections
* fix tests and address feedback and errormanagement
* fix tests, proper error-handling
* Fix test_util_reflection
* just some little addons to test_util_reflection
* fix cleanup_on_exit
* migration fix
* remove check, add redirect after saving node
* fix test (not that cool but what to do?)
* upgrade Flask as Flask-SQLAlchemy needs higher Flask version
* Revert "upgrade Flask as Flask-SQLAlchemy needs higher Flask version"
This reverts commit bf24120f89.
* update bug fixed + node manager added to node test
* cleanup external_node
Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
99 lines
3.4 KiB
Python
99 lines
3.4 KiB
Python
from enum import auto
|
|
import tempfile
|
|
import time
|
|
import tarfile
|
|
import os
|
|
from unittest.mock import MagicMock
|
|
|
|
import pytest
|
|
from cryptoadvance.specter.managers.node_manager import NodeManager
|
|
from cryptoadvance.specter.process_controller.bitcoind_controller import (
|
|
BitcoindPlainController,
|
|
)
|
|
from cryptoadvance.specter.process_controller.elementsd_controller import (
|
|
ElementsPlainController,
|
|
)
|
|
|
|
|
|
@pytest.mark.elm
|
|
def test_NodeManager(
|
|
bitcoin_regtest: BitcoindPlainController, elements_elreg: ElementsPlainController
|
|
):
|
|
with tempfile.TemporaryDirectory(
|
|
prefix="pytest_NodeManager_datafolder"
|
|
) as data_folder:
|
|
print(f"data_folder={data_folder}")
|
|
nm = NodeManager(data_folder=data_folder)
|
|
nm.add_external_node(
|
|
"BTC",
|
|
"bitcoin_regtest",
|
|
False,
|
|
"",
|
|
bitcoin_regtest.rpcconn.rpcuser,
|
|
bitcoin_regtest.rpcconn.rpcpassword,
|
|
bitcoin_regtest.rpcconn.rpcport,
|
|
bitcoin_regtest.rpcconn._ipaddress,
|
|
"http",
|
|
)
|
|
assert nm.nodes_names == ["Bitcoin Core", "bitcoin_regtest"]
|
|
nm.switch_node("bitcoin_regtest")
|
|
assert nm.active_node.rpc.getblockchaininfo()["chain"] == "regtest"
|
|
nm.add_external_node(
|
|
"ELM",
|
|
"elements_elreg",
|
|
False,
|
|
"",
|
|
elements_elreg.rpcconn.rpcuser,
|
|
elements_elreg.rpcconn.rpcpassword,
|
|
elements_elreg.rpcconn.rpcport,
|
|
elements_elreg.rpcconn._ipaddress,
|
|
"http",
|
|
)
|
|
assert nm.nodes_names == ["Bitcoin Core", "bitcoin_regtest", "elements_elreg"]
|
|
nm.switch_node("elements_elreg")
|
|
assert nm.active_node.rpc.getblockchaininfo()["chain"] == "elreg"
|
|
nm.delete_node(nm.nodes["Bitcoin Core"], MagicMock())
|
|
|
|
|
|
""" For some reason this breaks other tests"""
|
|
|
|
|
|
@pytest.mark.skip()
|
|
def test_NodeManager_import(bitcoind_path):
|
|
with tempfile.TemporaryDirectory("_some_datafolder_tmp") as data_folder:
|
|
print(f"data_folder={data_folder}")
|
|
nm = NodeManager(data_folder=data_folder, bitcoind_path=bitcoind_path)
|
|
print(os.getcwd())
|
|
# This .bitcoin folder doesn't have a config-file
|
|
btc_tar = tarfile.open(
|
|
"./tests/helpers_testdata/bitcoin_minimum_mainnet_datadir.tgz", "r:gz"
|
|
)
|
|
btc_tar.extractall(os.path.join(data_folder, "somename", ".bitcoin-main"))
|
|
# # ... so let's create one
|
|
# with open(
|
|
# os.path.join(data_folder,"somename",".bitcoin-main","bitcoin.conf"),
|
|
# "w+",
|
|
# ) as file:
|
|
# file.write('''
|
|
# rpcauth=bitcoin:044931c1d498b7c27080d8b981331a65$6ee7929513401c39ca1f7e376e55553c52dcb36a14e8410ac5f514fbf18bedbb
|
|
# server=1
|
|
# listen=1
|
|
# proxy=127.0.0.1:9050
|
|
# bind=127.0.0.1
|
|
# torcontrol=127.0.0.1:9051
|
|
# torpassword=gVzREfuHso6U2OfRRvqT3w
|
|
# fallbackfee=0.0002
|
|
# prune=1000
|
|
# '''
|
|
# )
|
|
|
|
node = nm.add_internal_node("somename", port=8339)
|
|
try:
|
|
node.start()
|
|
time.sleep(5)
|
|
# assert node.rpc.password == None
|
|
nm.switch_node("somename")
|
|
time.sleep(5)
|
|
assert nm.active_node.rpc.getblockchaininfo()["chain"] == "main"
|
|
finally:
|
|
node.stop()
|