diff --git a/lib/ucoinpy/api/bma/tx/history/__init__.py b/lib/ucoinpy/api/bma/tx/history/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b0e42968a817b6560c80602afca9587738640d00 --- /dev/null +++ b/lib/ucoinpy/api/bma/tx/history/__init__.py @@ -0,0 +1,32 @@ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# Authors: +# Caner Candan <caner@candan.fr>, http://caner.candan.fr +# + +from .. import History, logging + +logger = logging.getLogger("ucoin/tx") + + +class Blocks(History): + def __init__(self, conn_handler, pubkey, from_, to_, module='tx'): + super(Blocks, self).__init__(conn_handler, pubkey, module) + self.from_ = from_ + self.to_ = to_ + + def __get__(self, **kwargs): + r = yield from self.requests_get('/history/%s/blocks/%s/%s' % (self.pubkey, self.from_, self.to_), **kwargs) + return (yield from r.json()) \ No newline at end of file diff --git a/lib/ucoinpy/api/bma/ud/__init__.py b/lib/ucoinpy/api/bma/ud/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33f51b2ff52f9b1faaa1bf7ae2e718aec82783cf --- /dev/null +++ b/lib/ucoinpy/api/bma/ud/__init__.py @@ -0,0 +1,39 @@ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# Authors: +# Caner Candan <caner@candan.fr>, http://caner.candan.fr +# + +from .. import API, logging + +logger = logging.getLogger("ucoin/ud") + + +class Ud(API): + def __init__(self, conn_handler, module='ud'): + super(Ud, self).__init__(conn_handler, module) + + +class History(Ud): + """Get UD history.""" + + def __init__(self, conn_handler, pubkey, module='ud'): + super(Ud, self).__init__(conn_handler, module) + self.pubkey = pubkey + + def __get__(self, **kwargs): + assert self.pubkey is not None + r = yield from self.requests_get('/history/%s' % self.pubkey, **kwargs) + return (yield from r.json()) diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 3c19370748969ad4c1025930a52d985284e9e4a6..93d3f9492032c3510f1dbbd687ebce6c30311f59 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -84,7 +84,7 @@ class Account(QObject): return account @classmethod - def load(cls, json_data, network_manager, identities_registry): + def load(cls, json_data, identities_registry): """ Factory method to create an Account object from its json view. :rtype : cutecoin.core.account.Account @@ -108,7 +108,7 @@ class Account(QObject): communities = [] for data in json_data['communities']: - community = Community.load(network_manager, data) + community = Community.load(data) communities.append(community) account = cls(salt, pubkey, name, communities, wallets, diff --git a/src/cutecoin/core/app.py b/src/cutecoin/core/app.py index 75721e8b5a4689da4fbb012f1ca1dcd618f5bec4..724b74183ec7b94e4eca2e03b71c107d528ec69b 100644 --- a/src/cutecoin/core/app.py +++ b/src/cutecoin/core/app.py @@ -33,12 +33,11 @@ class Application(QObject): version_requested = pyqtSignal() - def __init__(self, qapp, loop, network_manager, identities_registry): + def __init__(self, qapp, loop, identities_registry): """ Init a new "cutecoin" application :param QCoreApplication qapp: Qt Application :param quamash.QEventLoop loop: quamash.QEventLoop instance - :param QNetworkAccessManager network_manager: QNetworkAccessManager instance :param IdentitiesRegistry identities_registry: IdentitiesRegistry instance :return: """ @@ -52,7 +51,6 @@ class Application(QObject): __version__, "") self._identities_registry = identities_registry - self._network_manager = network_manager self.preferences = {'account': "", 'lang': 'en_GB', 'ref': 0, @@ -70,9 +68,8 @@ class Application(QObject): @classmethod def startup(cls, argv, qapp, loop): config.parse_arguments(argv) - network_manager = QNetworkAccessManager() identities_registry = IdentitiesRegistry() - app = cls(qapp, loop, network_manager, identities_registry) + app = cls(qapp, loop, identities_registry) app.load() app.switch_language() if app.preferences['enable_proxy'] is True: @@ -81,7 +78,7 @@ class Application(QObject): qtproxy = QNetworkProxy(proxytypes[app.preferences.get('proxy_type', "HTTP")], app.preferences['proxy_address'], app.preferences['proxy_port']) - network_manager.setProxy(qtproxy) + #network_manager.setProxy(qtproxy) if app.preferences["account"] != "": account = app.get_account(app.preferences["account"]) @@ -145,10 +142,6 @@ class Application(QObject): def identities_registry(self): return self._identities_registry - @property - def network_manager(self): - return self._network_manager - def add_account(self, account): self.accounts[account.name] = account @@ -465,9 +458,9 @@ class Application(QObject): def get_last_version(self): url = QUrl("https://api.github.com/repos/ucoin-io/cutecoin/releases") - request = QNetworkRequest(url) + """request = QNetworkRequest(url) reply = self._network_manager.get(request) - reply.finished.connect(self.read_available_version) + reply.finished.connect(self.read_available_version)""" @pyqtSlot(QNetworkReply) def read_available_version(self): diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py index 07dd45b6e07aff5fe01b265b8ce988b837e187dc..e7ff00775df0a583f7895817a419f57dc6d2bed4 100644 --- a/src/cutecoin/core/community.py +++ b/src/cutecoin/core/community.py @@ -44,27 +44,27 @@ class Community(QObject): self._bma_access = bma_access @classmethod - def create(cls, network_manager, node): + def create(cls, node): """ Create a community from its first node. :param node: The first Node of the community """ - network = Network.create(network_manager, node) + network = Network.create(node) bma_access = BmaAccess.create(network) community = cls(node.currency, network, bma_access) logging.debug("Creating community") return community @classmethod - def load(cls, network_manager, json_data): + def load(cls, json_data): """ Load a community from json :param dict json_data: The community as a dict in json format """ currency = json_data['currency'] - network = Network.from_json(network_manager, currency, json_data['peers']) + network = Network.from_json(currency, json_data['peers']) bma_access = BmaAccess.create(network) community = cls(currency, network, bma_access) return community diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index 49cc2be80c95e63a1a892a58f694efa57c2a9cd4..c079892aeafa964e79a9757cb01cf5686bcbddad 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -26,7 +26,7 @@ class Network(QObject): nodes_changed = pyqtSignal() new_block_mined = pyqtSignal(int) - def __init__(self, network_manager, currency, nodes): + def __init__(self, currency, nodes): """ Constructor of a network @@ -40,12 +40,11 @@ class Network(QObject): self.add_node(n) self.currency = currency self._must_crawl = False - self.network_manager = network_manager self._block_found = self.latest_block_hash self._timer = QTimer() @classmethod - def create(cls, network_manager, node): + def create(cls, node): """ Create a new network with one knew node Crawls the nodes from the first node to build the @@ -54,7 +53,7 @@ class Network(QObject): :param node: The first knew node of the network """ nodes = [node] - network = cls(network_manager, node.currency, nodes) + network = cls(node.currency, nodes) return network def merge_with_json(self, json_data): @@ -65,7 +64,7 @@ class Network(QObject): :param dict json_data: Nodes in json format """ for data in json_data: - node = Node.from_json(self.network_manager, self.currency, data) + node = Node.from_json(self.currency, data) if node.pubkey not in [n.pubkey for n in self.nodes]: self.add_node(node) logging.debug("Loading : {:}".format(data['pubkey'])) @@ -86,7 +85,7 @@ class Network(QObject): other_node.state = node.state @classmethod - def from_json(cls, network_manager, currency, json_data): + def from_json(cls, currency, json_data): """ Load a network from a configured community @@ -95,9 +94,9 @@ class Network(QObject): """ nodes = [] for data in json_data: - node = Node.from_json(network_manager, currency, data) + node = Node.from_json(currency, data) nodes.append(node) - network = cls(network_manager, currency, nodes) + network = cls(currency, nodes) # We block the signals until loading the nodes cache return network @@ -320,7 +319,7 @@ class Network(QObject): pubkeys = [n.pubkey for n in self.nodes] if peer.pubkey not in pubkeys: logging.debug("New node found : {0}".format(peer.pubkey[:5])) - node = Node.from_peer(self.network_manager, self.currency, peer, pubkey) + node = Node.from_peer(self.currency, peer, pubkey) self.add_node(node) self.nodes_changed.emit() diff --git a/src/cutecoin/core/net/node.py b/src/cutecoin/core/net/node.py index d90f29a280b1b6cc3d0b3a4d8f5e7aac1fb69367..f8b5f9b2ddd4b7dfaa2565a6d4eef44ce587376b 100644 --- a/src/cutecoin/core/net/node.py +++ b/src/cutecoin/core/net/node.py @@ -38,13 +38,12 @@ class Node(QObject): changed = pyqtSignal() neighbour_found = pyqtSignal(Peer, str) - def __init__(self, network_manager, currency, endpoints, uid, pubkey, block, + def __init__(self, currency, endpoints, uid, pubkey, block, state, last_change, last_merkle, software, version, fork_window): """ Constructor """ super().__init__() - self.network_manager = network_manager self._endpoints = endpoints self._uid = uid self._pubkey = pubkey @@ -60,7 +59,7 @@ class Node(QObject): @classmethod @asyncio.coroutine - def from_address(cls, network_manager, currency, address, port): + def from_address(cls, currency, address, port): """ Factory method to get a node from a given address @@ -78,7 +77,7 @@ class Node(QObject): if peer.currency != currency: raise InvalidNodeCurrency(peer.currency, currency) - node = cls(network_manager, peer.currency, + node = cls(peer.currency, [Endpoint.from_inline(e.inline()) for e in peer.endpoints], "", peer.pubkey, None, Node.ONLINE, time.time(), {'root': "", 'leaves': []}, "", "", 0) @@ -86,7 +85,7 @@ class Node(QObject): return node @classmethod - def from_peer(cls, network_manager, currency, peer, pubkey): + def from_peer(cls, currency, peer, pubkey): """ Factory method to get a node from a peer document. @@ -98,7 +97,7 @@ class Node(QObject): if peer.currency != currency: raise InvalidNodeCurrency(peer.currency, currency) - node = cls(network_manager, peer.currency, peer.endpoints, + node = cls(peer.currency, peer.endpoints, "", pubkey, bma.blockchain.Block.null_value, Node.ONLINE, time.time(), {'root': "", 'leaves': []}, @@ -107,7 +106,7 @@ class Node(QObject): return node @classmethod - def from_json(cls, network_manager, currency, data): + def from_json(cls, currency, data): endpoints = [] uid = "" pubkey = "" @@ -148,7 +147,7 @@ class Node(QObject): if 'fork_window' in data: fork_window = data['fork_window'] - node = cls(network_manager, currency, endpoints, + node = cls(currency, endpoints, uid, pubkey, block, state, last_change, {'root': "", 'leaves': []}, diff --git a/src/cutecoin/gui/process_cfg_community.py b/src/cutecoin/gui/process_cfg_community.py index 9e6625960a595767f39dd06b803ec80d81f385fa..8a102051e526991b89ee72660115920f60522682 100644 --- a/src/cutecoin/gui/process_cfg_community.py +++ b/src/cutecoin/gui/process_cfg_community.py @@ -59,9 +59,9 @@ class StepPageInit(Step): server = self.config_dialog.lineedit_server.text() port = self.config_dialog.spinbox_port.value() logging.debug("Is valid ? ") - self.node = yield from Node.from_address(self.config_dialog.app.network_manager, None, server, port) + self.node = yield from Node.from_address(None, server, port) if self.node: - community = Community.create(self.app.network_manager, self.node) + community = Community.create(self.node) identity = yield from self.app.identities_registry.future_find(self.account.pubkey, community) if identity.blockchain_state == BlockchainState.NOT_FOUND: self.config_dialog.label_error.setText(self.tr("Could not find your identity on the network.")) @@ -81,9 +81,9 @@ class StepPageInit(Step): server = self.config_dialog.lineedit_server.text() port = self.config_dialog.spinbox_port.value() logging.debug("Is valid ? ") - self.node = yield from Node.from_address(self.config_dialog.app.network_manager, None, server, port) + self.node = yield from Node.from_address(None, server, port) if self.node: - community = Community.create(self.app.network_manager, self.node) + community = Community.create(self.node) identity = yield from self.app.identities_registry.future_find(self.account.pubkey, community) if identity.blockchain_state == BlockchainState.NOT_FOUND: password = yield from self.password_asker.future_exec() @@ -138,7 +138,7 @@ class StepPageInit(Step): """ account = self.config_dialog.account logging.debug("Account : {0}".format(account)) - self.config_dialog.community = Community.create(self.config_dialog.app.network_manager, self.node) + self.config_dialog.community = Community.create(self.node) def display_page(self): self.config_dialog.button_next.hide() @@ -237,7 +237,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): port = self.spinbox_add_port.value() try: - node = yield from Node.from_address(self.app.network_manager, self.community.currency, server, port) + node = yield from Node.from_address(self.community.currency, server, port) self.community.add_node(node) except Exception as e: QMessageBox.critical(self, self.tr("Error"), diff --git a/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py b/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py index 94145436a5fb13094a6658cbfbf0493b95ec6b88..bd120dbdd1a5c1ba823f011502d2185f1c1be85a 100644 --- a/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py +++ b/src/cutecoin/tests/core/txhistory/test_txhistory_loading.py @@ -21,21 +21,20 @@ from ucoinpy.documents.peer import BMAEndpoint class TestTxHistory(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry({}) - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint(PyBMAEndpoint("", "127.0.0.1", "", 50000)) - self.node = Node(self.network_manager, "test_currency", [self.endpoint], + self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", nice_blockchain.bma_blockchain_current, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) - self.network = Network.create(self.network_manager, self.node) + self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) @@ -59,7 +58,7 @@ class TestTxHistory(unittest.TestCase): mock = nice_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) + received_list = [] self.lp.run_until_complete(self.wallet.caches[self.community.currency]. refresh(self.community, received_list)) diff --git a/src/cutecoin/tests/gui/certification/test_certification.py b/src/cutecoin/tests/gui/certification/test_certification.py index b16e784b05bb46700958922e7b2099b2b277d0b0..2c75ddb7f9aa7aa7a80e4ace4cf128a80698cb88 100644 --- a/src/cutecoin/tests/gui/certification/test_certification.py +++ b/src/cutecoin/tests/gui/certification/test_certification.py @@ -26,21 +26,20 @@ from ucoinpy.api import bma class TestCertificationDialog(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry({}) - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50000) - self.node = Node(self.network_manager, "test_currency", [self.endpoint], + self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) - self.network = Network.create(self.network_manager, self.node) + self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) @@ -66,7 +65,6 @@ class TestCertificationDialog(unittest.TestCase): mock = init_new_community.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) certification_dialog = CertificationDialog(self.application, self.account, diff --git a/src/cutecoin/tests/gui/identities_tab/test_identities_table.py b/src/cutecoin/tests/gui/identities_tab/test_identities_table.py index 7e9ae2ab117ded171db241ee77b487696c9f1522..b5e8c936906b98afc860eedf28861f688fa6cb53 100644 --- a/src/cutecoin/tests/gui/identities_tab/test_identities_table.py +++ b/src/cutecoin/tests/gui/identities_tab/test_identities_table.py @@ -27,21 +27,20 @@ from cutecoin.tests import get_application class TestIdentitiesTable(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry() - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50000) - self.node = Node(self.network_manager, "test_currency", [self.endpoint], + self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) - self.network = Network.create(self.network_manager, self.node) + self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) @@ -67,7 +66,6 @@ class TestIdentitiesTable(unittest.TestCase): mock = nice_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) identities_tab = IdentitiesTabWidget(self.application) identities_tab.change_account(self.account, self.password_asker) diff --git a/src/cutecoin/tests/gui/main_window/test_main_window_dialogs.py b/src/cutecoin/tests/gui/main_window/test_main_window_dialogs.py index db842cfde92a8afcb3b19602468524c0842a73af..29051bf66c720677fe840c8abcf03f7ceb621ea9 100644 --- a/src/cutecoin/tests/gui/main_window/test_main_window_dialogs.py +++ b/src/cutecoin/tests/gui/main_window/test_main_window_dialogs.py @@ -19,9 +19,8 @@ class MainWindowDialogsTest(unittest.TestCase): self.qapplication = get_application() self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) - network_manager = QNetworkAccessManager() - self.application = Application(self.qapplication, self.lp, network_manager, IdentitiesRegistry()) + self.application = Application(self.qapplication, self.lp, IdentitiesRegistry()) self.main_window = MainWindow(self.application) def tearDown(self): diff --git a/src/cutecoin/tests/gui/main_window/test_main_window_menus.py b/src/cutecoin/tests/gui/main_window/test_main_window_menus.py index 95c3e6e12607d05d2523681b8970342baaca1de9..6fe831e8dfd3d3b0bc8b94e1b79b08b9e104ac2e 100644 --- a/src/cutecoin/tests/gui/main_window/test_main_window_menus.py +++ b/src/cutecoin/tests/gui/main_window/test_main_window_menus.py @@ -16,7 +16,7 @@ class MainWindowMenusTest(unittest.TestCase): self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) - self.application = Application(self.qapplication, self.lp, None, None) + self.application = Application(self.qapplication, self.lp, None) self.main_window = MainWindow(self.application) def tearDown(self): diff --git a/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py b/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py index cd6808c164b50e1668a6b507bc436946e1199220..887ff99166ac1ddc1aef23fdf62bf3fbe13639ce 100644 --- a/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py +++ b/src/cutecoin/tests/gui/process_cfg_account/test_add_account.py @@ -19,13 +19,12 @@ from cutecoin.tests import get_application class ProcessAddCommunity(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry({}) - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False # Salt/password : "testcutecoin/testcutecoin" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ diff --git a/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py b/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py index 9cacc9e260448fa53da3f70d6b275dcc3349044a..c7d112e5f20c4e274e501dbaf9b2dee31585e664 100644 --- a/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py +++ b/src/cutecoin/tests/gui/process_cfg_community/test_add_community.py @@ -22,13 +22,12 @@ from cutecoin.tests import get_application class ProcessAddCommunity(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry({}) - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False # Salt/password : "testcutecoin/testcutecoin" # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ @@ -48,7 +47,6 @@ class ProcessAddCommunity(unittest.TestCase): mock = new_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) process_community = ProcessConfigureCommunity(self.application, self.account, @@ -107,7 +105,6 @@ class ProcessAddCommunity(unittest.TestCase): mock = new_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) process_community = ProcessConfigureCommunity(self.application, self.account, @@ -160,7 +157,6 @@ class ProcessAddCommunity(unittest.TestCase): mock = nice_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) process_community = ProcessConfigureCommunity(self.application, self.account, diff --git a/src/cutecoin/tests/gui/transfer/test_transfer.py b/src/cutecoin/tests/gui/transfer/test_transfer.py index f3c35f4ff061d4ff80e3af865e1ff3e5a7264bf0..e97c8790f247769799e3f34f0c432660880b3a82 100644 --- a/src/cutecoin/tests/gui/transfer/test_transfer.py +++ b/src/cutecoin/tests/gui/transfer/test_transfer.py @@ -27,21 +27,20 @@ from ucoinpy.api import bma class TestTransferDialog(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry({}) - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50000) - self.node = Node(self.network_manager, "test_currency", [self.endpoint], + self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) - self.network = Network.create(self.network_manager, self.node) + self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) @@ -67,7 +66,6 @@ class TestTransferDialog(unittest.TestCase): mock = nice_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) transfer_dialog = TransferMoneyDialog(self.application, self.account, diff --git a/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py b/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py index 8b6240faa0fa50e3c273eea2f75fd63de13b44b4..72e1fc8a2d52e054d5d0ad416d3bd068826211cc 100644 --- a/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py +++ b/src/cutecoin/tests/gui/wot_tab/test_wot_tab.py @@ -26,21 +26,20 @@ from cutecoin.tests import get_application class TestIdentitiesTable(unittest.TestCase): def setUp(self): self.qapplication = get_application() - self.network_manager = MockNetworkAccessManager() QLocale.setDefault(QLocale("en_GB")) self.lp = quamash.QEventLoop(self.qapplication) asyncio.set_event_loop(self.lp) self.identities_registry = IdentitiesRegistry() - self.application = Application(self.qapplication, self.lp, self.network_manager, self.identities_registry) + self.application = Application(self.qapplication, self.lp, self.identities_registry) self.application.preferences['notifications'] = False self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50000) - self.node = Node(self.network_manager, "test_currency", [self.endpoint], + self.node = Node("test_currency", [self.endpoint], "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk", None, Node.ONLINE, time.time(), {}, "ucoin", "0.14.0", 0) - self.network = Network.create(self.network_manager, self.node) + self.network = Network.create(self.node) self.bma_access = BmaAccess.create(self.network) self.community = Community("test_currency", self.network, self.bma_access) @@ -66,7 +65,6 @@ class TestIdentitiesTable(unittest.TestCase): mock = nice_blockchain.get_mock() time.sleep(2) logging.debug(mock.pretend_url) - self.network_manager.set_mock_path(mock.pretend_url) API.reverse_url = pretender_reversed(mock.pretend_url) wot_tab = WotTabWidget(self.application) future = asyncio.Future() diff --git a/src/cutecoin/tests/mocks/bma/nice_blockchain.py b/src/cutecoin/tests/mocks/bma/nice_blockchain.py index c11b82d5c470ff9a44cebc22055fad870c1a28de..606fc66066635f13c9cad16d2ec5c22c47688e7d 100644 --- a/src/cutecoin/tests/mocks/bma/nice_blockchain.py +++ b/src/cutecoin/tests/mocks/bma/nice_blockchain.py @@ -273,7 +273,7 @@ def get_mock(): times=FOREVER, headers={'Content-Type': 'application/json'}) - mock.when('GET /blockchain/with/UD')\ + mock.when('GET /blockchain/with/[UD|ud]')\ .reply(body=bytes(json.dumps(bma_with_ud), "utf-8"), status=200, times=FOREVER, diff --git a/src/cutecoin/tests/stubs/core/net/network.py b/src/cutecoin/tests/stubs/core/net/network.py index 3d2de537d84529bd64056c7d2b25094d8c08be87..d37d8adf2faadc326bd319108644beb880efa4af 100644 --- a/src/cutecoin/tests/stubs/core/net/network.py +++ b/src/cutecoin/tests/stubs/core/net/network.py @@ -16,7 +16,7 @@ class Network(QObject): nodes_changed = pyqtSignal() new_block_mined = pyqtSignal(int) - def __init__(self, network_manager, currency, nodes): + def __init__(self, currency, nodes): """ Constructor of a network @@ -25,21 +25,20 @@ class Network(QObject): """ super().__init__() self.currency = currency - self.network_manager = network_manager @classmethod - def create(cls, network_manager, node): + def create(cls, node): nodes = [node] - network = cls(network_manager, node.currency, nodes) + network = cls(node.currency, nodes) return network def merge_with_json(self, json_data): pass @classmethod - def from_json(cls, network_manager, currency, json_data): + def from_json(cls, currency, json_data): nodes = [] - network = cls(network_manager, currency, nodes) + network = cls(currency, nodes) return network def jsonify(self):