示例#1
0
 def test_get_account_by_index(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_index(1)
     print(r)
     r = w.get_account_by_index(2)
     print(r)
    def test_get_account_by_index(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 _ in range(size * 2):
            index = choice(range(size))
            acct = wallet.get_account_by_index(index)
            self.assertEqual(address_list[index], acct.b58_address)