Skip to content

Commit d4668f3

Browse files
committed
[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.
1 parent 4b766fc commit d4668f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/functional/wallet.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ def run_test(self):
5757
assert_equal(len(self.nodes[2].listunspent()), 0)
5858

5959
# Send 21 BTC from 0 to 2 using sendtoaddress call.
60+
# Locked memory should use at least 32 bytes to sign each transaction
61+
self.log.info("test getmemoryinfo")
62+
memory_before = self.nodes[0].getmemoryinfo()
6063
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11)
6164
mempool_txid = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10)
65+
memory_after = self.nodes[0].getmemoryinfo()
66+
assert(memory_before['locked']['used'] + 64 <= memory_after['locked']['used'])
6267

6368
self.log.info("test gettxout")
6469
# utxo spent in mempool should be visible if you exclude mempool
@@ -78,7 +83,6 @@ def run_test(self):
7883
# but 10 will go to node2 and the rest will go to node0
7984
balance = self.nodes[0].getbalance()
8085
assert_equal(set([txout1['value'], txout2['value']]), set([10, balance]))
81-
8286
walletinfo = self.nodes[0].getwalletinfo()
8387
assert_equal(walletinfo['immature_balance'], 0)
8488

0 commit comments

Comments
 (0)