-
Notifications
You must be signed in to change notification settings - Fork 36
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
Added RelayedV3 support #457
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
from pathlib import Path | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from multiversx_sdk_cli.cli import main | ||
|
||
testdata_path = Path(__file__).parent / "testdata" | ||
|
@@ -105,5 +107,62 @@ def test_create_multi_transfer_transaction_with_single_egld_transfer(capsys: Any | |
assert data == "MultiESDTNFTTransfer@8049d639e5a6980d1cd2392abcce41029cda74a1563523a202f09641cc2618f8@01@45474c442d303030303030@@0de0b6b3a7640000" | ||
|
||
|
||
def test_create_relayed_v3_transaction(capsys: Any): | ||
return_code = main([ | ||
"tx", "new", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not possible to take a user transaction, already signed, and sign it with a relayer? Maybe I think we should allow users to decouple (in a way or another) the step of signing as user from the step of signing as relayer. Maybe brainstorm this a bit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, sounds like a good idea. Added a new command, |
||
"--pem", str(testdata_path / "alice.pem"), | ||
"--receiver", "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx", | ||
"--nonce", "7", | ||
"--gas-limit", "1300000", | ||
"--value", "1000000000000000000", | ||
"--chain", "T", | ||
"--relayer", "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5", | ||
"--relayer-pem", str(testdata_path / "testUser.pem") | ||
]) | ||
assert return_code == 0 | ||
|
||
tx = _read_stdout(capsys) | ||
tx_json = json.loads(tx)["emittedTransaction"] | ||
assert tx_json["sender"] == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" | ||
assert tx_json["receiver"] == "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx" | ||
assert tx_json["relayer"] == "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5" | ||
assert tx_json["signature"] | ||
assert tx_json["relayerSignature"] | ||
|
||
# no relayer wallet provided | ||
return_code = main([ | ||
"tx", "new", | ||
"--pem", str(testdata_path / "alice.pem"), | ||
"--receiver", "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx", | ||
"--nonce", "7", | ||
"--gas-limit", "1300000", | ||
"--value", "1000000000000000000", | ||
"--chain", "T", | ||
"--relayer", "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5" | ||
]) | ||
assert return_code == 0 | ||
tx = _read_stdout(capsys) | ||
tx_json = json.loads(tx)["emittedTransaction"] | ||
assert tx_json["sender"] == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" | ||
assert tx_json["receiver"] == "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx" | ||
assert tx_json["relayer"] == "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5" | ||
assert tx_json["signature"] | ||
assert not tx_json["relayerSignature"] | ||
|
||
# incorrect relayer wallet | ||
with pytest.raises(Exception, match="Relayer address does not match the provided relayer wallet."): | ||
main([ | ||
"tx", "new", | ||
"--pem", str(testdata_path / "alice.pem"), | ||
"--receiver", "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx", | ||
"--nonce", "7", | ||
"--gas-limit", "1300000", | ||
"--value", "1000000000000000000", | ||
"--chain", "T", | ||
"--relayer", "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5", | ||
"--relayer-pem", str(testdata_path / "alice.pem") | ||
]) | ||
|
||
|
||
def _read_stdout(capsys: Any) -> str: | ||
return capsys.readouterr().out.strip() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ requests-cache | |
rich==13.3.4 | ||
argcomplete==3.2.2 | ||
|
||
multiversx-sdk==0.16.3 | ||
multiversx-sdk==0.17.0 |
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.
👍