Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Exercise locking of unspent outputs | # Exercise locking of unspent outputs | ||||
unspent_0 = self.nodes[2].listunspent()[0] | unspent_0 = self.nodes[2].listunspent()[0] | ||||
unspent_0 = {"txid": unspent_0["txid"], "vout": unspent_0["vout"]} | unspent_0 = {"txid": unspent_0["txid"], "vout": unspent_0["vout"]} | ||||
assert_raises_rpc_error(-8, "Invalid parameter, expected locked output", | assert_raises_rpc_error(-8, "Invalid parameter, expected locked output", | ||||
self.nodes[2].lockunspent, True, [unspent_0]) | self.nodes[2].lockunspent, True, [unspent_0]) | ||||
self.nodes[2].lockunspent(False, [unspent_0]) | self.nodes[2].lockunspent(False, [unspent_0]) | ||||
assert_raises_rpc_error(-8, "Invalid parameter, output already locked", | assert_raises_rpc_error(-8, "Invalid parameter, output already locked", | ||||
self.nodes[2].lockunspent, False, [unspent_0]) | self.nodes[2].lockunspent, False, [unspent_0]) | ||||
assert_raises_rpc_error(-4, "Insufficient funds", | assert_raises_rpc_error(-6, "Insufficient funds", | ||||
self.nodes[2].sendtoaddress, self.nodes[2].getnewaddress(), 20000000) | self.nodes[2].sendtoaddress, self.nodes[2].getnewaddress(), 20000000) | ||||
assert_equal([unspent_0], self.nodes[2].listlockunspent()) | assert_equal([unspent_0], self.nodes[2].listlockunspent()) | ||||
self.nodes[2].lockunspent(True, [unspent_0]) | self.nodes[2].lockunspent(True, [unspent_0]) | ||||
assert_equal(len(self.nodes[2].listlockunspent()), 0) | assert_equal(len(self.nodes[2].listlockunspent()), 0) | ||||
assert_raises_rpc_error(-8, "txid must be of length 64 (not 34, for '0000000000000000000000000000000000')", | assert_raises_rpc_error(-8, "txid must be of length 64 (not 34, for '0000000000000000000000000000000000')", | ||||
self.nodes[2].lockunspent, False, | self.nodes[2].lockunspent, False, | ||||
[{"txid": "0000000000000000000000000000000000", "vout": 0}]) | [{"txid": "0000000000000000000000000000000000", "vout": 0}]) | ||||
assert_raises_rpc_error(-8, "txid must be hexadecimal string (not 'ZZZ0000000000000000000000000000000000000000000000000000000000000')", | assert_raises_rpc_error(-8, "txid must be hexadecimal string (not 'ZZZ0000000000000000000000000000000000000000000000000000000000000')", | ||||
▲ Show 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# 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(), "1e3") | self.nodes[2].getnewaddress(), "1e3") | ||||
tx_obj = self.nodes[0].gettransaction(txid) | tx_obj = self.nodes[0].gettransaction(txid) | ||||
assert_equal(tx_obj['amount'], Decimal('-1000')) | assert_equal(tx_obj['amount'], Decimal('-1000')) | ||||
# General checks for errors from incorrect inputs | # General checks for errors from incorrect inputs | ||||
# This will raise an exception because the amount is negative | |||||
assert_raises_rpc_error(-3, | |||||
"Amount out of range", | |||||
self.nodes[0].sendtoaddress, | |||||
self.nodes[2].getnewaddress(), | |||||
"-1") | |||||
# 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") | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
wait_until( | wait_until( | ||||
lambda: len( | lambda: len( | ||||
self.nodes[0].getrawmempool()) == chainlimit * | self.nodes[0].getrawmempool()) == chainlimit * | ||||
2) | 2) | ||||
node0_balance = self.nodes[0].getbalance() | node0_balance = self.nodes[0].getbalance() | ||||
# With walletrejectlongchains we will not create the tx and store it in | # With walletrejectlongchains we will not create the tx and store it in | ||||
# our wallet. | # our wallet. | ||||
assert_raises_rpc_error(-4, "Transaction has too long of a mempool chain", | assert_raises_rpc_error(-6, "Transaction has too long of a mempool chain", | ||||
self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('10000')) | self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('10000')) | ||||
# Verify nothing new in wallet | # Verify nothing new in wallet | ||||
assert_equal(total_txs, len( | assert_equal(total_txs, len( | ||||
self.nodes[0].listtransactions("*", 99999))) | self.nodes[0].listtransactions("*", 99999))) | ||||
# Test getaddressinfo on external address. Note that these addresses | # Test getaddressinfo on external address. Note that these addresses | ||||
# are taken from disablewallet.py | # are taken from disablewallet.py | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |