diff --git a/tests/test_keys.py b/tests/test_keys.py index de702836..602eb992 100644 --- a/tests/test_keys.py +++ b/tests/test_keys.py @@ -69,9 +69,9 @@ def test_path_expand(self): self.assertListEqual(path_expand([], witness_type='p2sh-segwit'), ['m', "49'", "0'", "0'", '0', '0']) self.assertListEqual(path_expand([99], witness_type='p2sh-segwit', multisig=True), ['m', "48'", "0'", "0'", "1'", '0', '99']) - self.assertRaisesRegexp(BKeyError, "Invalid path provided. Path should be shorter than 6 items.", + self.assertRaisesRegex(BKeyError, "Invalid path provided. Path should be shorter than 6 items.", path_expand, [0, 1, 2, 3, 4, 5, 6]) - self.assertRaisesRegexp(BKeyError, "Please provide path as list with at least 1 item", + self.assertRaisesRegex(BKeyError, "Please provide path as list with at least 1 item", path_expand, 5) @@ -110,8 +110,8 @@ def test_format_hdkey_mnemonic(self): self.assertEqual(get_key_format('abandon car zoo')['format'], 'mnemonic') def test_format_key_exceptions(self): - self.assertRaisesRegexp(BKeyError, "Key empty, please specify a valid key", get_key_format, '') - self.assertRaisesRegexp(BKeyError, "Attribute 'is_private' must be False or True", get_key_format, + self.assertRaisesRegex(BKeyError, "Key empty, please specify a valid key", get_key_format, '') + self.assertRaisesRegex(BKeyError, "Attribute 'is_private' must be False or True", get_key_format, '666368e477a8ddd46808c527cc3c506719bb3f52a927b6c13532984b714b56ad', 3) @@ -185,11 +185,11 @@ def test_private_key_import_generate_random(self): self.assertEqual(52, len(self.k.wif())) def test_private_key_import_error_1(self): - self.assertRaisesRegexp(BKeyError, "Invalid checksum, not a valid WIF key", + self.assertRaisesRegex(BKeyError, "Invalid checksum, not a valid WIF key", Key, 'L1odb1uUozbfK2NrsMyhJfvRsxGM2axixgPL8vG9BUBnE6W1VyTX') def test_private_key_import_error_2(self): - self.assertRaisesRegexp(BKeyError, "Unrecognised key format", + self.assertRaisesRegex(BKeyError, "Unrecognised key format", Key, 'M1odb1uUozbfK2NrsMyhJfvRsxGM2AxixgPL8vG9BUBnE6W1VyTX') def test_private_key_import_testnet(self): @@ -238,7 +238,7 @@ def test_public_key_try_private(self): self.assertFalse(self.K.private_hex) def test_public_key_import_error(self): - self.assertRaisesRegexp(BKeyError, "Unrecognised key format", + self.assertRaisesRegex(BKeyError, "Unrecognised key format", Key, '064781e448a7ff0e1b66f1a249b4c952dae33326cf57c0a643738886f4efcd14d5') def test_litecoin_private_key(self): @@ -449,10 +449,10 @@ def test_hdkey_bip44_account_litecoin(self): def test_hdkey_derive_from_public_error(self): k = HDKey().public() - self.assertRaisesRegexp(BKeyError, "Need a private key to create child private key", k.child_private) + self.assertRaisesRegex(BKeyError, "Need a private key to create child private key", k.child_private) k0 = HDKey() k1 = k0.child_private(10, hardened=True) - self.assertRaisesRegexp(BKeyError, "Cannot derive hardened key from public private key", + self.assertRaisesRegex(BKeyError, "Cannot derive hardened key from public private key", k1.child_public, 2147483659) @@ -573,7 +573,7 @@ def test_bip38_invalid_keys(self): return for v in self.vectors["invalid"]["verify"]: print("Checking invalid key %s" % v['base58']) - self.assertRaisesRegexp(Exception, "", Key, str(v['base58'])) + self.assertRaisesRegex(Exception, "", Key, str(v['base58'])) def test_bip38_other_networks(self): if not USING_MODULE_SCRYPT: @@ -655,16 +655,16 @@ def test_keys_address_encodings(self): self.assertEqual(a.address, 'tb1q8hehumvm039nxnwwtqdjr7qmm46sfxrdw7vc3g') def test_keys_address_deserialize_exceptions(self): - self.assertRaisesRegexp(BKeyError, "Invalid address 17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bb, checksum incorrect", + self.assertRaisesRegex(BKeyError, "Invalid address 17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bb, checksum incorrect", deserialize_address, '17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bb', encoding='base58') - self.assertRaisesRegexp(EncodingError, + self.assertRaisesRegex(EncodingError, "Address 17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bd is not in specified encoding bs", deserialize_address, '17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bd', encoding='bs') - self.assertRaisesRegexp(EncodingError, + self.assertRaisesRegex(EncodingError, "Invalid address 17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bb: " "Invalid bech32 character in bech string", deserialize_address, '17N9VQbP89ThunSq7Yo2VooXCFTW1Lp8bb', encoding='bech32') - self.assertRaisesRegexp(EncodingError, + self.assertRaisesRegex(EncodingError, "Address bc1qk077yl8zf6yty25rgrys8h40j8adun267y3m44 is not in specified " "encoding base58", deserialize_address, 'bc1qk077yl8zf6yty25rgrys8h40j8adun267y3m44', encoding='base58') @@ -925,11 +925,11 @@ def test_signatures_from_r_and_s(self): def test_signatures_rs_out_of_curve(self): outofcurveint = 115792089237316195423570985008687907852837564279074904382605163141518161494339 - self.assertRaisesRegexp(BKeyError, "r is not a positive integer smaller than the curve order", + self.assertRaisesRegex(BKeyError, "r is not a positive integer smaller than the curve order", Signature, outofcurveint, 10) - self.assertRaisesRegexp(BKeyError, "r is not a positive integer smaller than the curve order", + self.assertRaisesRegex(BKeyError, "r is not a positive integer smaller than the curve order", Signature, 0, 10) - self.assertRaisesRegexp(BKeyError, "s is not a positive integer smaller than the curve order", + self.assertRaisesRegex(BKeyError, "s is not a positive integer smaller than the curve order", Signature, 11, outofcurveint) def test_signatures_dunder(self): diff --git a/tests/test_mnemonic.py b/tests/test_mnemonic.py index 02d55f3d..dd0953ff 100644 --- a/tests/test_mnemonic.py +++ b/tests/test_mnemonic.py @@ -57,7 +57,7 @@ def test_mnemonic_generate(self): self.assertEqual(Mnemonic.detect_language(phrase), 'dutch') def test_mnemonic_generate_error(self): - self.assertRaisesRegexp(ValueError, 'Strength should be divisible by 32', Mnemonic().generate, 11) + self.assertRaisesRegex(ValueError, 'Strength should be divisible by 32', Mnemonic().generate, 11) def test_mnemonic_to_entropy(self): phrase = 'usage grid neither voice worry armor sudden core excuse keen stand pudding' @@ -68,22 +68,22 @@ def test_mnemonic_to_mnemonic(self): 'chunk gun celery million wood kite tackle twenty story episode raccoon dutch') self.assertEqual(Mnemonic().to_mnemonic('28acfc94465fd2f6774759d6897ec122', add_checksum=False), 'action filter venture match garlic nut oven modify output dwarf wild cattle') - self.assertRaisesRegexp(ValueError, "Integer value of data should be in secp256k1 domain between 1 and " + self.assertRaisesRegex(ValueError, "Integer value of data should be in secp256k1 domain between 1 and " "secp256k1_n-1", Mnemonic().to_mnemonic, '28acfc94465fd2f6774759d6897ec12228acfc94465fd2f6774759d6897ec12228acfc94465fd2f6774') def test_mnemonic_to_seed_invalid_checksum(self): phrase = "runway truly foil future recall scatter garage over floor clutch shy boat" - self.assertRaisesRegexp(ValueError, "Invalid checksum 0110 for entropy", Mnemonic().to_seed, phrase) + self.assertRaisesRegex(ValueError, "Invalid checksum 0110 for entropy", Mnemonic().to_seed, phrase) def test_mnemonic_exceptions(self): - self.assertRaisesRegexp(ValueError, "Strength should be divisible by 32", Mnemonic().generate, 20) - self.assertRaisesRegexp(ValueError, "Data length in bits should be divisible by 32", Mnemonic().checksum, + self.assertRaisesRegex(ValueError, "Strength should be divisible by 32", Mnemonic().generate, 20) + self.assertRaisesRegex(ValueError, "Data length in bits should be divisible by 32", Mnemonic().checksum, 'aabbccddeeff') - self.assertRaisesRegexp(Warning, "Unrecognised word", + self.assertRaisesRegex(Warning, "Unrecognised word", Mnemonic().sanitize_mnemonic, 'action filter venture match garlic nut oven modify output dwarf wild fiets') - self.assertRaisesRegexp(Warning, "Could not detect language", + self.assertRaisesRegex(Warning, "Could not detect language", Mnemonic().detect_language, 'floep fliep') diff --git a/tests/test_networks.py b/tests/test_networks.py index 2b4b143d..31be4f1c 100644 --- a/tests/test_networks.py +++ b/tests/test_networks.py @@ -49,7 +49,7 @@ def test_networks_network_value_for(self): def test_network_defined(self): self.assertTrue(network_defined('bitcoin')) self.assertFalse(network_defined('bitcoiiin')) - self.assertRaisesRegexp(NetworkError, "Network bitcoiin not found in network definitions", Network, 'bitcoiin') + self.assertRaisesRegex(NetworkError, "Network bitcoiin not found in network definitions", Network, 'bitcoiin') def test_wif_prefix_search(self): exp_dict = { diff --git a/tests/test_script.py b/tests/test_script.py index f7a33522..fe6ad70c 100644 --- a/tests/test_script.py +++ b/tests/test_script.py @@ -550,9 +550,9 @@ def test_script_multisig_errors(self): 'd1b1ec45d76724f26901099416b9265b76ba67c8b0b73d' '210202be80a0ca69c0e000b97d507f45b98c49f58fec6650b64ff70e6ffccc3e6d00' '210202be80a0ca69c0e000b97d507f45b98c49f58fec6650b64ff70e6ffccc3e6d0052ae') - self.assertRaisesRegexp(ScriptError, '3 keys found but 2 keys expected', + self.assertRaisesRegex(ScriptError, '3 keys found but 2 keys expected', Script.parse, scr) - self.assertRaisesRegexp(ScriptError, 'Number of signatures required \(3\) is higher then number of keys \(2\)', + self.assertRaisesRegex(ScriptError, 'Number of signatures required \(3\) is higher then number of keys \(2\)', Script.parse, '532102d9d64770e0510c650cfaa0c05ba34f6faa35a18defcf9f2d493c4c225d93fbf221020c39c418c2' '38ba876d09c4529bdafb2a1295c57ece923997ab693bf0a84189b852ae') diff --git a/tests/test_services.py b/tests/test_services.py index 5f277cac..edd09284 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -326,7 +326,7 @@ def test_service_gettransactions_after_txid_litecoin(self): self.assertEqual(res[0].txid, 'e0c1e90fa2195869905e90d4fa644082dfd0523540c13baea0c7a4e246ef40e4') def test_service_gettransactions_addresslist_error(self): - self.assertRaisesRegexp(ServiceError, "Address parameter must be of type text", + self.assertRaisesRegex(ServiceError, "Address parameter must be of type text", ServiceTest().gettransactions, ['1LGJzocooaciEtsxEVAajLhCymCXNvPoLh', '19KedreX9aR64fN7tnNzVLVFHQAUL6dLzr']) @@ -689,7 +689,7 @@ def test_service_max_providers(self): self.assertEqual(srv.resultcount, 1) def test_service_errors(self): - self.assertRaisesRegexp(ServiceError, "Provider 'unknown_provider' not found in provider definitions", + self.assertRaisesRegex(ServiceError, "Provider 'unknown_provider' not found in provider definitions", Service, providers='unknown_provider') def test_service_mempool(self): diff --git a/tests/test_transactions.py b/tests/test_transactions.py index 1745ae0e..7e99511d 100644 --- a/tests/test_transactions.py +++ b/tests/test_transactions.py @@ -213,7 +213,7 @@ def test_transactions_deserialize_p2sh_output(self): def test_transactions_deserialize_errors(self): rawtx = '01000000000102c114c54564ea09b33c73bfd0237a4d283fe9e73285ad6d34fd3fa42c99f194640300000000ffffffff' - self.assertRaisesRegexp(TransactionError, + self.assertRaisesRegex(TransactionError, 'Input transaction hash not found. Probably malformed raw transaction', Transaction.parse_hex, rawtx) # FIXME: tx.parse_hex() should check remaining size @@ -225,7 +225,7 @@ def test_transactions_deserialize_errors(self): # '3c12b67ddd3cf8127fe054dec971c858252c004bf8016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea36' \ # '8e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5' \ # 'ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae000000' - # self.assertRaisesRegexp(TransactionError, + # self.assertRaisesRegex(TransactionError, # 'Error when deserializing raw transaction, bytes left for locktime must be 4 not 3', # Transaction.parse, rawtx) # rawtx = '01000000000101c114c54564ea09b33c73bfd0237a4d283fe9e73285ad6d34fd3fa42c99f194640300000000ffffffff0200' \ @@ -236,7 +236,7 @@ def test_transactions_deserialize_errors(self): # '3c12b67ddd3cf8127fe054dec971c858252c004bf8016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea36' \ # '8e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70f01874496feff2103c96d495bfdd5' \ # 'ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000' - # self.assertRaisesRegexp(TransactionError, + # self.assertRaisesRegex(TransactionError, # "Error when deserializing raw transaction, bytes left for locktime must be 4 not 3", # Transaction.parse, rawtx) @@ -1029,7 +1029,7 @@ def test_transactions_parse_totals(self): def test_transaction_sendto_wrong_address(self): t = Transaction(network='bitcoin') - self.assertRaisesRegexp(BKeyError, 'Network bitcoin not found in extracted networks*', + self.assertRaisesRegex(BKeyError, 'Network bitcoin not found in extracted networks*', t.add_output, 100000, 'LTK1nK5TyGALmSup5SzhgkX1cnVQrC4cLd') def test_transaction_create_with_address_objects(self): @@ -1052,7 +1052,7 @@ def test_transaction_info(self): self.assertIsNone(t.info()) def test_transaction_errors(self): - self.assertRaisesRegexp(TransactionError, "Please specify a valid witness type: legacy or segwit", + self.assertRaisesRegex(TransactionError, "Please specify a valid witness type: legacy or segwit", Transaction, witness_type='error') @@ -1063,7 +1063,7 @@ def test_transaction_redeemscript_errors(self): keys = [] for n in range(20): keys.append(HDKey().public_hex) - self.assertRaisesRegexp(TransactionError, exp_error, serialize_multisig_redeemscript, keys) + self.assertRaisesRegex(TransactionError, exp_error, serialize_multisig_redeemscript, keys) def test_transaction_script_type_string(self): # Locking script @@ -1178,7 +1178,7 @@ def test_transaction_locktime(self): def test_transaction_get_unlocking_script_type(self): self.assertEqual(get_unlocking_script_type('p2pk'), 'signature') - self.assertRaisesRegexp(TransactionError, "Unknown locking script type troep", get_unlocking_script_type, + self.assertRaisesRegex(TransactionError, "Unknown locking script type troep", get_unlocking_script_type, 'troep') def test_transaction_equal(self): diff --git a/tests/test_wallets.py b/tests/test_wallets.py index dcc1fb5b..407581db 100644 --- a/tests/test_wallets.py +++ b/tests/test_wallets.py @@ -202,21 +202,21 @@ def test_wallet_empty(self): self.assertEqual(len(w2.keys()), 1) self.assertEqual(len(w3.keys()), 1) # Test exceptions - self.assertRaisesRegexp(WalletError, "Wallet 'unknown_wallet_2' not found", wallet_empty, 'unknown_wallet_2', + self.assertRaisesRegex(WalletError, "Wallet 'unknown_wallet_2' not found", wallet_empty, 'unknown_wallet_2', db_uri=self.DATABASE_URI) def test_wallet_delete_not_empty(self): w = Wallet.create('unempty_wallet_test', network='bitcoinlib_test', db_uri=self.DATABASE_URI) w.utxos_update() - self.assertRaisesRegexp(WalletError, "still has unspent outputs. Use 'force=True' to delete this wallet", + self.assertRaisesRegex(WalletError, "still has unspent outputs. Use 'force=True' to delete this wallet", wallet_delete, 'unempty_wallet_test', db_uri=self.DATABASE_URI) self.assertTrue(wallet_delete('unempty_wallet_test', db_uri=self.DATABASE_URI, force=True)) def test_delete_wallet_exception(self): - self.assertRaisesRegexp(WalletError, '', wallet_delete, 'unknown_wallet', db_uri=self.DATABASE_URI) + self.assertRaisesRegex(WalletError, '', wallet_delete, 'unknown_wallet', db_uri=self.DATABASE_URI) def test_wallet_unknown_error(self): - self.assertRaisesRegexp(WalletError, "Wallet 'test_wallet_create_errors10' not found", + self.assertRaisesRegex(WalletError, "Wallet 'test_wallet_create_errors10' not found", Wallet, 'test_wallet_create_errors10', db_uri=self.DATABASE_URI) def test_wallet_duplicate_key_for_path(self): @@ -251,49 +251,49 @@ def test_wallet_create_change_name(self): def test_wallet_create_errors(self): Wallet.create('test_wallet_create_errors', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Wallet with name 'test_wallet_create_errors' already exists", + self.assertRaisesRegex(WalletError, "Wallet with name 'test_wallet_create_errors' already exists", Wallet.create, 'test_wallet_create_errors', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Only bip32 or single key scheme's are supported at the moment", + self.assertRaisesRegex(WalletError, "Only bip32 or single key scheme's are supported at the moment", Wallet.create, 'test_wallet_create_errors2', scheme='raar', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Wallet name '123' invalid, please include letter characters", + self.assertRaisesRegex(WalletError, "Wallet name '123' invalid, please include letter characters", Wallet.create, '123', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Please enter wallet name", + self.assertRaisesRegex(WalletError, "Please enter wallet name", Wallet.create, '', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Witness type unknown not supported at the moment", + self.assertRaisesRegex(WalletError, "Witness type unknown not supported at the moment", Wallet.create, '', witness_type='unknown', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Multisig wallets should use bip32 scheme not single", + self.assertRaisesRegex(WalletError, "Multisig wallets should use bip32 scheme not single", Wallet.create, 'test_wallet_create_errors_multisig', keys=[HDKey(), HDKey()], scheme='single', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Password protected multisig wallets not supported", + self.assertRaisesRegex(WalletError, "Password protected multisig wallets not supported", Wallet.create, 'test_wallet_create_errors_multisig2', keys=[HDKey(), HDKey()], password='geheim', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Number of keys required to sign is greater then number of keys provided", + self.assertRaisesRegex(WalletError, "Number of keys required to sign is greater then number of keys provided", Wallet.create, 'test_wallet_create_errors_multisig3', keys=[HDKey(), HDKey()], sigs_required=3, db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, + self.assertRaisesRegex(WalletError, "Network from key \(dash\) is different then specified network \(bitcoin\)", Wallet.create, 'test_wallet_create_errors_multisig4', keys=[HDKey(), HDKey(network='dash')], db_uri=self.DATABASE_URI) passphrase = 'usual olympic ride small mix follow trend baby stereo sweet lucky lend' - self.assertRaisesRegexp(WalletError, "Please specify network when using passphrase to create a key", + self.assertRaisesRegex(WalletError, "Please specify network when using passphrase to create a key", Wallet.create, 'test_wallet_create_errors3', keys=passphrase, db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Invalid key or address: zwqrC7h9pRj7SBhLRDG4FnkNBRQgene3y3", + self.assertRaisesRegex(WalletError, "Invalid key or address: zwqrC7h9pRj7SBhLRDG4FnkNBRQgene3y3", Wallet.create, 'test_wallet_create_errors4', keys='zwqrC7h9pRj7SBhLRDG4FnkNBRQgene3y3', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Invalid key or address: zwqrC7h9pRj7SBhLRDG4FnkNBRQgene3y3", + self.assertRaisesRegex(WalletError, "Invalid key or address: zwqrC7h9pRj7SBhLRDG4FnkNBRQgene3y3", Wallet.create, 'test_wallet_create_errors4', keys='zwqrC7h9pRj7SBhLRDG4FnkNBRQgene3y3', db_uri=self.DATABASE_URI) k = HDKey(network='litecoin').wif_private() - self.assertRaisesRegexp(WalletError, "Invalid key or address", + self.assertRaisesRegex(WalletError, "Invalid key or address", Wallet.create, 'test_wallet_create_errors5', keys=k, network='bitcoin', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Segwit is not supported for Dash wallets", + self.assertRaisesRegex(WalletError, "Segwit is not supported for Dash wallets", Wallet.create, 'test_wallet_create_errors6', keys=HDKey(network='dash'), witness_type='segwit', db_uri=self.DATABASE_URI) k = HDKey().subkey_for_path('m/1/2/3/4/5/6/7') - self.assertRaisesRegexp(WalletError, "Depth of provided public master key 7 does not correspond with key path", + self.assertRaisesRegex(WalletError, "Depth of provided public master key 7 does not correspond with key path", Wallet.create, 'test_wallet_create_errors7', keys=k, db_uri=self.DATABASE_URI) @@ -304,7 +304,7 @@ def test_wallet_rename_duplicate(self): def test_func(): w2.name = 'test_wallet_rename_duplicate1' - self.assertRaisesRegexp(WalletError, "Wallet with name 'test_wallet_rename_duplicate1' already exists", + self.assertRaisesRegex(WalletError, "Wallet with name 'test_wallet_rename_duplicate1' already exists", test_func) def test_wallet_as_dict_json(self): @@ -405,7 +405,7 @@ def test_wallet_import_key_network_error(self): w = Wallet.create( name='Wallet Error', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, + self.assertRaisesRegex(WalletError, "Network litecoin not available in this wallet, please create an account " "for this network first.", w.import_key, 'T43gB4F6k1Ly3YWbMuddq13xLb56hevUDP3RthKArr7FPHjQiXpp', @@ -459,12 +459,12 @@ def test_wallet_import_master_key(self): w = Wallet.create('test_wallet_import_master_key', keys=k.public_master(), db_uri=self.DATABASE_URI) self.assertFalse(w.main_key.is_private) - self.assertRaisesRegexp(WalletError, "Please supply a valid private BIP32 master key with key depth 0", + self.assertRaisesRegex(WalletError, "Please supply a valid private BIP32 master key with key depth 0", w.import_master_key, k.public()) - self.assertRaisesRegexp(WalletError, "Network of Wallet class, main account key and the imported private " + self.assertRaisesRegex(WalletError, "Network of Wallet class, main account key and the imported private " "key must use the same network", w.import_master_key, HDKey(network='litecoin')) - self.assertRaisesRegexp(WalletError, "This key does not correspond to current public master key", + self.assertRaisesRegex(WalletError, "This key does not correspond to current public master key", w.import_master_key, HDKey()) w.import_master_key(k.wif_private()) self.assertTrue(w.main_key.is_private) @@ -472,16 +472,16 @@ def test_wallet_import_master_key(self): k2 = HDKey() w2 = Wallet.create('test_wallet_import_master_key2', keys=k2.subkey_for_path("m/32'"), scheme='single', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Main key is already a private key, cannot import key", + self.assertRaisesRegex(WalletError, "Main key is already a private key, cannot import key", w2.import_master_key, k2) w2.main_key = None - self.assertRaisesRegexp(WalletError, "Main wallet key is not an WalletKey instance", + self.assertRaisesRegex(WalletError, "Main wallet key is not an WalletKey instance", w2.import_master_key, k2) k3 = HDKey() w3 = Wallet.create('test_wallet_import_master_key3', keys=k3.subkey_for_path("m/32'").public(), scheme='single', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "Current main key is not a valid BIP32 public master key", + self.assertRaisesRegex(WalletError, "Current main key is not a valid BIP32 public master key", w3.import_master_key, k3) @@ -595,7 +595,7 @@ def test_wallet_keys_single_key(self): 'ujRHzmBMxE' w = Wallet.create('test_wallet_keys_single_key', wk, scheme='single', db_uri=self.DATABASE_URI) self.assertEqual(w.new_key(), w.new_key()) - self.assertRaisesRegexp(WalletError, + self.assertRaisesRegex(WalletError, "Single wallet has only one \(master\)key. Use get_key\(\) or main_key\(\) method", w.get_keys) @@ -612,7 +612,7 @@ def test_wallet_create_invalid_key(self): key_invalid = HDKey(witness_type='segwit', network='testnet') w = wallet_create_or_open('my-awesome-wallet55', keys=key_correct, witness_type='segwit', network='testnet', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(AssertionError, '', Wallet, 'my-awesome-wallet55', main_key_object=key_invalid, + self.assertRaisesRegex(AssertionError, '', Wallet, 'my-awesome-wallet55', main_key_object=key_invalid, db_uri=self.DATABASE_URI) def test_wallet_single_key(self): @@ -684,13 +684,13 @@ def test_wallet_key_create_from_key(self): w1 = Wallet.create('network_mixup_test_wallet', network='litecoin', db_uri=self.DATABASE_URI) wk1 = WalletKey.from_key('key1', w1.wallet_id, w1._session, key=k1.address_obj) self.assertEqual(wk1.network.name, 'dash') - self.assertRaisesRegexp(WalletError, "Specified network and key network should be the same", + self.assertRaisesRegex(WalletError, "Specified network and key network should be the same", WalletKey.from_key, 'key2', w1.wallet_id, w1._session, key=k2.address_obj, network='bitcoin') w2 = Wallet.create('network_mixup_test_wallet2', network='litecoin', db_uri=self.DATABASE_URI) wk2 = WalletKey.from_key('key1', w2.wallet_id, w2._session, key=k1) self.assertEqual(wk2.network.name, 'dash') - self.assertRaisesRegexp(WalletError, "Specified network and key network should be the same", + self.assertRaisesRegex(WalletError, "Specified network and key network should be the same", WalletKey.from_key, 'key2', w2.wallet_id, w2._session, key=k2, network='bitcoin') wk3 = WalletKey.from_key('key3', w2.wallet_id, w2._session, key=k1) @@ -709,12 +709,12 @@ def test_wallet_key_create_from_key(self): def test_wallet_key_exceptions(self): w = Wallet.create('test_wallet_key_not_found', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, 'Key with id 1000000 not found', WalletKey, 1000000, w._session) - self.assertRaisesRegexp(BKeyError, "Specified key \['litecoin', 'litecoin_legacy'\] is from different " + self.assertRaisesRegex(WalletError, 'Key with id 1000000 not found', WalletKey, 1000000, w._session) + self.assertRaisesRegex(BKeyError, "Specified key \['litecoin', 'litecoin_legacy'\] is from different " "network then specified: bitcoin", WalletKey.from_key, '', w.wallet_id, w._session, 'T3Er8TQUMjkor8JBGm6aPqg1FA2L98MSK52htgNDeSJmfhLYTpgN') - self.assertRaisesRegexp(WalletError, "", w.get_key, cosigner_id=10) + self.assertRaisesRegex(WalletError, "", w.get_key, cosigner_id=10) def test_wallet_key_public_leaks(self): w = wallet_create_or_open("wallet_private", network='testnet', db_uri=self.DATABASE_URI) @@ -824,7 +824,7 @@ def test_wallet_multiple_networks_import_error(self): 'KoMgKnjvAZ6a4Yn2QZg' error_str = "Network bitcoinlib_test not available in this wallet, please create an account for this network " \ "first." - self.assertRaisesRegexp(WalletError, error_str, self.wallet.import_key, pk_dashtest) + self.assertRaisesRegex(WalletError, error_str, self.wallet.import_key, pk_dashtest) def test_wallet_multiple_networks_value(self): pk = 'vprv9DMUxX4ShgxMM1FFB24BgXE3fMYXKicceSdMUtfhyyUzKNkCvPeYrcoZpPezahBEzFc23yHTPj46eqx3jKuQpQFq5kbd2oxDysd' \ @@ -888,7 +888,7 @@ def test_wallet_multi_networks_send_transaction(self): def test_wallet_multi_networks_account_bip44_code_error(self): wlt = Wallet.create("wallet-bip44-code-error", network='testnet', db_uri=self.DATABASE_URI) error_str = "Can not create new account for network litecoin_testnet with same BIP44 cointype" - self.assertRaisesRegexp(WalletError, error_str, wlt.new_account, network='litecoin_testnet') + self.assertRaisesRegex(WalletError, error_str, wlt.new_account, network='litecoin_testnet') def test_wallet_get_account_defaults(self): w = wallet_create_or_open("test_wallet_get_account_defaults", witness_type='segwit', @@ -953,7 +953,7 @@ def test_wallet_bitcoinlib_testnet_sendto_no_funds_txfee(self): w.new_key() w.utxos_update() balance = w.balance() - self.assertRaisesRegexp(WalletError, "Not enough unspent transaction outputs found", + self.assertRaisesRegex(WalletError, "Not enough unspent transaction outputs found", w.send_to, '21DBmFUMQMP7A6KeENXgZQ4wJdSCeGc2zFo', balance, offline=False) def test_wallet_bitcoinlib_testnet_sweep(self): @@ -967,7 +967,7 @@ def test_wallet_bitcoinlib_testnet_sweep(self): w.utxos_update() self.assertIsNone(w.sweep('21DBmFUMQMP7A6KeENXgZQ4wJdSCeGc2zFo', offline=False).error) self.assertEqual(w.utxos(), []) - self.assertRaisesRegexp(WalletError, "Cannot sweep wallet, no UTXO's found", + self.assertRaisesRegex(WalletError, "Cannot sweep wallet, no UTXO's found", w.sweep, '21DBmFUMQMP7A6KeENXgZQ4wJdSCeGc2zFo', offline=False) @@ -1009,7 +1009,7 @@ def test_wallet_multisig_create_2_cosigner_wallets(self): wl1_key = wl1.new_key() wl2_key = wl2.new_key(cosigner_id=wl1.cosigner_id) self.assertEqual(wl1_key.address, wl2_key.address) - self.assertRaisesRegexp(WalletError, "Accounts are not supported for this wallet", wl1.account, 10) + self.assertRaisesRegex(WalletError, "Accounts are not supported for this wallet", wl1.account, 10) def test_wallet_multisig_bitcoinlib_testnet_transaction_send(self): self.db_remove() @@ -1378,7 +1378,7 @@ def test_wallets_multisig_missing_private_and_cosigner(self): hdkey0 = HDKey(k0).public_master_multisig() hdkey1 = HDKey(k1, key_type='single') hdkey2 = HDKey(k2, key_type='single') - self.assertRaisesRegexp(WalletError, + self.assertRaisesRegex(WalletError, "This wallet does not contain any private keys, please specify cosigner_id for " "this wallet", wallet_create_or_open, 'test_wallets_multisig_missing_private_and_cosigner', @@ -1456,7 +1456,7 @@ def test_wallets_multisig_huge_error(self): pk_n = random.randint(0, n_keys - 1) key_list_cosigners = [k.public_master(multisig=True) for k in key_list if k is not key_list[pk_n]] key_list_wallet = [key_list[pk_n]] + key_list_cosigners - self.assertRaisesRegexp(WalletError, 'Redeemscripts with more then 15 keys are non-standard and could ' + self.assertRaisesRegex(WalletError, 'Redeemscripts with more then 15 keys are non-standard and could ' 'result in locked up funds', Wallet.create, wallet_name, keys=key_list_wallet, sigs_required=sigs_req, network=network, db_uri=self.DATABASE_URI) @@ -1845,9 +1845,9 @@ def test_wallet_transaction_fee_limits(self): wlt = Wallet.create('bcltestwlt6', network='bitcoinlib_test', db_uri=self.DATABASE_URI) to_key = wlt.get_key() wlt.utxos_update() - self.assertRaisesRegexp(WalletError, 'Fee per kB of 660 is lower then minimal network fee of 1000', + self.assertRaisesRegex(WalletError, 'Fee per kB of 660 is lower then minimal network fee of 1000', wlt.send_to, to_key.address, 50000000, fee=150) - self.assertRaisesRegexp(WalletError, 'Fee per kB of 1321585 is higher then maximum network fee of 1000000', + self.assertRaisesRegex(WalletError, 'Fee per kB of 1321585 is higher then maximum network fee of 1000000', wlt.send_to, to_key.address, 50000000, fee=300000) def test_wallet_transaction_fee_zero_problem(self): @@ -1985,7 +1985,7 @@ def test_wallet_transaction_send_keyid(self): offline=False) self.assertEqual(t.inputs[0].address, keys[1].address) self.assertTrue(t.verified) - self.assertRaisesRegexp(WalletError, "Not enough unspent transaction outputs found", w.send_to, + self.assertRaisesRegex(WalletError, "Not enough unspent transaction outputs found", w.send_to, 'blt1qtk5swtntg8gvtsyr3kkx3mjcs5ncav84exjvde', 250000000, input_key_id=keys[0].key_id) @@ -2031,15 +2031,15 @@ def test_wallet_transaction_create_exceptions(self): 'FwNjcNknbseoKp1vR2h' wlt = Wallet.create('test_wallet_transaction_create_exceptions', keys=wif, db_uri=self.DATABASE_URI) wlt.utxos_update() - self.assertRaisesRegexp(WalletError, "Output array must be a list of tuples with address and amount. " + self.assertRaisesRegex(WalletError, "Output array must be a list of tuples with address and amount. " "Use 'send_to' method to send to one address", wlt.transaction_create, '217rBycQpv9rjhiLcg94vdZ7muMVLJ9yysJ') inps = wlt.select_inputs(150000000) - self.assertRaisesRegexp(WalletError, "Input array contains 2 UTXO's but max_utxos=1 parameter specified", + self.assertRaisesRegex(WalletError, "Input array contains 2 UTXO's but max_utxos=1 parameter specified", wlt.transaction_create, [('217rBycQpv9rjhiLcg94vdZ7muMVLJ9yysJ', 150000000)], inps, max_utxos=1) wallet_empty('test_wallet_transaction_create_exceptions', db_uri=self.DATABASE_URI) - self.assertRaisesRegexp(WalletError, "UTXO", + self.assertRaisesRegex(WalletError, "UTXO", wlt.transaction_create, [('217rBycQpv9rjhiLcg94vdZ7muMVLJ9yysJ', 150000000)], inps) @@ -2211,7 +2211,7 @@ def test_wallet_avoid_forced_address_reuse2(self): } ] w.utxos_update(utxos=utxos) - self.assertRaisesRegexp(WalletError, "", w.send_to, 'bc1qx76mfmrgvejprscpk8e76d90h94xdhhgnr3jfk', 200001, + self.assertRaisesRegex(WalletError, "", w.send_to, 'bc1qx76mfmrgvejprscpk8e76d90h94xdhhgnr3jfk', 200001, fee=150) def test_wallet_transactions_delete(self): @@ -2413,7 +2413,7 @@ def test_wallet_segwit_p2sh_p2wsh_send(self): def test_wallet_segwit_uncompressed_error(self): k = HDKey(compressed=False, network='bitcoinlib_test') - self.assertRaisesRegexp(BKeyError, 'Uncompressed keys are non-standard', wallet_create_or_open, + self.assertRaisesRegex(BKeyError, 'Uncompressed keys are non-standard', wallet_create_or_open, 'segwit_uncompressed_error', k, witness_type='segwit', network='bitcoinlib_test', db_uri=self.DATABASE_URI) @@ -2528,9 +2528,9 @@ def test_wallet_segwit_multiple_account_paths(self): w.new_account() w.new_account() w.new_account(account_id=100) - self.assertRaisesRegexp(WalletError, "Account with ID 100 already exists for this wallet", + self.assertRaisesRegex(WalletError, "Account with ID 100 already exists for this wallet", w.new_account, 'test', 100) - self.assertRaisesRegexp(WalletError, "Account with ID 1001 not found in this wallet", + self.assertRaisesRegex(WalletError, "Account with ID 1001 not found in this wallet", w.account, 1001) paths = ["m/48'/0'/0'/2'", "m/48'/0'/0'/2'/0/0", "m/48'/0'/0'/2'/1/0", "m/48'/0'/1'/2'", "m/48'/0'/1'/2'/0/0", @@ -2580,9 +2580,9 @@ def test_wallet_path_expand(self): self.assertListEqual(wlt.path_expand(['m', "purpose", "coin_type'", "1", 2, 3]), ['m', "44'", "0'", "1'", '2', '3']) self.assertListEqual(wlt.path_expand([100], -2), ['m', "44'", "0'", "100'"]) - self.assertRaisesRegexp(BKeyError, "Please provide value for 'address_index'", + self.assertRaisesRegex(BKeyError, "Please provide value for 'address_index'", wlt.path_expand, ['m', 45, "cosigner_index", 55, "address_index"]) - self.assertRaisesRegexp(BKeyError, "Variable bestaatnie not found in Key structure definitions in main.py", + self.assertRaisesRegex(BKeyError, "Variable bestaatnie not found in Key structure definitions in main.py", wlt.path_expand, ['m', "bestaatnie'", "coin_type'", "1", 2, 3]) def test_wallet_exotic_key_paths(self): @@ -2614,7 +2614,7 @@ def test_wallet_exotic_key_paths(self): def test_wallet_normalize_path(self): self.assertEqual(normalize_path("m/48h/0p/100H/1200'/1234555"), "m/48'/0'/100'/1200'/1234555") - self.assertRaisesRegexp(WalletError, 'Could not parse path. Index is empty.', normalize_path, + self.assertRaisesRegex(WalletError, 'Could not parse path. Index is empty.', normalize_path, "m/44h/0p/100H//1201") def test_wallet_accounts(self): @@ -2642,7 +2642,7 @@ def test_wallet_readonly_create_and_import(self): self.assertListEqual(w.addresslist(), ['13A1W4jLPP75pzvn2qJ5KyyqG3qPSpb9jM', '12yuSkjKmHzXCFn39PK1XP3XyeoVw9LJdN']) self.assertGreaterEqual(w.balance(), 4532991) - self.assertRaisesRegexp(WalletError, "No unspent", w.send_to, '1ApcyGtcX4DUmfGqPBPY1bvKEh2irLqnhp', 50000) + self.assertRaisesRegex(WalletError, "No unspent", w.send_to, '1ApcyGtcX4DUmfGqPBPY1bvKEh2irLqnhp', 50000) self.assertEqual(w.utxo_last('13A1W4jLPP75pzvn2qJ5KyyqG3qPSpb9jM'), '22965c151d850b5c7d98561e5432459141b1321a299cdcac1764f540eef56451')