def test_signing_keystore_load(): a = Account.from_keystore( os.path.join(os.path.dirname(os.path.realpath(__file__)), "testdata", "keystore.json"), "aeternity") assert a.get_address( ) == "ak_2hSFmdK98bhUw4ar7MUdTRzNQuMJfBFQYxdhN9kaiopDGqj3Cr"
def test_signing_keystore_save_load(tempdir): original_account = Account.generate() filename = original_account.save_to_keystore(tempdir, "whatever") path = os.path.join(tempdir, filename) print(f"\nAccount keystore is {path}") # now load again the same a = Account.from_keystore(path, "whatever") assert a.get_address() == original_account.get_address() ###### original_account = Account.generate() filename = "account_ks" filename = original_account.save_to_keystore(tempdir, "whatever") path = os.path.join(tempdir, filename) print(f"\nAccount keystore is {path}") # now load again the same a = Account.from_keystore(path, "whatever") assert a.get_address() == original_account.get_address()
def test_signing_keystore_save_load_wrong_pwd(tempdir): original_account = Account.generate() filename = original_account.save_to_keystore(tempdir, "whatever") path = os.path.join(tempdir, filename) print(f"\nAccount keystore is {path}") # now load again the same with raises(ValueError): a = Account.from_keystore(path, "nononon") assert a.get_address() == original_account.get_address()
def cmd_export(args): try: a = Account.from_keystore(args.keystore_path, args.password) print( json.dumps( { "keystore": args.keystore_path, "secret_key": a.get_secret_key(), "address": a.get_address() }, indent=2)) except Exception as e: print(f"Invalid keystore or password: {e}")