-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests for transaction improvements #5879
Merged
antdanchenko
merged 1 commit into
transaction-improvements
from
tests-transaction-improvements
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import pytest | ||
import time | ||
import uuid | ||
from conftest import user_1, user_2, option | ||
from test_cases import SignalTestCase | ||
|
||
|
||
@pytest.mark.rpc | ||
@pytest.mark.transaction | ||
@pytest.mark.wallet | ||
class TestTransactionFromRoute(SignalTestCase): | ||
|
||
await_signals = [ | ||
"wallet.suggested.routes", | ||
"wallet.router.sign-transactions", | ||
"wallet.router.sending-transactions-started", | ||
"wallet.transaction.status-changed", | ||
"wallet.router.transactions-sent" | ||
] | ||
|
||
def test_tx_from_route(self): | ||
|
||
_uuid = str(uuid.uuid4()) | ||
amount_in = "0xde0b6b3a7640000" | ||
|
||
method = "wallet_getSuggestedRoutesAsync" | ||
params = [ | ||
{ | ||
"uuid": _uuid, | ||
"sendType": 0, | ||
"addrFrom": user_1.address, | ||
"addrTo": user_2.address, | ||
"amountIn": amount_in, | ||
"amountOut": "0x0", | ||
"tokenID": "ETH", | ||
"tokenIDIsOwnerToken": False, | ||
"toTokenID": "", | ||
"disabledFromChainIDs": [10, 42161], | ||
"disabledToChainIDs": [10, 42161], | ||
"gasFeeMode": 1, | ||
"fromLockedAmount": {} | ||
} | ||
] | ||
response = self.rpc_request(method, params) | ||
self.verify_is_valid_json_rpc_response(response) | ||
|
||
self.wait_for_signal("wallet.suggested.routes") | ||
assert self.received_signals[ | ||
'wallet.suggested.routes']['event']['Uuid'] == _uuid | ||
|
||
method = "wallet_buildTransactionsFromRoute" | ||
params = [ | ||
{ | ||
"uuid": _uuid, | ||
"slippagePercentage": 0 | ||
} | ||
] | ||
response = self.rpc_request(method, params) | ||
self.verify_is_valid_json_rpc_response(response) | ||
|
||
self.wait_for_signal("wallet.router.sign-transactions") | ||
|
||
assert self.received_signals[ | ||
'wallet.router.sign-transactions']['event']['signingDetails']['signOnKeycard'] == False | ||
transaction_hashes = self.received_signals[ | ||
'wallet.router.sign-transactions']['event']['signingDetails']['hashes'] | ||
|
||
assert transaction_hashes, "Transaction hashes are empty!" | ||
|
||
tx_signatures = {} | ||
|
||
for hash in transaction_hashes: | ||
|
||
method = "wallet_signMessage" | ||
params = [ | ||
hash, | ||
user_1.address, | ||
option.password | ||
] | ||
|
||
response = self.rpc_request(method, params) | ||
self.verify_is_valid_json_rpc_response(response) | ||
|
||
if response.json()["result"].startswith("0x"): | ||
tx_signature = response.json()["result"][2:] | ||
|
||
signature = { | ||
"r": tx_signature[:64], | ||
"s": tx_signature[64:128], | ||
"v": tx_signature[128:] | ||
} | ||
|
||
tx_signatures[hash] = signature | ||
|
||
method = "wallet_sendRouterTransactionsWithSignatures" | ||
params = [ | ||
{ | ||
"uuid": _uuid, | ||
"Signatures": tx_signatures | ||
} | ||
] | ||
response = self.rpc_request(method, params) | ||
self.verify_is_valid_json_rpc_response(response) | ||
|
||
tx_status = self.wait_for_signal("wallet.transaction.status-changed") | ||
|
||
|
||
assert tx_status["event"]["chainId"] == 31337 | ||
assert tx_status["event"]["status"] == "Success" | ||
tx_hash = tx_status["event"]["hash"] | ||
|
||
method = "eth_getTransactionByHash" | ||
params = [tx_hash] | ||
|
||
response = self.rpc_request(method, params, url=option.anvil_url) | ||
self.verify_is_valid_json_rpc_response(response) | ||
tx_details = response.json()["result"] | ||
|
||
assert tx_details["value"] == amount_in | ||
assert tx_details["to"] == user_2.address | ||
assert tx_details["from"] == user_1.address |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antdanchenko since we're resolving selected chains based on the entry in the
networks
table, and since the statusgo is run with the config set inintegration-tests/config.json
(that provides config for the Anvil chain only), the result will be the same either we provide an empty list here or the list with all but the Anvil chain id.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the note, we will add more anvil networks and bridges in future to simulate proper route, but for now let's keep as it is