def test0(self): """ Case when succeed transfer value. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) ret = bool( wallet.transfer_value( password, to_address="hxa974f512a510299b53c55535c105ed962fd01ee2", value="1000000000000000000", fee=10000000000000000)) # Then self.assertEqual(True, ret) except FileNotFoundError: self.assertFalse(True)
def test3(self): """ Case to return the wallet info in keystore file successfully. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) # Then self.assertTrue(type(wallet.wallet_info) == dict)
def test0(self): """ Case to get balance successfully that balance is 0. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) balance = wallet.get_balance() # Then self.assertTrue(type(balance) == int)
def test9(self): """ Case when balance is same as sum of Amount and Fee. """ # Given password = "******" keystore_file_path1 = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") try: # When wallet1, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path1, password) # send the value to the address of keystore file (test_keystore_for_transfer2) ret = wallet1.transfer_value( password, to_address="hx95e12b1f98f9b847175849f51bed5d121e742f6a", value="1010000000000000000", fee=10000000000000000) password = "******" keystore_file_path2 = os.path.join( TEST_DIR, "test_keystore_for_transfer2.txt") wallet2, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path2, password) ret = wallet2.transfer_value( password, to_address="hx66425784bfddb5b430136b38268c3ce1fb68e8c5", value="1000000000000000000", fee=10000000000000000) # Then except AmountIsInvalid: self.assertTrue(False) else: self.assertTrue(True)
def test1(self): """ Case to get balance successfully that balance is more than 0. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) balance = wallet.get_balance() # Then self.assertTrue(type(balance) == int and balance > 0)
def test2(self): """ Case to enter a invalid password. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) # Then except PasswordIsWrong: self.assertTrue(True)
def test3(self): """ Case to return the correct form of wallet information. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet(keystore_file_path, password) wallet_info = wallet.get_wallet_info(uri) # Then self.assertTrue(validate_wallet_info(wallet_info)) except FileNotFoundError: self.assertFalse(True)
def test2(self): """ Case to return the wallet info in keystore file successfully. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet(keystore_file_path, password) wallet_info = wallet.get_wallet_info(uri) # Then self.assertTrue(type(wallet_info) == dict) except FileNotFoundError: self.assertFalse(True)
def test0(self): """ Case to open wallet successfully. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) # Then prefix = wallet.address[0:2] self.assertEqual(prefix, "hx") except FileNotFoundError: self.assertFalse(True)
def test1(self): """ Case to enter a directory that does not exist. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "unknown_folder", "test_keystore.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) # Then except FilePathIsWrong: self.assertTrue(True) except FileNotFoundError: self.assertTrue(True)
def test1(self): """ Case when key_store_file_path is wrong. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "./wrong_path") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) ret = wallet.transfer_value( password, to_address="hxa974f512a510299b53c55535c105ed962fd01ee2", value="10000000000000000000", fee=10000000000000000) # Then except FilePathIsWrong: self.assertTrue(True) else: self.assertTrue(False)
def test10(self): """ Case when wallet address to transfer is same as wallet address to be sent. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) ret = wallet.transfer_value( password, to_address="hx66425784bfddb5b430136b38268c3ce1fb68e8c5", value="0", fee=10000000000000000) # Then except AddressIsSame: self.assertTrue(True) else: self.assertTrue(False)
def test8(self): """ Case when Amount is 0. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) ret = wallet.transfer_value( password, to_address="hxa974f512a510299b53c55535c105ed962fd01ee2", value="0", fee=10000000000000000) # Then except AmountIsInvalid: self.assertTrue(True) else: self.assertTrue(False)
def test2_1(self): """ Case when password is not acceptable. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) ret = wallet.transfer_value( password, to_address="hxa974f512a510299b53c55535c105ed962fd01ee2", value="1000000000000000000", fee=10000000000000000) # Then except PasswordIsNotAcceptable: self.assertTrue(True) else: self.assertTrue(False)
def test3(self): """ Case when wallet does not have enough balance. """ # Given password = "******" keystore_file_path = os.path.join(TEST_DIR, "test_keystore_for_transfer.txt") try: # When wallet, _ = Wallet.open_keystore_file_of_wallet( keystore_file_path, password) ret = wallet.transfer_value( password, to_address="hxa974f512a510299b53c55535c105ed962fd01ee2", value="10000000000000000000000000000000000000000000000000", fee=10000000000000000) # Then except NotEnoughBalanceInWallet: self.assertTrue(True) else: self.assertTrue(False)