This repository has been archived by the owner on Oct 27, 2024. It is now read-only.
forked from raiden-network/raiden-services
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Purge old monitor requests from database
Relates to raiden-network#419.
- Loading branch information
Showing
7 changed files
with
159 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .contracts import * # noqa | ||
from .factories import * # noqa | ||
from .server import * # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
from eth_utils import encode_hex, to_checksum_address | ||
|
||
from monitoring_service.states import HashedBalanceProof | ||
from raiden.messages import RequestMonitoring | ||
from raiden.utils.typing import Address, ChannelID, Nonce, TokenAmount, TokenNetworkAddress | ||
from raiden_contracts.tests.utils.address import get_random_privkey | ||
from raiden_contracts.utils.type_aliases import ChainID | ||
from raiden_libs.utils import private_key_to_address | ||
|
||
|
||
@pytest.fixture | ||
def build_request_monitoring(): | ||
non_closing_privkey = get_random_privkey() | ||
non_closing_address = private_key_to_address(non_closing_privkey) | ||
|
||
def f( | ||
chain_id: ChainID = ChainID(1), | ||
amount: TokenAmount = TokenAmount(50), | ||
nonce: Nonce = Nonce(1), | ||
channel_id: ChannelID = ChannelID(1), | ||
) -> RequestMonitoring: | ||
balance_proof = HashedBalanceProof( | ||
channel_identifier=channel_id, | ||
token_network_address=TokenNetworkAddress(b"1" * 20), | ||
chain_id=chain_id, | ||
nonce=nonce, | ||
additional_hash="", | ||
balance_hash=encode_hex(bytes([amount])), | ||
priv_key=get_random_privkey(), | ||
) | ||
request_monitoring = balance_proof.get_request_monitoring( | ||
privkey=non_closing_privkey, | ||
reward_amount=TokenAmount(55), | ||
monitoring_service_contract_address=Address(bytes([11] * 20)), | ||
) | ||
|
||
# usually not a property of RequestMonitoring, but added for convenience in these tests | ||
request_monitoring.non_closing_signer = to_checksum_address( # type: ignore | ||
non_closing_address | ||
) | ||
return request_monitoring | ||
|
||
return f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters