def test_add_account(self): test_id = "test_ont_id" w = WalletData(default_id=test_id) acct = AccountData() w.add_account(acct) acct = w.accounts[0] self.assertTrue(isinstance(acct, AccountData))
def test_add_account(self): test_id = "test_ont_id" wallet = WalletData(default_id=test_id) b58_address = 'AKck7c1ySGr63UinVcMcyuoZD4nXbMk7Sw' acct = AccountData(b58_address) wallet.add_account(acct) acct = wallet.accounts[0] self.assertTrue(isinstance(acct, AccountData))
def test_remove_account(self): w = WalletData(default_ontid='hahaha') acct1 = AccountData(address="123") acct2 = AccountData(address="456") w.add_account(acct1) w.add_account(acct2) print(len(w.accounts)) w.remove_account("123") print(len(w.accounts))
class Wallet(object): def __init__(self): self.wallet = WalletData() def add_account(self, b58_address='AatF7ATuecga82vk8wBqjZizCPUce4rpZ5'): acct = AccountData(b58_address) self.wallet.add_account(acct) def remove_account(self, b58_address='AatF7ATuecga82vk8wBqjZizCPUce4rpZ5'): self.wallet.remove_account(b58_address)
def create_wallet_data(self, default_id, size): wallet = WalletData(default_id=default_id) address_list = list() for i in range(size): address = randint(0, 1000000000) acct = AccountData(b58_address=address) wallet.add_account(acct) address_list.append(address) self.assertEqual(len(wallet.accounts), i + 1) return wallet, address_list
def test_get_account_by_address(self): w = WalletData(default_ontid='hahaha') acct1 = AccountData(address="123") acct2 = AccountData(address="456") w.add_account(acct1) w.add_account(acct2) print(len(w.accounts)) r = w.get_account_by_address("123") print(r[0]) print(r[1])
def test_get_account_by_address(self): test_id = "test_ont_id" wallet = WalletData(default_id=test_id) size = 10 address_list = list() for i in range(size): address = randint(0, 1000000000) acct = AccountData(b58_address=address) wallet.add_account(acct) address_list.append(address) self.assertEqual(len(wallet.accounts), i + 1) for i in range(size * 2): rand_address = choice(address_list) acct = wallet.get_account_by_b58_address(rand_address) self.assertEqual(rand_address, acct.b58_address)
def test_remove_account(self): test_id = "test_ont_id" wallet = WalletData(default_id=test_id) size = 10 address_list = list() for i in range(size): address = randint(0, 1000000000) acct = AccountData(b58_address=address) wallet.add_account(acct) address_list.append(address) self.assertEqual(len(wallet.accounts), i + 1) for i in range(size): rand_address = choice(address_list) wallet.remove_account(rand_address) address_list.remove(rand_address) self.assertEqual(len(wallet.accounts), size - i - 1)
def test_get_account_by_index(self): test_id = "test_ont_id" w = WalletData(default_id=test_id) size = 10 address_list = list() for i in range(size): address = random.randint(0, 1000000000) acct = AccountData(address=address) w.add_account(acct) address_list.append(address) self.assertEqual(len(w.accounts), i + 1) for i in range(size * 2): index = random.choice(range(size)) acct = w.get_account_by_index(index) self.assertEqual(address_list[index], acct.address)
def test_add_account(self): w = WalletData(default_ontid='hahaha') acct = AccountData() w.add_account(acct) print(w.accounts[0])