Skip to content

Commit

Permalink
test_: drop statusd
Browse files Browse the repository at this point in the history
  • Loading branch information
antdanchenko committed Dec 10, 2024
1 parent 5ac75d8 commit aac61ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
12 changes: 6 additions & 6 deletions tests-functional/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

from conftest import option
from constants import user_1, user_2
from test_cases import SignalTestCase
from test_cases import StatusBackendTestCase
from clients.signals import SignalType

@pytest.mark.rpc
@pytest.mark.transaction
@pytest.mark.wallet
@pytest.mark.skip("should migrate to status-backend asap")
class TestTransactionFromRoute(SignalTestCase):
class TestTransactionFromRoute(StatusBackendTestCase):
await_signals = [
SignalType.NODE_LOGIN.value,
SignalType.WALLET_SUGGESTED_ROUTES.value,
SignalType.WALLET_ROUTER_SIGN_TRANSACTIONS.value,
SignalType.WALLET_ROUTER_SENDING_TRANSACTIONS_STARTED.value,
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_tx_from_route(self):
]
response = self.rpc_client.rpc_valid_request(method, params)

routes = self.signal_client.wait_for_signal(SignalType.WALLET_SUGGESTED_ROUTES.value)
routes = self.rpc_client.wait_for_signal(SignalType.WALLET_SUGGESTED_ROUTES.value)
assert routes['event']['Uuid'] == _uuid

method = "wallet_buildTransactionsFromRoute"
Expand All @@ -57,7 +57,7 @@ def test_tx_from_route(self):
]
response = self.rpc_client.rpc_valid_request(method, params)

wallet_router_sign_transactions = self.signal_client.wait_for_signal(
wallet_router_sign_transactions = self.rpc_client.wait_for_signal(
SignalType.WALLET_ROUTER_SIGN_TRANSACTIONS.value)

assert wallet_router_sign_transactions['event']['signingDetails']['signOnKeycard'] == False
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_tx_from_route(self):
]
response = self.rpc_client.rpc_valid_request(method, params)

