コード例 #1
0
 def test_get_default_account(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         size = 3
         for _ in range(size):
             wm.create_account(password)
         accounts = wm.get_wallet().get_accounts()
         self.assertEqual(len(accounts), size)
         for acct in accounts:
             wm.get_wallet().set_default_account_by_address(
                 acct.b58_address)
             default_account = wm.get_default_account_data()
             self.assertEqual(default_account.b58_address, acct.b58_address)
     finally:
         wm.del_wallet_file()
コード例 #2
0
 def test_set_default_account_by_index(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         size = 3
         for _ in range(size):
             wm.create_account(password)
         accounts = wm.get_wallet().get_accounts()
         self.assertEqual(len(accounts), size)
         self.assertRaises(SDKException,
                           wm.get_wallet().set_default_account_by_index,
                           size)
         for index in range(size):
             wm.get_wallet().set_default_account_by_index(index)
             default_address = wm.get_wallet().get_default_account_address()
             self.assertEqual(accounts[index].b58_address, default_address)
     finally:
         wm.del_wallet_file()
コード例 #3
0
 def test_set_default_identity_by_index(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         size = 3
         for i in range(size):
             private_key = utils.get_random_hex_str(64)
             wm.create_identity_from_private_key("ide", str(i), private_key)
         identities = wm.get_wallet().get_identities()
         self.assertEqual(len(identities), size)
         self.assertRaises(SDKException,
                           wm.get_wallet().set_default_identity_by_index,
                           size)
         for index in range(size):
             wm.get_wallet().set_default_identity_by_index(index)
             default_identity = wm.get_default_identity()
             self.assertEqual(identities[index], default_identity)
     finally:
         wm.del_wallet_file()
コード例 #4
0
 def test_get_accounts(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         size = 5
         for _ in range(size):
             wm.create_account(password)
         accounts = wm.get_wallet().get_accounts()
         self.assertEqual(len(accounts), size)
     finally:
         wm.del_wallet_file()
コード例 #5
0
 def test_set_default_identity_by_ont_id(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         size = 3
         for i in range(size):
             private_key = utils.get_random_hex_str(64)
             wm.create_identity_from_private_key("ide", str(i), private_key)
         identities = wm.get_wallet().get_identities()
         self.assertEqual(len(identities), size)
         self.assertRaises(SDKException,
                           wm.get_wallet().set_default_identity_by_ont_id,
                           '')
         ont_id_list = list()
         for identity in wm.get_wallet().identities:
             ont_id_list.append(identity.ont_id)
         for _ in range(size * 5):
             rand_ont_id = choice(ont_id_list)
             wm.get_wallet().set_default_identity_by_ont_id(rand_ont_id)
             default_identity = wm.get_default_identity()
             self.assertEqual(rand_ont_id, default_identity.ont_id)
     finally:
         wm.del_wallet_file()