Skip to content

Commit

Permalink
fix guardian for contract upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed May 22, 2023
1 parent f0437fc commit 109c3e1
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/cli_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def upgrade(args: Any):
contract.address = Address(contract_address)
sender = _prepare_sender(args)

tx = contract.upgrade(sender, arguments, gas_price, gas_limit, value, chain, version, args.guardian_address, args.options)
tx = contract.upgrade(sender, arguments, gas_price, gas_limit, value, chain, version, args.guardian, args.options)

if args.guardian:
tx = cosign_transaction(tx, args.guardian_service_url, args.guardian_2fa_code)
Expand Down
90 changes: 90 additions & 0 deletions multiversx_sdk_cli/tests/test_cli_contracts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from pathlib import Path
from multiversx_sdk_cli.cli import main


def test_contract_deploy():
parent = Path(__file__).parent
output_file = parent / "testdata-out" / "deploy.json"

main(
[
"contract",
"deploy",
"--bytecode",
f"{parent}/testdata/adder.wasm",
"--pem",
f"{parent}/testdata/testUser.pem",
"--proxy",
"https://testnet-api.multiversx.com",
"--chain",
"T",
"--recall-nonce",
"--gas-limit",
"5000000",
"--arguments",
"0",
"--outfile",
str(output_file),
]
)
assert Path.is_file(output_file) == True


def test_contract_upgrade():
parent = Path(__file__).parent
output_file = parent / "testdata-out" / "upgrade.json"
contract_address = "erd1qqqqqqqqqqqqqpgq5l9jl0j0gnqmm7hn82zaydwux3s5xuwkyq8srt5vsy"

main(
[
"contract",
"upgrade",
contract_address,
"--bytecode",
f"{parent}/testdata/adder.wasm",
"--pem",
f"{parent}/testdata/testUser.pem",
"--proxy",
"https://testnet-api.multiversx.com",
"--chain",
"T",
"--recall-nonce",
"--gas-limit",
"5000000",
"--arguments",
"0",
"--outfile",
str(output_file),
]
)
assert Path.is_file(output_file) == True


def test_contract_call():
parent = Path(__file__).parent
output_file = parent / "testdata-out" / "call.json"
contract_address = "erd1qqqqqqqqqqqqqpgq5l9jl0j0gnqmm7hn82zaydwux3s5xuwkyq8srt5vsy"

main(
[
"contract",
"call",
contract_address,
"--function",
"add",
"--pem",
f"{parent}/testdata/testUser.pem",
"--proxy",
"https://testnet-api.multiversx.com",
"--chain",
"T",
"--recall-nonce",
"--gas-limit",
"5000000",
"--arguments",
"5",
"--outfile",
str(output_file),
]
)
assert Path.is_file(output_file) == True
Binary file added multiversx_sdk_cli/tests/testdata/adder.wasm
Binary file not shown.

0 comments on commit 109c3e1

Please sign in to comment.