Skip to content

Commit 7710093

Browse files
MarcoFalkeknst
authored andcommitted
partial Merge bitcoin#26722: test: speed up the two slowest functional tests by 18-35% via keypoolrefill()
BACKPORT NOTE: we have missing changes for wallet_fundrawtransaction.py due to DNM bitcoin#20536 31fdc54 test: speed up wallet_fundrawtransaction.py and wallet_sendall.py (kdmukai) Pull request description: ## Problem `wallet_fundrawtransaction.py` and `wallet_sendall.py` are the two slowest functional tests *when running without a RAM disk*. ``` # M1 MacBook Pro timings wallet_fundrawtransaction.py --descriptors | ✓ Passed | 55 s wallet_fundrawtransaction.py --legacy-wallet | ✓ Passed | 381 s wallet_sendall.py --descriptors | ✓ Passed | 43 s wallet_sendall.py --legacy-wallet | ✓ Passed | 327 s ``` In each case, the majority of the time is spent iterating through 1500 to 1600 `getnewaddress()` calls. This is particularly slow in the `--legacy-wallet` runs. see: https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_fundrawtransaction.py#L986-L987 see: https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_sendall.py#L324 ## Solution Pre-fill the keypool before iterating through those `getnewaddress()` calls. With this change, the execution time drops to: ``` wallet_fundrawtransaction.py --descriptors | ✓ Passed | 52 s # -3s diff wallet_fundrawtransaction.py --legacy-wallet | ✓ Passed | 291 s # -90s diff wallet_sendall.py --descriptors | ✓ Passed | 27 s # -16s diff wallet_sendall.py --legacy-wallet | ✓ Passed | 228 s # -99s diff ``` --- Tagging @ Sjors as he had encouraged me to take a look at speeding up the tests. ACKs for top commit: achow101: ACK 31fdc54 Tree-SHA512: e8dd89323551779832a407d068977c827c09dff55c1079d3c19aab39fcce6957df22b1da797ed7aa3bc2f6dd22fdf9e6f5e1a9a0200fdb16ed6042fc5f6dd992
1 parent 7d078d5 commit 7710093

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

test/functional/wallet_sendall.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ def sendall_watchonly_specific_inputs(self):
322322
# This tests needs to be the last one otherwise @cleanup will fail with "Transaction too large" error
323323
def sendall_fails_with_transaction_too_large(self):
324324
self.log.info("Test that sendall fails if resulting transaction is too large")
325+
326+
# Force the wallet to bulk-generate the addresses we'll need
327+
self.wallet.keypoolrefill(1600)
328+
325329
# create many inputs
326330
outputs = {self.wallet.getnewaddress(): 0.000025 for _ in range(1600)}
327331
self.def_wallet.sendmany(amounts=outputs)

0 commit comments

Comments
 (0)