aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Song <jaejoon@gmail.com>2017-04-21 19:06:11 -0700
committerJimmy Song <jaejoon@gmail.com>2017-05-09 14:48:10 -0700
commitd4668f35ab230083e39ab05857ccae4fe77dcb50 (patch)
tree38172d69ba810a7ac050e5799572a3a858676b5e
parent4b766fcdd4ca16399075d1e081a321b3b05ce516 (diff)
[test] Add test for getmemoryinfo
Checks memory before and after a transaction that requires a private key. Each time, 32 bytes of memory for a private key should be used. Tested in wallet.py instead of its own file to save testing time.
-rwxr-xr-xtest/functional/wallet.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/functional/wallet.py b/test/functional/wallet.py
index 57f6dfdaa9..efde2e005e 100755
--- a/test/functional/wallet.py
+++ b/test/functional/wallet.py
@@ -57,8 +57,13 @@ class WalletTest(BitcoinTestFramework):
assert_equal(len(self.nodes[2].listunspent()), 0)
# Send 21 BTC from 0 to 2 using sendtoaddress call.
+ # Locked memory should use at least 32 bytes to sign each transaction
+ self.log.info("test getmemoryinfo")
+ memory_before = self.nodes[0].getmemoryinfo()
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
mempool_txid = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
+ memory_after = self.nodes[0].getmemoryinfo()
+ assert(memory_before['locked']['used'] + 64 <= memory_after['locked']['used'])
self.log.info("test gettxout")
# utxo spent in mempool should be visible if you exclude mempool
@@ -78,7 +83,6 @@ class WalletTest(BitcoinTestFramework):
# but 10 will go to node2 and the rest will go to node0
balance = self.nodes[0].getbalance()
assert_equal(set([txout1['value'], txout2['value']]), set([10, balance]))
-
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 0)