Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_basic.py
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
memory_before = self.nodes[0].getmemoryinfo() | memory_before = self.nodes[0].getmemoryinfo() | ||||
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) | self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) | ||||
mempool_txid = self.nodes[0].sendtoaddress( | mempool_txid = self.nodes[0].sendtoaddress( | ||||
self.nodes[2].getnewaddress(), 10) | self.nodes[2].getnewaddress(), 10) | ||||
memory_after = self.nodes[0].getmemoryinfo() | memory_after = self.nodes[0].getmemoryinfo() | ||||
assert(memory_before['locked']['used'] + | assert(memory_before['locked']['used'] + | ||||
64 <= memory_after['locked']['used']) | 64 <= memory_after['locked']['used']) | ||||
self.log.info("test sendtoaddress CheckBalance") | |||||
# Check that sendtoaddress fails with insufficient funds when you | |||||
# try to send more money than the wallet has | |||||
assert_equal(self.nodes[1].getbalance(), 50) | |||||
assert_raises_rpc_error(-6, "Insufficient funds", | |||||
self.nodes[1].sendtoaddress, | |||||
self.nodes[0].getnewaddress(), | |||||
50.00000001) | |||||
# # Check that sendtoaddress fails with insufficient fee when you | |||||
# # try to send more money than the wallet has | |||||
assert_equal(self.nodes[1].getbalance(), 50) | |||||
assert_raises_rpc_error(-4, "This transaction requires a transaction fee" | |||||
" of at least", | |||||
self.nodes[1].sendtoaddress, | |||||
self.nodes[0].getnewaddress(), | |||||
50.00000000) | |||||
assert_equal(self.nodes[1].getbalance(), 50) | |||||
self.nodes[1].sendtoaddress(self.nodes[1].getnewaddress(), 49.99999800) | |||||
assert self.nodes[1].getbalance() < 50 | |||||
deadalnix: My understanding is that this patch do not change any behavior, so how is this testing the new… | |||||
jtoomimAuthorUnsubmitted Not Done Inline ActionsThe check on the new code is done by the sendtoaddress lines. sendtoaddress is the only RPC call that runs the new code (CheckBalance), and no longer runs the old code (GetBalance). If ::CheckBalance(..) returns the wrong results (and disagrees with ::GetBalance()), then the sendtoaddress calls will either succeed when they should fail (lines 100 and 107) or fail when they should succeed (line 113). The nodes[1].getbalance asserts are just there to sanity check the python code itself, and to make sure that the wallet contains as much as it was supposed to contain at that point in execution according to when the RPC test was written. jtoomim: The check on the new code is done by the sendtoaddress lines. sendtoaddress is the only RPC… | |||||
self.log.info("test gettxout (second part)") | self.log.info("test gettxout (second part)") | ||||
# utxo spent in mempool should be visible if you exclude mempool | # utxo spent in mempool should be visible if you exclude mempool | ||||
# but invisible if you include mempool | # but invisible if you include mempool | ||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False) | txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False) | ||||
assert_equal(txout['value'], 50) | assert_equal(txout['value'], 50) | ||||
txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True) | txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True) | ||||
assert txout is None | assert txout is None | ||||
# new utxo from mempool should be invisible if you exclude mempool | # new utxo from mempool should be invisible if you exclude mempool | ||||
▲ Show 20 Lines • Show All 381 Lines • Show Last 20 Lines |
My understanding is that this patch do not change any behavior, so how is this testing the new code ?