Skip to content

Commit 19f413a

Browse files
hackaugustopalango
authored andcommitted
Removed the class App.
App was an umbrella class which used to contian a list of services, slowly the class was dehidrated to a proxy class, which only instantiate the RaidenService. This commit removes that one level of indirection which simplifies a lot of code.
1 parent 2b24450 commit 19f413a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1430
-1443
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ actually expect the crash of a `RaidenService` instance within the test
536536
and want to ignore it.
537537

538538
Sometimes a test using `@raise_on_failure` needs to restart nodes or start
539-
new ones during the test. Simply calling `App.start` to achieve this will
539+
new ones during the test. Simply calling `Raiden.start` to achieve this will
540540
make `@raise_on_failure` lose track of the app. Therefore, such tests should
541541
always use the `restart_node` fixture and call `restart_node(app)` instead.
542542

raiden/app.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

raiden/network/transport/matrix/transport.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ def __init__(self, config: MatrixTransportConfig, environment: Environment) -> N
356356
)
357357

358358
def _http_retry_delay() -> Iterable[float]:
359-
# below constants are defined in raiden.app.App.DEFAULT_CONFIG
360359
return timeout_exponential_backoff(
361360
self._config.retries_before_backoff,
362361
self._config.retry_interval_initial,

raiden/raiden_service.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
InvalidDBData,
4545
InvalidSecret,
4646
InvalidSecretHash,
47+
InvalidSettleTimeout,
4748
PaymentConflict,
4849
RaidenRecoverableError,
4950
RaidenUnrecoverableError,
@@ -316,6 +317,32 @@ def __init__(
316317
api_server: Optional[APIServer] = None,
317318
) -> None:
318319
super().__init__()
320+
321+
# check that the settlement timeout fits the limits of the contract
322+
settlement_timeout_min = raiden_bundle.token_network_registry.settlement_timeout_min(
323+
BLOCK_ID_LATEST
324+
)
325+
settlement_timeout_max = raiden_bundle.token_network_registry.settlement_timeout_max(
326+
BLOCK_ID_LATEST
327+
)
328+
invalid_settle_timeout = (
329+
config.settle_timeout < settlement_timeout_min
330+
or config.settle_timeout > settlement_timeout_max
331+
or config.settle_timeout < config.reveal_timeout * 2
332+
)
333+
if invalid_settle_timeout:
334+
raise InvalidSettleTimeout(
335+
(
336+
"Settlement timeout for Registry contract {} must "
337+
"be in range [{}, {}], is {}"
338+
).format(
339+
to_checksum_address(raiden_bundle.token_network_registry.address),
340+
settlement_timeout_min,
341+
settlement_timeout_max,
342+
config.settle_timeout,
343+
)
344+
)
345+
319346
self.tokennetworkaddrs_to_connectionmanagers: ConnectionManagerDict = dict()
320347
self.targets_to_identifiers_to_statuses: StatusesDict = defaultdict(dict)
321348

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33
from raiden.api.rest import APIServer
4-
from raiden.app import App
4+
from raiden.raiden_service import RaidenService
55
from raiden.tests.integration.api.utils import prepare_api_server
66
from raiden.utils.typing import List
77

@@ -11,7 +11,7 @@
1111
# the server is no longer running even though the teardown has not
1212
# been invoked.
1313
@pytest.fixture
14-
def api_server_test_instance(raiden_network: List[App]) -> APIServer:
14+
def api_server_test_instance(raiden_network: List[RaidenService]) -> APIServer:
1515
api_server = prepare_api_server(raiden_network[0])
1616

1717
return api_server

raiden/tests/integration/api/rest/test_channel.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from raiden.api.rest import APIServer
99
from raiden.constants import BLOCK_ID_LATEST, NULL_ADDRESS_HEX
10+
from raiden.raiden_service import RaidenService
1011
from raiden.tests.integration.api.rest.test_rest import DEPOSIT_FOR_TEST_API_DEPOSIT_LIMIT
1112
from raiden.tests.integration.api.rest.utils import (
1213
api_url_for,
@@ -21,7 +22,7 @@
2122
from raiden.tests.utils.events import check_dict_nested_attrs
2223
from raiden.transfer import views
2324
from raiden.transfer.state import ChannelState
24-
from raiden.utils.typing import TokenAmount
25+
from raiden.utils.typing import List, TokenAmount
2526
from raiden.waiting import wait_for_participant_deposit
2627
from raiden_contracts.constants import TEST_SETTLE_TIMEOUT_MAX, TEST_SETTLE_TIMEOUT_MIN
2728

@@ -242,7 +243,7 @@ def test_api_channel_open_and_deposit(
242243
@pytest.mark.parametrize("enable_rest_api", [True])
243244
def test_api_channel_open_and_deposit_race(
244245
api_server_test_instance: APIServer,
245-
raiden_network,
246+
raiden_network: List[RaidenService],
246247
token_addresses,
247248
reveal_timeout,
248249
token_network_registry_address,
@@ -319,11 +320,11 @@ def test_api_channel_open_and_deposit_race(
319320
exception = Exception(f"Expected deposit not seen within {timeout_seconds}")
320321
with gevent.Timeout(seconds=timeout_seconds, exception=exception):
321322
wait_for_participant_deposit(
322-
raiden=app0.raiden,
323+
raiden=app0,
323324
token_network_registry_address=token_network_registry_address,
324325
token_address=token_address,
325326
partner_address=to_canonical_address(first_partner_address),
326-
target_address=app0.raiden.address,
327+
target_address=app0.address,
327328
target_balance=deposit_amount,
328329
retry_timeout=retry_timeout,
329330
)
@@ -688,11 +689,11 @@ def test_api_channel_state_change_errors(
688689
@pytest.mark.parametrize("deposit", [1000])
689690
@pytest.mark.parametrize("enable_rest_api", [True])
690691
def test_api_channel_withdraw(
691-
api_server_test_instance: APIServer, raiden_network, token_addresses
692+
api_server_test_instance: APIServer, raiden_network: List[RaidenService], token_addresses
692693
):
693694
_, app1 = raiden_network
694695
token_address = token_addresses[0]
695-
partner_address = app1.raiden.address
696+
partner_address = app1.address
696697

697698
# Withdraw a 0 amount
698699
request = grequests.patch(
@@ -752,11 +753,14 @@ def test_api_channel_withdraw(
752753
@pytest.mark.parametrize("deposit", [0])
753754
@pytest.mark.parametrize("enable_rest_api", [True])
754755
def test_api_channel_set_reveal_timeout(
755-
api_server_test_instance: APIServer, raiden_network, token_addresses, settle_timeout
756+
api_server_test_instance: APIServer,
757+
raiden_network: List[RaidenService],
758+
token_addresses,
759+
settle_timeout,
756760
):
757761
app0, app1 = raiden_network
758762
token_address = token_addresses[0]
759-
partner_address = app1.raiden.address
763+
partner_address = app1.address
760764

761765
request = grequests.patch(
762766
api_url_for(
@@ -796,13 +800,13 @@ def test_api_channel_set_reveal_timeout(
796800
assert_response_with_code(response, HTTPStatus.OK)
797801

798802
token_network_address = views.get_token_network_address_by_token_address(
799-
views.state_from_app(app0), app0.raiden.default_registry.address, token_address
803+
views.state_from_raiden(app0), app0.default_registry.address, token_address
800804
)
801805
assert token_network_address
802806
channel_state = views.get_channelstate_by_token_network_and_partner(
803-
chain_state=views.state_from_raiden(app0.raiden),
807+
chain_state=views.state_from_raiden(app0),
804808
token_network_address=token_network_address,
805-
partner_address=app1.raiden.address,
809+
partner_address=app1.address,
806810
)
807811
assert channel_state
808812

0 commit comments

Comments
 (0)