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 init_wallet(): m = "brick seed fatigue flee earn rural decline switch number cause wheat employ unknown betray tray" wallet_sender = Wallet.restore("Default", PASSPHRASE, m) wallet_sender.create_address("staking") wallet_sender.create_address("staking") # create test wallet wallet_receiver = Wallet("receiver", PASSPHRASE) wallet_receiver.new("basic") return wallet_sender, wallet_receiver
def test_wallet_restore_basic(): delete_all_wallet() wallet = Wallet("test", PASSPHRASE) wallet.new("basic") private_view_key = wallet.view_key(private = True) wallet_basic = Wallet.restore_basic("test-basic", PASSPHRASE, private_view_key) assert wallet.view_key() == wallet_basic.view_key()
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"]
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" ) assert len(w.list_address("transfer")["addresses"]) == 0 wallet_list.append(w) w.create_address("transfer") w.create_address("transfer") w.create_address("staking") assert len(w.list_pub_key()) == 2 assert len(w.list_address("transfer")["addresses"]) == 2 assert len(w.list_address("staking")["addresses"]) == 1 #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() assert sorted(wallet_names) == [w.name for w in wallet_list] assert len(w.list_address("transfer")["addresses"]) == 2 assert len(w.list_address("staking")["addresses"]) == 1
def init_wallet(): m = "brick seed fatigue flee earn rural decline switch number cause wheat employ unknown betray tray" wallet_1 = Wallet.restore("Default", PASSPHRASE, m) wallet_1.create_address("staking") wallet_1.create_address("staking") # create test wallet wallet_2 = Wallet("test-2", PASSPHRASE) wallet_2.new("basic") wallet_3 = Wallet("test-3", PASSPHRASE) wallet_3.new("basic") # create a mock hw wallet wallet_hw = Wallet("hw", PASSPHRASE) wallet_hw.new("hw", "mock")
t = 0 while t < 30 and balance_sender["pending"] > 0: time.sleep(1) wallet_sender.sync(enable_fast_forward=False) balance_sender = wallet_sender.balance t += 1 wallet_receiver.sync(enable_fast_forward=False) balance_receiver = wallet_receiver.balance assert balance_sender[ "total"] == balance_sender_begin["total"] - amount_cro * CRO assert balance_receiver[ "total"] == balance_receiver_begin["total"] + amount_cro * CRO staking_address_wallet_1 = "0x5e7e1e79d80b861a94598c721598951098dd3825" wallet_1 = Wallet("Default") wallet_2 = Wallet("test-2") wallet_3 = Wallet("test-3") wallet_hw = Wallet("hw") @pytest.mark.zerofee def test_create_wallet(): os.environ['CRYPTO_CLIENT_TENDERMINT'] = 'ws://localhost:26667/websocket' init_wallet() @pytest.mark.zerofee def test_withdraw_all_unbonded_from_genesis(): withdraw_transactions(wallet_1, staking_address_wallet_1) balance = wallet_1.balance