mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge bitcoin/bitcoin#22423: test: wallet_listtransactions improvements (speedup, cleanup, logging)
a006d7d73019b8cf4d68626c019c3d69729dda69 test: add logging to wallet_listtransactions (Sebastian Falbesoner) 47915b118720c6e2b2ec9f599f25848041b42b99 test: remove unneeded/redundant code in wallet_listtransactions (Sebastian Falbesoner) fb6c6a7938cb7c4808ad88d23bfc2b7408407b12 test: speedup wallet_listtransactions by whitelisting peers (immediate tx relay) (Sebastian Falbesoner) Pull request description: This PR improves the test `wallet_listtransactions.py` in three ways: * speeds up runtime by a factor of 2-3x by using the good ol' immediate tx relay trick (`-whitelist=noban@127.0.0.1`) * removes unneeded/redundant code * adds log messages, mostly by turning comments into `self.log.info(...)` calls ACKs for top commit: jonatack: ACK a006d7d73019b8cf4d68626c019c3d69729dda69 kristapsk: ACK a006d7d73019b8cf4d68626c019c3d69729dda69 Tree-SHA512: a91a19f5ebc4d05f0b96c5419683c4c57ac0ef44b64eeb8dd550bd72296fd3a2857a3ba83f755fe4b0b3bd06439973f226070b5d0ce2dee58344dae78cb50290
This commit is contained in:
parent
0959f0fe52
commit
61f9d96f38
@ -117,8 +117,6 @@ BASE_SCRIPTS = [
|
|||||||
'mempool_updatefromblock.py',
|
'mempool_updatefromblock.py',
|
||||||
'p2p_tx_download.py',
|
'p2p_tx_download.py',
|
||||||
'wallet_dump.py --legacy-wallet',
|
'wallet_dump.py --legacy-wallet',
|
||||||
'wallet_listtransactions.py --legacy-wallet',
|
|
||||||
'wallet_listtransactions.py --descriptors',
|
|
||||||
'feature_multikeysporks.py',
|
'feature_multikeysporks.py',
|
||||||
'feature_dip3_v19.py',
|
'feature_dip3_v19.py',
|
||||||
'feature_llmq_signing.py', # NOTE: needs dash_hash to pass
|
'feature_llmq_signing.py', # NOTE: needs dash_hash to pass
|
||||||
@ -179,6 +177,8 @@ BASE_SCRIPTS = [
|
|||||||
'wallet_createwallet.py --usecli',
|
'wallet_createwallet.py --usecli',
|
||||||
'wallet_createwallet.py --descriptors',
|
'wallet_createwallet.py --descriptors',
|
||||||
'wallet_reorgsrestore.py',
|
'wallet_reorgsrestore.py',
|
||||||
|
'wallet_listtransactions.py --legacy-wallet',
|
||||||
|
'wallet_listtransactions.py --descriptors',
|
||||||
'wallet_watchonly.py --legacy-wallet',
|
'wallet_watchonly.py --legacy-wallet',
|
||||||
'wallet_watchonly.py --usecli --legacy-wallet',
|
'wallet_watchonly.py --usecli --legacy-wallet',
|
||||||
'interface_http.py',
|
'interface_http.py',
|
||||||
|
@ -14,12 +14,15 @@ from test_framework.util import (
|
|||||||
class ListTransactionsTest(BitcoinTestFramework):
|
class ListTransactionsTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
|
# This test isn't testing txn relay/timing, so set whitelist on the
|
||||||
|
# peers for instant txn relay. This speeds up the test run time 2-3x.
|
||||||
|
self.extra_args = [["-whitelist=noban@127.0.0.1"]] * self.num_nodes
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
def skip_test_if_missing_module(self):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Simple send, 0 to 1:
|
self.log.info("Test simple send from node0 to node1")
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
assert_array_result(self.nodes[0].listtransactions(),
|
assert_array_result(self.nodes[0].listtransactions(),
|
||||||
@ -28,7 +31,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||||||
assert_array_result(self.nodes[1].listtransactions(),
|
assert_array_result(self.nodes[1].listtransactions(),
|
||||||
{"txid": txid},
|
{"txid": txid},
|
||||||
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 0})
|
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 0})
|
||||||
# mine a block, confirmations should change:
|
self.log.info("Test confirmations change after mining a block")
|
||||||
blockhash = self.nodes[0].generate(1)[0]
|
blockhash = self.nodes[0].generate(1)[0]
|
||||||
blockheight = self.nodes[0].getblockheader(blockhash)['height']
|
blockheight = self.nodes[0].getblockheader(blockhash)['height']
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
@ -39,7 +42,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||||||
{"txid": txid},
|
{"txid": txid},
|
||||||
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 1, "blockhash": blockhash, "blockheight": blockheight})
|
{"category": "receive", "amount": Decimal("0.1"), "confirmations": 1, "blockhash": blockhash, "blockheight": blockheight})
|
||||||
|
|
||||||
# send-to-self:
|
self.log.info("Test send-to-self on node0")
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
|
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2)
|
||||||
assert_array_result(self.nodes[0].listtransactions(),
|
assert_array_result(self.nodes[0].listtransactions(),
|
||||||
{"txid": txid, "category": "send"},
|
{"txid": txid, "category": "send"},
|
||||||
@ -48,7 +51,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||||||
{"txid": txid, "category": "receive"},
|
{"txid": txid, "category": "receive"},
|
||||||
{"amount": Decimal("0.2")})
|
{"amount": Decimal("0.2")})
|
||||||
|
|
||||||
# sendmany from node1: twice to self, twice to node2:
|
self.log.info("Test sendmany from node1: twice to self, twice to node0")
|
||||||
send_to = {self.nodes[0].getnewaddress(): 0.11,
|
send_to = {self.nodes[0].getnewaddress(): 0.11,
|
||||||
self.nodes[1].getnewaddress(): 0.22,
|
self.nodes[1].getnewaddress(): 0.22,
|
||||||
self.nodes[0].getnewaddress(): 0.33,
|
self.nodes[0].getnewaddress(): 0.33,
|
||||||
@ -82,6 +85,7 @@ class ListTransactionsTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
if not self.options.descriptors:
|
if not self.options.descriptors:
|
||||||
# include_watchonly is a legacy wallet feature, so don't test it for descriptor wallets
|
# include_watchonly is a legacy wallet feature, so don't test it for descriptor wallets
|
||||||
|
self.log.info("Test 'include_watchonly' feature (legacy wallet)")
|
||||||
pubkey = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['pubkey']
|
pubkey = self.nodes[1].getaddressinfo(self.nodes[1].getnewaddress())['pubkey']
|
||||||
multisig = self.nodes[1].createmultisig(1, [pubkey])
|
multisig = self.nodes[1].createmultisig(1, [pubkey])
|
||||||
self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True)
|
self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True)
|
||||||
|
Loading…
Reference in New Issue
Block a user