tx_status = self.signal_client.wait_for_signal(
tx_status = self.rpc_client.wait_for_signal(
SignalType.WALLET_TRANSACTION_STATUS_CHANGED.value)

assert tx_status["event"]["chainId"] == 31337
Expand Down
33 changes: 16 additions & 17 deletions tests-functional/tests/test_wallet_activity_session.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import json
import random

import wallet_utils
import pytest

from constants import user_1
from test_cases import SignalTestCase

import wallet_utils

import logging
from test_cases import StatusBackendTestCase
from clients.signals import SignalType

EventActivityFilteringDone = "wallet-activity-filtering-done"
EventActivityFilteringUpdate = "wallet-activity-filtering-entries-updated"
Expand All @@ -20,32 +17,34 @@ def validate_entry(entry, tx_data):

@pytest.mark.wallet
@pytest.mark.rpc
class TestWalletActivitySession(SignalTestCase):
await_signals = ["wallet",
@pytest.mark.takoe
class TestWalletActivitySession(StatusBackendTestCase):
await_signals = [
SignalType.NODE_LOGIN.value,
"wallet",
"wallet.suggested.routes",
"wallet.router.sign-transactions",
"wallet.router.sending-transactions-started",
"wallet.transaction.status-changed",
"wallet.router.transactions-sent"]

def setup_method(self):
super().setup_method()
self.request_id = str(random.randint(1, 8888))

def test_wallet_start_activity_filter_session(self):
tx_data = [] # (routes, build_tx, tx_signatures, tx_status)
# Set up a transactions for account before starting session
tx_data.append(wallet_utils.send_router_transaction(self.rpc_client, self.signal_client))
tx_data.append(wallet_utils.send_router_transaction(self.rpc_client))

# Start activity session
method = "wallet_startActivityFilterSessionV2"
params = [[user_1.address], [self.network_id],
{"period": {"startTimestamp": 0, "endTimestamp": 0}, "types": [], "statuses": [],
"counterpartyAddresses": [], "assets": [], "collectibles": [], "filterOutAssets": False,
"filterOutCollectibles": False}, 10]
self.signal_client.prepare_wait_for_signal("wallet", 1, lambda signal : signal["event"]["type"] == EventActivityFilteringDone)
self.rpc_client.prepare_wait_for_signal("wallet", 1, lambda signal : signal["event"]["type"] == EventActivityFilteringDone)
response = self.rpc_client.rpc_valid_request(method, params, self.request_id)
event_response = self.signal_client.wait_for_signal("wallet", timeout=10)['event']
event_response = self.rpc_client.wait_for_signal("wallet", timeout=10)['event']

# Check response
sessionID = int(response.json()["result"])
Expand All @@ -60,10 +59,10 @@ def test_wallet_start_activity_filter_session(self):
validate_entry(message['activities'][0], tx_data[-1])

# Trigger new transaction
self.signal_client.prepare_wait_for_signal("wallet", 1, lambda signal : signal["event"]["type"] == EventActivitySessionUpdated and signal['event']['requestId'] == sessionID)
tx_data.append(wallet_utils.send_router_transaction(self.rpc_client, self.signal_client))
self.rpc_client.prepare_wait_for_signal("wallet", 1, lambda signal : signal["event"]["type"] == EventActivitySessionUpdated and signal['event']['requestId'] == sessionID)
tx_data.append(wallet_utils.send_router_transaction(self.rpc_client))
print(tx_data[-1])
event_response = self.signal_client.wait_for_signal("wallet", timeout=10)['event']
event_response = self.rpc_client.wait_for_signal("wallet", timeout=10)['event']

# Check response event
assert int(event_response['requestId']) == sessionID
Expand All @@ -73,9 +72,9 @@ def test_wallet_start_activity_filter_session(self):
# Reset activity session
method = "wallet_resetActivityFilterSession"
params = [sessionID, 10]
self.signal_client.prepare_wait_for_signal("wallet", 1, lambda signal : signal["event"]["type"] == EventActivityFilteringDone and signal['event']['requestId'] == sessionID)
self.rpc_client.prepare_wait_for_signal("wallet", 1, lambda signal : signal["event"]["type"] == EventActivityFilteringDone and signal['event']['requestId'] == sessionID)
response = self.rpc_client.rpc_valid_request(method, params, self.request_id)
event_response = self.signal_client.wait_for_signal("wallet", timeout=10)['event']
event_response = self.rpc_client.wait_for_signal("wallet", timeout=10)['event']

# Check response event
assert int(event_response['requestId']) == sessionID
Expand Down
22 changes: 11 additions & 11 deletions tests-functional/wallet_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def verify_json_schema(response, method):
jsonschema.validate(instance=response,
schema=json.load(schema))

def get_suggested_routes(rpc_client, signal_client, **kwargs):
def get_suggested_routes(rpc_client, **kwargs):
_uuid = str(uuid.uuid4())
amount_in = "0xde0b6b3a7640000"

Expand Down Expand Up @@ -43,15 +43,15 @@ def get_suggested_routes(rpc_client, signal_client, **kwargs):
f"Warning: The key '{key}' does not exist in the input_params parameters and will be ignored.")
params = [input_params]

signal_client.prepare_wait_for_signal("wallet.suggested.routes", 1)
rpc_client.prepare_wait_for_signal("wallet.suggested.routes", 1)
_ = rpc_client.rpc_valid_request(method, params)

routes = signal_client.wait_for_signal("wallet.suggested.routes")
routes = rpc_client.wait_for_signal("wallet.suggested.routes")
assert routes['event']['Uuid'] == _uuid

return routes['event']

def build_transactions_from_route(rpc_client, signal_client, uuid, **kwargs):
def build_transactions_from_route(rpc_client, uuid, **kwargs):
method = "wallet_buildTransactionsFromRoute"
build_tx_params = {
"uuid": uuid,
Expand All @@ -66,7 +66,7 @@ def build_transactions_from_route(rpc_client, signal_client, uuid, **kwargs):
params = [build_tx_params]
_ = rpc_client.rpc_valid_request(method, params)

wallet_router_sign_transactions = signal_client.wait_for_signal("wallet.router.sign-transactions")
wallet_router_sign_transactions = rpc_client.wait_for_signal("wallet.router.sign-transactions")

assert wallet_router_sign_transactions['event']['signingDetails']['signOnKeycard'] == False
transaction_hashes = wallet_router_sign_transactions['event']['signingDetails']['hashes']
Expand Down Expand Up @@ -101,7 +101,7 @@ def sign_messages(rpc_client, hashes):
tx_signatures[hash] = signature
return tx_signatures

def send_router_transactions_with_signatures(rpc_client, signal_client, uuid, tx_signatures):
def send_router_transactions_with_signatures(rpc_client, uuid, tx_signatures):
method = "wallet_sendRouterTransactionsWithSignatures"
params = [
{
Expand All @@ -111,18 +111,18 @@ def send_router_transactions_with_signatures(rpc_client, signal_client, uuid, tx
]
_ = rpc_client.rpc_valid_request(method, params)

tx_status = signal_client.wait_for_signal(
tx_status = rpc_client.wait_for_signal(
"wallet.transaction.status-changed")

assert tx_status["event"]["status"] == "Success"

return tx_status["event"]

def send_router_transaction(rpc_client, signal_client, **kwargs):
routes = get_suggested_routes(rpc_client, signal_client, **kwargs)
build_tx = build_transactions_from_route(rpc_client, signal_client, routes['Uuid'])
def send_router_transaction(rpc_client, **kwargs):
routes = get_suggested_routes(rpc_client, **kwargs)
build_tx = build_transactions_from_route(rpc_client, routes['Uuid'])
tx_signatures = sign_messages(rpc_client, build_tx['signingDetails']['hashes'])
tx_status = send_router_transactions_with_signatures(rpc_client, signal_client, routes['Uuid'], tx_signatures)
tx_status = send_router_transactions_with_signatures(rpc_client, routes['Uuid'], tx_signatures)
return {
"routes": routes,
"build_tx": build_tx,
Expand Down

0 comments on commit aac61ca

Please sign in to comment.