Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show First 20 Lines • Show All 334 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(txObj['amount'], Decimal('-0.0001')) | assert_equal(txObj['amount'], Decimal('-0.0001')) | ||||
# check if JSON parser can handle scientific notation in strings | # check if JSON parser can handle scientific notation in strings | ||||
txId = self.nodes[0].sendtoaddress( | txId = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), "1e-4") | self.nodes[2].getnewaddress(), "1e-4") | ||||
txObj = self.nodes[0].gettransaction(txId) | txObj = self.nodes[0].gettransaction(txId) | ||||
assert_equal(txObj['amount'], Decimal('-0.0001')) | assert_equal(txObj['amount'], Decimal('-0.0001')) | ||||
# General checks for errors from incorrect inputs | |||||
# This will raise an exception because the amount type is wrong | # This will raise an exception because the amount type is wrong | ||||
assert_raises_rpc_error(-3, "Invalid amount", | assert_raises_rpc_error(-3, "Invalid amount", | ||||
self.nodes[0].sendtoaddress, self.nodes[2].getnewaddress(), "1f-4") | self.nodes[0].sendtoaddress, self.nodes[2].getnewaddress(), "1f-4") | ||||
# This will raise an exception since generate does not accept a string | # This will raise an exception since generate does not accept a string | ||||
assert_raises_rpc_error(-1, "not an integer", | assert_raises_rpc_error(-1, "not an integer", | ||||
self.nodes[0].generate, "2") | self.nodes[0].generate, "2") | ||||
# This will raise an exception for the invalid private key format | |||||
assert_raises_rpc_error(-5, | |||||
"Invalid private key encoding", | |||||
self.nodes[0].importprivkey, | |||||
"invalid") | |||||
# This will raise an exception for importing an address with the PS2H | |||||
# flag | |||||
temp_address = self.nodes[1].getnewaddress() | |||||
assert_raises_rpc_error(-5, | |||||
"Cannot use the p2sh flag with an address - use a script instead", | |||||
self.nodes[0].importaddress, | |||||
temp_address, | |||||
"label", | |||||
False, | |||||
True) | |||||
# This will raise an exception for attempting to dump the private key | |||||
# of an address you do not own | |||||
assert_raises_rpc_error(-4, | |||||
"Private key for address", | |||||
self.nodes[0].dumpprivkey, | |||||
temp_address) | |||||
# This will raise an exception for attempting to get the private key of | |||||
# an invalid Bitcoin address | |||||
assert_raises_rpc_error(-5, | |||||
"Invalid Bitcoin address", | |||||
self.nodes[0].dumpprivkey, | |||||
"invalid") | |||||
# This will raise an exception for attempting to set a label for an | |||||
# invalid Bitcoin address | |||||
assert_raises_rpc_error(-5, | |||||
"Invalid Bitcoin address", | |||||
self.nodes[0].setlabel, | |||||
"invalid address", | |||||
"label") | |||||
# This will raise an exception for importing an invalid address | |||||
assert_raises_rpc_error(-5, | |||||
"Invalid Bitcoin address or script", | |||||
self.nodes[0].importaddress, | |||||
"invalid") | |||||
# This will raise an exception for attempting to import a pubkey that | |||||
# isn't in hex | |||||
assert_raises_rpc_error(-5, | |||||
"Pubkey must be a hex string", | |||||
self.nodes[0].importpubkey, | |||||
"not hex") | |||||
# This will raise an exception for importing an invalid pubkey | |||||
assert_raises_rpc_error(-5, | |||||
"Pubkey is not a valid public key", | |||||
self.nodes[0].importpubkey, | |||||
"5361746f736869204e616b616d6f746f") | |||||
# Import address and private key to check correct behavior of spendable unspents | # Import address and private key to check correct behavior of spendable unspents | ||||
# 1. Send some coins to generate new UTXO | # 1. Send some coins to generate new UTXO | ||||
address_to_import = self.nodes[2].getnewaddress() | address_to_import = self.nodes[2].getnewaddress() | ||||
txid = self.nodes[0].sendtoaddress(address_to_import, 1) | txid = self.nodes[0].sendtoaddress(address_to_import, 1) | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all(self.nodes[0:3]) | self.sync_all(self.nodes[0:3]) | ||||
# 2. Import address from node2 to node1 | # 2. Import address from node2 to node1 | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |