|
1 | 1 | import json |
2 | | -import os |
3 | 2 | from pathlib import Path |
4 | | -from typing import Any, List |
| 3 | +from typing import Any |
5 | 4 |
|
6 | 5 | from multiversx_sdk_cli.cli import main |
7 | 6 |
|
@@ -89,93 +88,5 @@ def test_create_multi_transfer_transaction(capsys: Any): |
89 | 88 | assert signature == "575b029d52ff5ffbfb7bab2f04052de88a6f7d022a6ad368459b8af9acaed3717d3f95db09f460649a8f405800838bc2c432496bd03c9039ea166bd32b84660e" |
90 | 89 |
|
91 | 90 |
|
92 | | -def test_create_and_save_inner_transaction(): |
93 | | - return_code = main([ |
94 | | - "tx", "new", |
95 | | - "--pem", str(testdata_path / "alice.pem"), |
96 | | - "--receiver", "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx", |
97 | | - "--nonce", "77", |
98 | | - "--gas-limit", "500000", |
99 | | - "--relayer", "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8", |
100 | | - "--inner-transactions-outfile", str(testdata_out / "inner_transactions.json"), |
101 | | - "--chain", "T", |
102 | | - ]) |
103 | | - assert False if return_code else True |
104 | | - assert Path(testdata_out / "inner_transactions.json").is_file() |
105 | | - |
106 | | - |
107 | | -def test_create_and_append_inner_transaction(): |
108 | | - return_code = main([ |
109 | | - "tx", "new", |
110 | | - "--pem", str(testdata_path / "alice.pem"), |
111 | | - "--receiver", "erd1fggp5ru0jhcjrp5rjqyqrnvhr3sz3v2e0fm3ktknvlg7mcyan54qzccnan", |
112 | | - "--nonce", "1234", |
113 | | - "--gas-limit", "50000", |
114 | | - "--relayer", "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8", |
115 | | - "--inner-transactions-outfile", str(testdata_out / "inner_transactions.json"), |
116 | | - "--chain", "T", |
117 | | - ]) |
118 | | - assert False if return_code else True |
119 | | - |
120 | | - with open(testdata_out / "inner_transactions.json", "r") as file: |
121 | | - json_file = json.load(file) |
122 | | - |
123 | | - inner_txs: List[Any] = json_file["innerTransactions"] |
124 | | - assert len(inner_txs) == 2 |
125 | | - |
126 | | - |
127 | | -def test_create_invalid_relayed_transaction(): |
128 | | - return_code = main([ |
129 | | - "tx", "new", |
130 | | - "--pem", str(testdata_path / "testUser.pem"), |
131 | | - "--receiver", "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5", |
132 | | - "--nonce", "987", |
133 | | - "--gas-limit", "5000000", |
134 | | - "--inner-transactions", str(testdata_out / "inner_transactions.json"), |
135 | | - "--data", "test data", |
136 | | - "--chain", "T", |
137 | | - ]) |
138 | | - assert return_code |
139 | | - |
140 | | - |
141 | | -def test_create_relayer_transaction(capsys: Any): |
142 | | - return_code = main([ |
143 | | - "tx", "new", |
144 | | - "--pem", str(testdata_path / "testUser.pem"), |
145 | | - "--receiver", "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5", |
146 | | - "--nonce", "987", |
147 | | - "--gas-limit", "5000000", |
148 | | - "--inner-transactions", str(testdata_out / "inner_transactions.json"), |
149 | | - "--chain", "T", |
150 | | - ]) |
151 | | - # remove test file to ensure consistency when running test file locally |
152 | | - os.remove(testdata_out / "inner_transactions.json") |
153 | | - |
154 | | - assert False if return_code else True |
155 | | - |
156 | | - tx = _read_stdout(capsys) |
157 | | - tx_json = json.loads(tx)["emittedTransaction"] |
158 | | - |
159 | | - assert tx_json["sender"] == "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5" |
160 | | - assert tx_json["receiver"] == "erd1cqqxak4wun7508e0yj9ng843r6hv4mzd0hhpjpsejkpn9wa9yq8sj7u2u5" |
161 | | - assert tx_json["gasLimit"] == 5000000 |
162 | | - assert tx_json["nonce"] == 987 |
163 | | - assert tx_json["chainID"] == "T" |
164 | | - |
165 | | - # should be the two inner transactions created in the tests above |
166 | | - inner_transactions = tx_json["innerTransactions"] |
167 | | - assert len(inner_transactions) == 2 |
168 | | - |
169 | | - assert inner_transactions[0]["sender"] == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" |
170 | | - assert inner_transactions[0]["receiver"] == "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx" |
171 | | - assert inner_transactions[0]["nonce"] == 77 |
172 | | - assert inner_transactions[0]["relayer"] == "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" |
173 | | - |
174 | | - assert inner_transactions[1]["sender"] == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" |
175 | | - assert inner_transactions[1]["receiver"] == "erd1fggp5ru0jhcjrp5rjqyqrnvhr3sz3v2e0fm3ktknvlg7mcyan54qzccnan" |
176 | | - assert inner_transactions[1]["nonce"] == 1234 |
177 | | - assert inner_transactions[1]["relayer"] == "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8" |
178 | | - |
179 | | - |
180 | 91 | def _read_stdout(capsys: Any) -> str: |
181 | 92 | return capsys.readouterr().out.strip() |
0 commit comments