def delete_all_wallet(): wallet_names = Wallet.list() wallet_list = [Wallet(name, PASSPHRASE) for name in wallet_names] for wallet in wallet_list: wallet.delete() wallet_names = Wallet.list() assert not wallet_names
def test_wallet_basic(): # 1. create wallet wallet_name_list = ["test1", "test2"] wallet_list = [] for name in wallet_name_list: wallet = Wallet(name, PASSPHRASE) wallet.new("basic") wallet_list.append(wallet) wallet_name_list = ["test3", "test4"] for name in wallet_name_list: wallet = Wallet(name, PASSPHRASE) wallet.new("hd") wallet_list.append(wallet) # 2. restore wallet w = Wallet.restore("test5", PASSPHRASE, "ordinary mandate edit father snack mesh history identify print borrow skate unhappy cattle tiny first") wallet_list.append(w) #3. check the wallet wallet_names = Wallet.list() assert sorted(wallet_names) == ["test1", "test2", "test3", "test4", "test5"] #4. export wallet export_result = Wallet.export_without_file(wallet_list) write_wallet_info_to_file(wallet_list) export2file_result = Wallet.export_with_file() assert export_result == export2file_result #5. delete wallet delete_all_wallet() #6. import wallet Wallet.import_from_file() _wallet_names = Wallet.list()
def test_address(): delete_all_wallet() w1 = Wallet("test-address-1", PASSPHRASE) w1.new("hd") w2 = Wallet("test-address-2", PASSPHRASE) w2.new("basic") wallets = [w1, w2] for wallet in wallets: wallet.create_address("transfer") wallet.create_address("transfer") wallet.create_address("staking") wallet.create_address("staking") for wallet in wallets: assert len(wallet.list_address("transfer")["addresses"]) == 2 assert len(wallet.list_address("staking")["addresses"]) == 2 assert len(wallet.list_pub_key("transfer")) == 2 assert len(wallet.list_pub_key("staking")) == 2 wallet_names = Wallet.list() assert sorted(wallet_names) == ["test-address-1", "test-address-2"]