|
| 1 | +import json |
1 | 2 | import os
|
2 | 3 | import re
|
3 | 4 | import time
|
@@ -195,6 +196,15 @@ def test_wallet_creations(wallet_setup):
|
195 | 196 | )
|
196 | 197 | assert wallet_status, message
|
197 | 198 |
|
| 199 | + json_result = exec_command( |
| 200 | + command="wallet", |
| 201 | + sub_command="list", |
| 202 | + extra_args=["--wallet-path", wallet_path, "--json-output"], |
| 203 | + ) |
| 204 | + json_wallet = json.loads(json_result.stdout)["wallets"][0] |
| 205 | + assert json_wallet["ss58_address"] == wallet.coldkey.ss58_address |
| 206 | + assert json_wallet["hotkeys"][0]["ss58_address"] == wallet.hotkey.ss58_address |
| 207 | + |
198 | 208 | # -----------------------------
|
199 | 209 | # Command 1: <btcli w create>
|
200 | 210 | # -----------------------------
|
@@ -267,6 +277,27 @@ def test_wallet_creations(wallet_setup):
|
267 | 277 | wallet_status, message = verify_wallet_dir(wallet_path, "new_coldkey")
|
268 | 278 | assert wallet_status, message
|
269 | 279 |
|
| 280 | + json_creation = exec_command( |
| 281 | + "wallet", |
| 282 | + "new-coldkey", |
| 283 | + extra_args=[ |
| 284 | + "--wallet-name", |
| 285 | + "new_json_coldkey", |
| 286 | + "--wallet-path", |
| 287 | + wallet_path, |
| 288 | + "--n-words", |
| 289 | + "12", |
| 290 | + "--no-use-password", |
| 291 | + "--json-output", |
| 292 | + ], |
| 293 | + ) |
| 294 | + json_creation_output = json.loads(json_creation.stdout) |
| 295 | + assert json_creation_output["success"] is True |
| 296 | + assert json_creation_output["data"]["name"] == "new_json_coldkey" |
| 297 | + assert "coldkey_ss58" in json_creation_output["data"] |
| 298 | + assert json_creation_output["error"] == "" |
| 299 | + new_json_coldkey_ss58 = json_creation_output["data"]["coldkey_ss58"] |
| 300 | + |
270 | 301 | # -----------------------------
|
271 | 302 | # Command 3: <btcli w new_hotkey>
|
272 | 303 | # -----------------------------
|
@@ -303,6 +334,29 @@ def test_wallet_creations(wallet_setup):
|
303 | 334 | )
|
304 | 335 | assert wallet_status, message
|
305 | 336 |
|
| 337 | + new_hotkey_json = exec_command( |
| 338 | + "wallet", |
| 339 | + sub_command="new-hotkey", |
| 340 | + extra_args=[ |
| 341 | + "--wallet-name", |
| 342 | + "new_json_coldkey", |
| 343 | + "--hotkey", |
| 344 | + "new_json_hotkey", |
| 345 | + "--wallet-path", |
| 346 | + wallet_path, |
| 347 | + "--n-words", |
| 348 | + "12", |
| 349 | + "--no-use-password", |
| 350 | + "--json-output", |
| 351 | + ], |
| 352 | + ) |
| 353 | + new_hotkey_json_output = json.loads(new_hotkey_json.stdout) |
| 354 | + assert new_hotkey_json_output["success"] is True |
| 355 | + assert new_hotkey_json_output["data"]["name"] == "new_json_coldkey" |
| 356 | + assert new_hotkey_json_output["data"]["hotkey"] == "new_json_hotkey" |
| 357 | + assert new_hotkey_json_output["data"]["coldkey_ss58"] == new_json_coldkey_ss58 |
| 358 | + assert new_hotkey_json_output["error"] == "" |
| 359 | + |
306 | 360 |
|
307 | 361 | def test_wallet_regen(wallet_setup, capfd):
|
308 | 362 | """
|
@@ -385,7 +439,24 @@ def test_wallet_regen(wallet_setup, capfd):
|
385 | 439 | assert (
|
386 | 440 | initial_coldkey_mod_time != new_coldkey_mod_time
|
387 | 441 | ), "Coldkey file was not regenerated as expected"
|
388 |
| - print("Passed wallet regen_coldkey command ✅") |
| 442 | + # Underlying Rust is broken. Will add this in when that is fixed: https://github.com/opentensor/btwallet/issues/118 |
| 443 | + # json_result = exec_command( |
| 444 | + # command="wallet", |
| 445 | + # sub_command="regen-coldkey", |
| 446 | + # extra_args=[ |
| 447 | + # "--wallet-name", |
| 448 | + # "new_wallet", |
| 449 | + # "--hotkey", |
| 450 | + # "new_hotkey", |
| 451 | + # "--wallet-path", |
| 452 | + # wallet_path, |
| 453 | + # "--mnemonic", |
| 454 | + # mnemonics["coldkey"], |
| 455 | + # "--no-use-password", |
| 456 | + # "--overwrite", |
| 457 | + # "--json-output" |
| 458 | + # ], |
| 459 | + # ) |
389 | 460 |
|
390 | 461 | # -----------------------------
|
391 | 462 | # Command 2: <btcli w regen_coldkeypub>
|
|
0 commit comments