scripted-diff: Use generate* from TestFramework

-BEGIN VERIFY SCRIPT-
 sed --regexp-extended -i \
     's/((self\.)?(nodes\[[^]]+\]|[a-z_]*(wallet|node)[0-9a-z_]*))\.(generate(|toaddress|block|todescriptor)(\(|, ))/self.\5\1, /g' \
     $(git grep -l generate ./test | grep -v 'test_framework/' | grep -v 'feature_rbf')
-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke 2021-08-19 17:10:24 +02:00
parent 245462b66c
commit fa0b916971
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
117 changed files with 468 additions and 468 deletions

View file

@ -141,7 +141,7 @@ class ExampleTest(BitcoinTestFramework):
peer_messaging = self.nodes[0].add_p2p_connection(BaseNode()) peer_messaging = self.nodes[0].add_p2p_connection(BaseNode())
# Generating a block on one of the nodes will get us out of IBD # Generating a block on one of the nodes will get us out of IBD
blocks = [int(self.nodes[0].generate(nblocks=1)[0], 16)] blocks = [int(self.generate(self.nodes[0], nblocks=1)[0], 16)]
self.sync_all(self.nodes[0:2]) self.sync_all(self.nodes[0:2])
# Notice above how we called an RPC by calling a method with the same # Notice above how we called an RPC by calling a method with the same

View file

@ -26,7 +26,7 @@ class AbortNodeTest(BitcoinTestFramework):
# We'll connect the nodes later # We'll connect the nodes later
def run_test(self): def run_test(self):
self.nodes[0].generate(3) self.generate(self.nodes[0], 3)
datadir = get_datadir_path(self.options.tmpdir, 0) datadir = get_datadir_path(self.options.tmpdir, 0)
# Deleting the undo file will result in reorg failure # Deleting the undo file will result in reorg failure
@ -34,10 +34,10 @@ class AbortNodeTest(BitcoinTestFramework):
# Connecting to a node with a more work chain will trigger a reorg # Connecting to a node with a more work chain will trigger a reorg
# attempt. # attempt.
self.nodes[1].generate(3) self.generate(self.nodes[1], 3)
with self.nodes[0].assert_debug_log(["Failed to disconnect block"]): with self.nodes[0].assert_debug_log(["Failed to disconnect block"]):
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
# Check that node0 aborted # Check that node0 aborted
self.log.info("Waiting for crash") self.log.info("Waiting for crash")

View file

@ -64,7 +64,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
self.import_deterministic_coinbase_privkeys() self.import_deterministic_coinbase_privkeys()
def run_test(self): def run_test(self):
self.nodes[0].generatetoaddress(COINBASE_MATURITY + 1, self.nodes[0].getnewaddress()) self.generatetoaddress(self.nodes[0], COINBASE_MATURITY + 1, self.nodes[0].getnewaddress())
self.sync_blocks() self.sync_blocks()
@ -92,7 +92,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
address = wallet.getnewaddress() address = wallet.getnewaddress()
self.nodes[0].sendtoaddress(address, 10) self.nodes[0].sendtoaddress(address, 10)
self.sync_mempools() self.sync_mempools()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
# Create a conflicting transaction using RBF # Create a conflicting transaction using RBF
return_address = self.nodes[0].getnewaddress() return_address = self.nodes[0].getnewaddress()
@ -100,7 +100,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
tx2_id = self.nodes[1].bumpfee(tx1_id)["txid"] tx2_id = self.nodes[1].bumpfee(tx1_id)["txid"]
# Confirm the transaction # Confirm the transaction
self.sync_mempools() self.sync_mempools()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
# Create another conflicting transaction using RBF # Create another conflicting transaction using RBF
tx3_id = self.nodes[1].sendtoaddress(return_address, 1) tx3_id = self.nodes[1].sendtoaddress(return_address, 1)

View file

@ -55,7 +55,7 @@ class BIP68Test(BitcoinTestFramework):
self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"]
# Generate some coins # Generate some coins
self.nodes[0].generate(110) self.generate(self.nodes[0], 110)
self.log.info("Running test disable flag") self.log.info("Running test disable flag")
self.test_disable_flag() self.test_disable_flag()
@ -143,7 +143,7 @@ class BIP68Test(BitcoinTestFramework):
for i in range(num_outputs): for i in range(num_outputs):
outputs[addresses[i]] = random.randint(1, 20)*0.01 outputs[addresses[i]] = random.randint(1, 20)*0.01
self.nodes[0].sendmany("", outputs) self.nodes[0].sendmany("", outputs)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
utxos = self.nodes[0].listunspent() utxos = self.nodes[0].listunspent()
@ -273,7 +273,7 @@ class BIP68Test(BitcoinTestFramework):
cur_time = int(time.time()) cur_time = int(time.time())
for _ in range(10): for _ in range(10):
self.nodes[0].setmocktime(cur_time + 600) self.nodes[0].setmocktime(cur_time + 600)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
cur_time += 600 cur_time += 600
assert tx2.hash in self.nodes[0].getrawmempool() assert tx2.hash in self.nodes[0].getrawmempool()
@ -288,7 +288,7 @@ class BIP68Test(BitcoinTestFramework):
self.nodes[0].setmocktime(cur_time+600) self.nodes[0].setmocktime(cur_time+600)
# Save block template now to use for the reorg later # Save block template now to use for the reorg later
tmpl = self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS) tmpl = self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert tx2.hash not in self.nodes[0].getrawmempool() assert tx2.hash not in self.nodes[0].getrawmempool()
# Now that tx2 is not in the mempool, a sequence locked spend should # Now that tx2 is not in the mempool, a sequence locked spend should
@ -296,7 +296,7 @@ class BIP68Test(BitcoinTestFramework):
tx3 = test_nonzero_locks(tx2, self.nodes[0], self.relayfee, use_height_lock=False) tx3 = test_nonzero_locks(tx2, self.nodes[0], self.relayfee, use_height_lock=False)
assert tx3.hash in self.nodes[0].getrawmempool() assert tx3.hash in self.nodes[0].getrawmempool()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert tx3.hash not in self.nodes[0].getrawmempool() assert tx3.hash not in self.nodes[0].getrawmempool()
# One more test, this time using height locks # One more test, this time using height locks
@ -349,7 +349,7 @@ class BIP68Test(BitcoinTestFramework):
# Reset the chain and get rid of the mocktimed-blocks # Reset the chain and get rid of the mocktimed-blocks
self.nodes[0].setmocktime(0) self.nodes[0].setmocktime(0)
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(cur_height+1)) self.nodes[0].invalidateblock(self.nodes[0].getblockhash(cur_height+1))
self.nodes[0].generate(10) self.generate(self.nodes[0], 10)
# Make sure that BIP68 isn't being used to validate blocks prior to # Make sure that BIP68 isn't being used to validate blocks prior to
# activation height. If more blocks are mined prior to this test # activation height. If more blocks are mined prior to this test
@ -403,9 +403,9 @@ class BIP68Test(BitcoinTestFramework):
min_activation_height = 432 min_activation_height = 432
height = self.nodes[0].getblockcount() height = self.nodes[0].getblockcount()
assert_greater_than(min_activation_height - height, 2) assert_greater_than(min_activation_height - height, 2)
self.nodes[0].generate(min_activation_height - height - 2) self.generate(self.nodes[0], min_activation_height - height - 2)
assert not softfork_active(self.nodes[0], 'csv') assert not softfork_active(self.nodes[0], 'csv')
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert softfork_active(self.nodes[0], 'csv') assert softfork_active(self.nodes[0], 'csv')
self.sync_blocks() self.sync_blocks()

View file

@ -25,9 +25,9 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
self.sync_index(height=200) self.sync_index(height=200)
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0) assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection # Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
self.nodes[0].generate(250) self.generate(self.nodes[0], 250)
self.sync_all() self.sync_all()
self.nodes[0].generate(250) self.generate(self.nodes[0], 250)
self.sync_all() self.sync_all()
self.sync_index(height=700) self.sync_index(height=700)
@ -46,7 +46,7 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
self.log.info("make sure accessing the blockfilters throws an error") self.log.info("make sure accessing the blockfilters throws an error")
assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[0].getblockfilter, self.nodes[0].getblockhash(2)) assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[0].getblockfilter, self.nodes[0].getblockhash(2))
self.nodes[0].generate(1000) self.generate(self.nodes[0], 1000)
self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled") self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled")
pruneheight_new = self.nodes[0].pruneblockchain(1000) pruneheight_new = self.nodes[0].pruneblockchain(1000)

View file

@ -29,7 +29,7 @@ class BlocksdirTest(BitcoinTestFramework):
self.log.info("Starting with existing blocksdir ...") self.log.info("Starting with existing blocksdir ...")
self.start_node(0, [f"-blocksdir={blocksdir_path}"]) self.start_node(0, [f"-blocksdir={blocksdir_path}"])
self.log.info("mining blocks..") self.log.info("mining blocks..")
self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 10, self.nodes[0].get_deterministic_priv_key().address)
assert os.path.isfile(os.path.join(blocksdir_path, self.chain, "blocks", "blk00000.dat")) assert os.path.isfile(os.path.join(blocksdir_path, self.chain, "blocks", "blk00000.dat"))
assert os.path.isdir(os.path.join(self.nodes[0].datadir, self.chain, "blocks", "index")) assert os.path.isdir(os.path.join(self.nodes[0].datadir, self.chain, "blocks", "index"))

View file

@ -102,8 +102,8 @@ class BIP65Test(BitcoinTestFramework):
self.test_cltv_info(is_active=False) self.test_cltv_info(is_active=False)
self.log.info("Mining %d blocks", CLTV_HEIGHT - 2) self.log.info("Mining %d blocks", CLTV_HEIGHT - 2)
wallet.generate(10) self.generate(wallet, 10)
self.nodes[0].generate(CLTV_HEIGHT - 2 - 10) self.generate(self.nodes[0], CLTV_HEIGHT - 2 - 10)
assert_equal(self.nodes[0].getblockcount(), CLTV_HEIGHT - 2) assert_equal(self.nodes[0].getblockcount(), CLTV_HEIGHT - 2)
self.log.info("Test that invalid-according-to-CLTV transactions can still appear in a block") self.log.info("Test that invalid-according-to-CLTV transactions can still appear in a block")

View file

@ -67,10 +67,10 @@ class CoinStatsIndexTest(BitcoinTestFramework):
index_hash_options = ['none', 'muhash'] index_hash_options = ['none', 'muhash']
# Generate a normal transaction and mine it # Generate a normal transaction and mine it
node.generate(COINBASE_MATURITY + 1) self.generate(node, COINBASE_MATURITY + 1)
address = self.nodes[0].get_deterministic_priv_key().address address = self.nodes[0].get_deterministic_priv_key().address
node.sendtoaddress(address=address, amount=10, subtractfeefromamount=True) node.sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
node.generate(1) self.generate(node, 1)
self.sync_blocks(timeout=120) self.sync_blocks(timeout=120)
@ -92,7 +92,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
self.log.info("Test that gettxoutsetinfo() can get fetch data on specific heights with index") self.log.info("Test that gettxoutsetinfo() can get fetch data on specific heights with index")
# Generate a new tip # Generate a new tip
node.generate(5) self.generate(node, 5)
for hash_option in index_hash_options: for hash_option in index_hash_options:
# Fetch old stats by height # Fetch old stats by height
@ -169,7 +169,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
self.nodes[0].sendrawtransaction(tx2_hex) self.nodes[0].sendrawtransaction(tx2_hex)
# Include both txs in a block # Include both txs in a block
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
for hash_option in index_hash_options: for hash_option in index_hash_options:
@ -228,7 +228,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
res9 = index_node.gettxoutsetinfo('muhash') res9 = index_node.gettxoutsetinfo('muhash')
assert_equal(res8, res9) assert_equal(res8, res9)
index_node.generate(1) self.generate(index_node, 1)
res10 = index_node.gettxoutsetinfo('muhash') res10 = index_node.gettxoutsetinfo('muhash')
assert(res8['txouts'] < res10['txouts']) assert(res8['txouts'] < res10['txouts'])
@ -247,14 +247,14 @@ class CoinStatsIndexTest(BitcoinTestFramework):
# Generate two block, let the index catch up, then invalidate the blocks # Generate two block, let the index catch up, then invalidate the blocks
index_node = self.nodes[1] index_node = self.nodes[1]
reorg_blocks = index_node.generatetoaddress(2, index_node.getnewaddress()) reorg_blocks = self.generatetoaddress(index_node, 2, index_node.getnewaddress())
reorg_block = reorg_blocks[1] reorg_block = reorg_blocks[1]
res_invalid = index_node.gettxoutsetinfo('muhash') res_invalid = index_node.gettxoutsetinfo('muhash')
index_node.invalidateblock(reorg_blocks[0]) index_node.invalidateblock(reorg_blocks[0])
assert_equal(index_node.gettxoutsetinfo('muhash')['height'], 110) assert_equal(index_node.gettxoutsetinfo('muhash')['height'], 110)
# Add two new blocks # Add two new blocks
block = index_node.generate(2)[1] block = self.generate(index_node, 2)[1]
res = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=False) res = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=False)
# Test that the result of the reorged block is not returned for its old block height # Test that the result of the reorged block is not returned for its old block height
@ -270,7 +270,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
# Add another block, so we don't depend on reconsiderblock remembering which # Add another block, so we don't depend on reconsiderblock remembering which
# blocks were touched by invalidateblock # blocks were touched by invalidateblock
index_node.generate(1) self.generate(index_node, 1)
self.sync_all() self.sync_all()
# Ensure that removing and re-adding blocks yields consistent results # Ensure that removing and re-adding blocks yields consistent results

View file

@ -189,7 +189,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
self.log.info("Generate blocks in the past for coinbase outputs.") self.log.info("Generate blocks in the past for coinbase outputs.")
long_past_time = int(time.time()) - 600 * 1000 # enough to build up to 1000 blocks 10 minutes apart without worrying about getting into the future long_past_time = int(time.time()) - 600 * 1000 # enough to build up to 1000 blocks 10 minutes apart without worrying about getting into the future
self.nodes[0].setmocktime(long_past_time - 100) # enough so that the generated blocks will still all be before long_past_time self.nodes[0].setmocktime(long_past_time - 100) # enough so that the generated blocks will still all be before long_past_time
self.coinbase_blocks = self.miniwallet.generate(COINBASE_BLOCK_COUNT) # blocks generated for inputs self.coinbase_blocks = self.generate(self.miniwallet, COINBASE_BLOCK_COUNT) # blocks generated for inputs
self.nodes[0].setmocktime(0) # set time back to present so yielded blocks aren't in the future as we advance last_block_time self.nodes[0].setmocktime(0) # set time back to present so yielded blocks aren't in the future as we advance last_block_time
self.tipheight = COINBASE_BLOCK_COUNT # height of the next block to build self.tipheight = COINBASE_BLOCK_COUNT # height of the next block to build
self.last_block_time = long_past_time self.last_block_time = long_past_time
@ -235,7 +235,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
bip113input = self.send_generic_input_tx(self.coinbase_blocks) bip113input = self.send_generic_input_tx(self.coinbase_blocks)
self.nodes[0].setmocktime(self.last_block_time + 600) self.nodes[0].setmocktime(self.last_block_time + 600)
inputblockhash = self.nodes[0].generate(1)[0] # 1 block generated for inputs to be in chain at height 431 inputblockhash = self.generate(self.nodes[0], 1)[0] # 1 block generated for inputs to be in chain at height 431
self.nodes[0].setmocktime(0) self.nodes[0].setmocktime(0)
self.tip = int(inputblockhash, 16) self.tip = int(inputblockhash, 16)
self.tipheight += 1 self.tipheight += 1

View file

@ -72,7 +72,7 @@ class BIP66Test(BitcoinTestFramework):
self.test_dersig_info(is_active=False) self.test_dersig_info(is_active=False)
self.log.info("Mining %d blocks", DERSIG_HEIGHT - 2) self.log.info("Mining %d blocks", DERSIG_HEIGHT - 2)
self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.miniwallet.generate(DERSIG_HEIGHT - 2)] self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.generate(self.miniwallet, DERSIG_HEIGHT - 2)]
self.log.info("Test that a transaction with non-DER signature can still appear in a block") self.log.info("Test that a transaction with non-DER signature can still appear in a block")

View file

@ -197,7 +197,7 @@ class EstimateFeeTest(BitcoinTestFramework):
tx_kbytes = (len(txhex) // 2) / 1000.0 tx_kbytes = (len(txhex) // 2) / 1000.0
self.fees_per_kb.append(float(fee) / tx_kbytes) self.fees_per_kb.append(float(fee) / tx_kbytes)
self.sync_mempools(wait=.1) self.sync_mempools(wait=.1)
mined = mining_node.getblock(mining_node.generate(1)[0], True)["tx"] mined = mining_node.getblock(self.generate(mining_node, 1)[0], True)["tx"]
self.sync_blocks(wait=.1) self.sync_blocks(wait=.1)
# update which txouts are confirmed # update which txouts are confirmed
newmem = [] newmem = []
@ -221,7 +221,7 @@ class EstimateFeeTest(BitcoinTestFramework):
# Mine # Mine
while len(self.nodes[0].getrawmempool()) > 0: while len(self.nodes[0].getrawmempool()) > 0:
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Repeatedly split those 2 outputs, doubling twice for each rep # Repeatedly split those 2 outputs, doubling twice for each rep
# Use txouts to monitor the available utxo, since these won't be tracked in wallet # Use txouts to monitor the available utxo, since these won't be tracked in wallet
@ -231,12 +231,12 @@ class EstimateFeeTest(BitcoinTestFramework):
while len(self.txouts) > 0: while len(self.txouts) > 0:
split_inputs(self.nodes[0], self.txouts, self.txouts2) split_inputs(self.nodes[0], self.txouts, self.txouts2)
while len(self.nodes[0].getrawmempool()) > 0: while len(self.nodes[0].getrawmempool()) > 0:
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Double txouts2 to txouts # Double txouts2 to txouts
while len(self.txouts2) > 0: while len(self.txouts2) > 0:
split_inputs(self.nodes[0], self.txouts2, self.txouts) split_inputs(self.nodes[0], self.txouts2, self.txouts)
while len(self.nodes[0].getrawmempool()) > 0: while len(self.nodes[0].getrawmempool()) > 0:
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
reps += 1 reps += 1
self.log.info("Finished splitting") self.log.info("Finished splitting")
@ -269,7 +269,7 @@ class EstimateFeeTest(BitcoinTestFramework):
# Finish by mining a normal-sized block: # Finish by mining a normal-sized block:
while len(self.nodes[1].getrawmempool()) > 0: while len(self.nodes[1].getrawmempool()) > 0:
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_blocks(self.nodes[0:3], wait=.1) self.sync_blocks(self.nodes[0:3], wait=.1)
self.log.info("Final estimates after emptying mempools") self.log.info("Final estimates after emptying mempools")

View file

@ -29,7 +29,7 @@ class LoadblockTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.nodes[1].setnetworkactive(state=False) self.nodes[1].setnetworkactive(state=False)
self.nodes[0].generate(COINBASE_MATURITY) self.generate(self.nodes[0], COINBASE_MATURITY)
# Parsing the url of our node to get settings for config file # Parsing the url of our node to get settings for config file
data_dir = self.nodes[0].datadir data_dir = self.nodes[0].datadir

View file

@ -56,7 +56,7 @@ class MaxUploadTest(BitcoinTestFramework):
self.nodes[0].setmocktime(old_time) self.nodes[0].setmocktime(old_time)
# Generate some old blocks # Generate some old blocks
self.nodes[0].generate(130) self.generate(self.nodes[0], 130)
# p2p_conns[0] will only request old blocks # p2p_conns[0] will only request old blocks
# p2p_conns[1] will only request new blocks # p2p_conns[1] will only request new blocks

View file

@ -51,7 +51,7 @@ class MinimumChainWorkTest(BitcoinTestFramework):
num_blocks_to_generate = int((self.node_min_work[1] - starting_chain_work) / REGTEST_WORK_PER_BLOCK) num_blocks_to_generate = int((self.node_min_work[1] - starting_chain_work) / REGTEST_WORK_PER_BLOCK)
self.log.info(f"Generating {num_blocks_to_generate} blocks on node0") self.log.info(f"Generating {num_blocks_to_generate} blocks on node0")
hashes = self.nodes[0].generatetoaddress(num_blocks_to_generate, hashes = self.generatetoaddress(self.nodes[0], num_blocks_to_generate,
self.nodes[0].get_deterministic_priv_key().address) self.nodes[0].get_deterministic_priv_key().address)
self.log.info(f"Node0 current chain work: {self.nodes[0].getblockheader(hashes[-1])['chainwork']}") self.log.info(f"Node0 current chain work: {self.nodes[0].getblockheader(hashes[-1])['chainwork']}")
@ -73,7 +73,7 @@ class MinimumChainWorkTest(BitcoinTestFramework):
assert_equal(self.nodes[2].getblockcount(), starting_blockcount) assert_equal(self.nodes[2].getblockcount(), starting_blockcount)
self.log.info("Generating one more block") self.log.info("Generating one more block")
self.nodes[0].generatetoaddress(1, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 1, self.nodes[0].get_deterministic_priv_key().address)
self.log.info("Verifying nodes are all synced") self.log.info("Verifying nodes are all synced")

View file

@ -76,7 +76,7 @@ class NotificationsTest(BitcoinTestFramework):
self.log.info("test -blocknotify") self.log.info("test -blocknotify")
block_count = 10 block_count = 10
blocks = self.nodes[1].generatetoaddress(block_count, self.nodes[1].getnewaddress() if self.is_wallet_compiled() else ADDRESS_BCRT1_UNSPENDABLE) blocks = self.generatetoaddress(self.nodes[1], block_count, self.nodes[1].getnewaddress() if self.is_wallet_compiled() else ADDRESS_BCRT1_UNSPENDABLE)
# wait at most 10 seconds for expected number of files before reading the content # wait at most 10 seconds for expected number of files before reading the content
self.wait_until(lambda: len(os.listdir(self.blocknotify_dir)) == block_count, timeout=10) self.wait_until(lambda: len(os.listdir(self.blocknotify_dir)) == block_count, timeout=10)
@ -110,7 +110,7 @@ class NotificationsTest(BitcoinTestFramework):
# triggered by node 1 # triggered by node 1
self.log.info("test -walletnotify with conflicting transactions") self.log.info("test -walletnotify with conflicting transactions")
self.nodes[0].rescanblockchain() self.nodes[0].rescanblockchain()
self.nodes[0].generatetoaddress(100, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_blocks() self.sync_blocks()
# Generate transaction on node 0, sync mempools, and check for # Generate transaction on node 0, sync mempools, and check for
@ -131,7 +131,7 @@ class NotificationsTest(BitcoinTestFramework):
# Add bump1 transaction to new block, checking for a notification # Add bump1 transaction to new block, checking for a notification
# and the correct number of confirmations. # and the correct number of confirmations.
blockhash1 = self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)[0] blockhash1 = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
blockheight1 = self.nodes[0].getblockcount() blockheight1 = self.nodes[0].getblockcount()
self.sync_blocks() self.sync_blocks()
self.expect_wallet_notify([(bump1, blockheight1, blockhash1)]) self.expect_wallet_notify([(bump1, blockheight1, blockhash1)])
@ -148,7 +148,7 @@ class NotificationsTest(BitcoinTestFramework):
# about newly confirmed bump2 and newly conflicted tx2. # about newly confirmed bump2 and newly conflicted tx2.
self.disconnect_nodes(0, 1) self.disconnect_nodes(0, 1)
bump2 = self.nodes[0].bumpfee(tx2)["txid"] bump2 = self.nodes[0].bumpfee(tx2)["txid"]
blockhash2 = self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)[0] blockhash2 = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
blockheight2 = self.nodes[0].getblockcount() blockheight2 = self.nodes[0].getblockcount()
assert_equal(self.nodes[0].gettransaction(bump2)["confirmations"], 1) assert_equal(self.nodes[0].gettransaction(bump2)["confirmations"], 1)
assert_equal(tx2 in self.nodes[1].getrawmempool(), True) assert_equal(tx2 in self.nodes[1].getrawmempool(), True)

View file

@ -74,11 +74,11 @@ class NULLDUMMYTest(BitcoinTestFramework):
wmulti.importaddress(self.ms_address) wmulti.importaddress(self.ms_address)
wmulti.importaddress(self.wit_ms_address) wmulti.importaddress(self.wit_ms_address)
self.coinbase_blocks = self.nodes[0].generate(2) # block height = 2 self.coinbase_blocks = self.generate(self.nodes[0], 2) # block height = 2
coinbase_txid = [] coinbase_txid = []
for i in self.coinbase_blocks: for i in self.coinbase_blocks:
coinbase_txid.append(self.nodes[0].getblock(i)['tx'][0]) coinbase_txid.append(self.nodes[0].getblock(i)['tx'][0])
self.nodes[0].generate(COINBASE_MATURITY) # block height = COINBASE_MATURITY + 2 self.generate(self.nodes[0], COINBASE_MATURITY) # block height = COINBASE_MATURITY + 2
self.lastblockhash = self.nodes[0].getbestblockhash() self.lastblockhash = self.nodes[0].getbestblockhash()
self.lastblockheight = COINBASE_MATURITY + 2 self.lastblockheight = COINBASE_MATURITY + 2
self.lastblocktime = int(time.time()) + self.lastblockheight self.lastblocktime = int(time.time()) + self.lastblockheight

View file

@ -28,7 +28,7 @@ class SegwitUpgradeTest(BitcoinTestFramework):
assert not softfork_active(node, "segwit") assert not softfork_active(node, "segwit")
# Generate 8 blocks without witness data # Generate 8 blocks without witness data
node.generate(8) self.generate(node, 8)
assert_equal(node.getblockcount(), 8) assert_equal(node.getblockcount(), 8)
self.stop_node(0) self.stop_node(0)

View file

@ -118,9 +118,9 @@ class PruneTest(BitcoinTestFramework):
def create_big_chain(self): def create_big_chain(self):
# Start by creating some coinbases we can spend later # Start by creating some coinbases we can spend later
self.nodes[1].generate(200) self.generate(self.nodes[1], 200)
self.sync_blocks(self.nodes[0:2]) self.sync_blocks(self.nodes[0:2])
self.nodes[0].generate(150) self.generate(self.nodes[0], 150)
# Then mine enough full blocks to create more than 550MiB of data # Then mine enough full blocks to create more than 550MiB of data
mine_large_blocks(self.nodes[0], 645) mine_large_blocks(self.nodes[0], 645)
@ -211,7 +211,7 @@ class PruneTest(BitcoinTestFramework):
self.disconnect_nodes(1, 2) self.disconnect_nodes(1, 2)
self.log.info("Generating new longer chain of 300 more blocks") self.log.info("Generating new longer chain of 300 more blocks")
self.nodes[1].generate(300) self.generate(self.nodes[1], 300)
self.log.info("Reconnect nodes") self.log.info("Reconnect nodes")
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
@ -263,7 +263,7 @@ class PruneTest(BitcoinTestFramework):
self.nodes[0].invalidateblock(curchainhash) self.nodes[0].invalidateblock(curchainhash)
assert_equal(self.nodes[0].getblockcount(), self.mainchainheight) assert_equal(self.nodes[0].getblockcount(), self.mainchainheight)
assert_equal(self.nodes[0].getbestblockhash(), self.mainchainhash2) assert_equal(self.nodes[0].getbestblockhash(), self.mainchainhash2)
goalbesthash = self.nodes[0].generate(blocks_to_mine)[-1] goalbesthash = self.generate(self.nodes[0], blocks_to_mine)[-1]
goalbestheight = first_reorg_height + 1 goalbestheight = first_reorg_height + 1
self.log.info("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload") self.log.info("Verify node 2 reorged back to the main chain, some blocks of which it had to redownload")
@ -306,7 +306,7 @@ class PruneTest(BitcoinTestFramework):
assert_equal(block1_details["nTx"], len(block1_details["tx"])) assert_equal(block1_details["nTx"], len(block1_details["tx"]))
# mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight) # mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight)
node.generate(6) self.generate(node, 6)
assert_equal(node.getblockchaininfo()["blocks"], 1001) assert_equal(node.getblockchaininfo()["blocks"], 1001)
# Pruned block should still know the number of transactions # Pruned block should still know the number of transactions
@ -337,7 +337,7 @@ class PruneTest(BitcoinTestFramework):
assert has_block(2), "blk00002.dat is still there, should be pruned by now" assert has_block(2), "blk00002.dat is still there, should be pruned by now"
# advance the tip so blk00002.dat and blk00003.dat can be pruned (the last 288 blocks should now be in blk00004.dat) # advance the tip so blk00002.dat and blk00003.dat can be pruned (the last 288 blocks should now be in blk00004.dat)
node.generate(288) self.generate(node, 288)
prune(1000) prune(1000)
assert not has_block(2), "blk00002.dat is still there, should be pruned by now" assert not has_block(2), "blk00002.dat is still there, should be pruned by now"
assert not has_block(3), "blk00003.dat is still there, should be pruned by now" assert not has_block(3), "blk00003.dat is still there, should be pruned by now"

View file

@ -19,7 +19,7 @@ class ReindexTest(BitcoinTestFramework):
self.num_nodes = 1 self.num_nodes = 1
def reindex(self, justchainstate=False): def reindex(self, justchainstate=False):
self.nodes[0].generatetoaddress(3, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 3, self.nodes[0].get_deterministic_priv_key().address)
blockcount = self.nodes[0].getblockcount() blockcount = self.nodes[0].getblockcount()
self.stop_nodes() self.stop_nodes()
extra_args = [["-reindex-chainstate" if justchainstate else "-reindex"]] extra_args = [["-reindex-chainstate" if justchainstate else "-reindex"]]

View file

@ -105,13 +105,13 @@ class SegWitTest(BitcoinTestFramework):
def success_mine(self, node, txid, sign, redeem_script=""): def success_mine(self, node, txid, sign, redeem_script=""):
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script) send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script)
block = node.generate(1) block = self.generate(node, 1)
assert_equal(len(node.getblock(block[0])["tx"]), 2) assert_equal(len(node.getblock(block[0])["tx"]), 2)
self.sync_blocks() self.sync_blocks()
def skip_mine(self, node, txid, sign, redeem_script=""): def skip_mine(self, node, txid, sign, redeem_script=""):
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script) send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("49.998"), sign, redeem_script)
block = node.generate(1) block = self.generate(node, 1)
assert_equal(len(node.getblock(block[0])["tx"]), 1) assert_equal(len(node.getblock(block[0])["tx"]), 1)
self.sync_blocks() self.sync_blocks()
@ -119,7 +119,7 @@ class SegWitTest(BitcoinTestFramework):
assert_raises_rpc_error(-26, error_msg, send_to_witness, use_p2wsh=1, node=node, utxo=getutxo(txid), pubkey=self.pubkey[0], encode_p2sh=False, amount=Decimal("49.998"), sign=sign, insert_redeem_script=redeem_script) assert_raises_rpc_error(-26, error_msg, send_to_witness, use_p2wsh=1, node=node, utxo=getutxo(txid), pubkey=self.pubkey[0], encode_p2sh=False, amount=Decimal("49.998"), sign=sign, insert_redeem_script=redeem_script)
def run_test(self): def run_test(self):
self.nodes[0].generate(161) # block 161 self.generate(self.nodes[0], 161) # block 161
self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork") self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
@ -130,7 +130,7 @@ class SegWitTest(BitcoinTestFramework):
assert tmpl['transactions'][0]['hash'] == txid assert tmpl['transactions'][0]['hash'] == txid
assert tmpl['transactions'][0]['sigops'] == 2 assert tmpl['transactions'][0]['sigops'] == 2
assert '!segwit' not in tmpl['rules'] assert '!segwit' not in tmpl['rules']
self.nodes[0].generate(1) # block 162 self.generate(self.nodes[0], 1) # block 162
balance_presetup = self.nodes[0].getbalance() balance_presetup = self.nodes[0].getbalance()
self.pubkey = [] self.pubkey = []
@ -156,7 +156,7 @@ class SegWitTest(BitcoinTestFramework):
wit_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], False, Decimal("49.999"))) wit_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], False, Decimal("49.999")))
p2sh_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], True, Decimal("49.999"))) p2sh_ids[n][v].append(send_to_witness(v, self.nodes[0], find_spendable_utxo(self.nodes[0], 50), self.pubkey[n], True, Decimal("49.999")))
self.nodes[0].generate(1) # block 163 self.generate(self.nodes[0], 1) # block 163
self.sync_blocks() self.sync_blocks()
# Make sure all nodes recognize the transactions as theirs # Make sure all nodes recognize the transactions as theirs
@ -164,7 +164,7 @@ class SegWitTest(BitcoinTestFramework):
assert_equal(self.nodes[1].getbalance(), 20 * Decimal("49.999")) assert_equal(self.nodes[1].getbalance(), 20 * Decimal("49.999"))
assert_equal(self.nodes[2].getbalance(), 20 * Decimal("49.999")) assert_equal(self.nodes[2].getbalance(), 20 * Decimal("49.999"))
self.nodes[0].generate(260) # block 423 self.generate(self.nodes[0], 260) # block 423
self.sync_blocks() self.sync_blocks()
self.log.info("Verify witness txs are skipped for mining before the fork") self.log.info("Verify witness txs are skipped for mining before the fork")
@ -177,11 +177,11 @@ class SegWitTest(BitcoinTestFramework):
self.fail_accept(self.nodes[2], "mandatory-script-verify-flag-failed (Operation not valid with the current stack size)", p2sh_ids[NODE_2][P2WPKH][1], sign=False) self.fail_accept(self.nodes[2], "mandatory-script-verify-flag-failed (Operation not valid with the current stack size)", p2sh_ids[NODE_2][P2WPKH][1], sign=False)
self.fail_accept(self.nodes[2], "mandatory-script-verify-flag-failed (Operation not valid with the current stack size)", p2sh_ids[NODE_2][P2WSH][1], sign=False) self.fail_accept(self.nodes[2], "mandatory-script-verify-flag-failed (Operation not valid with the current stack size)", p2sh_ids[NODE_2][P2WSH][1], sign=False)
self.nodes[2].generate(4) # blocks 428-431 self.generate(self.nodes[2], 4) # blocks 428-431
self.log.info("Verify previous witness txs skipped for mining can now be mined") self.log.info("Verify previous witness txs skipped for mining can now be mined")
assert_equal(len(self.nodes[2].getrawmempool()), 4) assert_equal(len(self.nodes[2].getrawmempool()), 4)
blockhash = self.nodes[2].generate(1)[0] # block 432 (first block with new rules; 432 = 144 * 3) blockhash = self.generate(self.nodes[2], 1)[0] # block 432 (first block with new rules; 432 = 144 * 3)
self.sync_blocks() self.sync_blocks()
assert_equal(len(self.nodes[2].getrawmempool()), 0) assert_equal(len(self.nodes[2].getrawmempool()), 0)
segwit_tx_list = self.nodes[2].getblock(blockhash)["tx"] segwit_tx_list = self.nodes[2].getblock(blockhash)["tx"]
@ -239,7 +239,7 @@ class SegWitTest(BitcoinTestFramework):
assert tmpl['transactions'][0]['sigops'] == 8 assert tmpl['transactions'][0]['sigops'] == 8
assert '!segwit' in tmpl['rules'] assert '!segwit' in tmpl['rules']
self.nodes[0].generate(1) # Mine a block to clear the gbt cache self.generate(self.nodes[0], 1) # Mine a block to clear the gbt cache
self.log.info("Non-segwit miners are able to use GBT response after activation.") self.log.info("Non-segwit miners are able to use GBT response after activation.")
# Create a 3-tx chain: tx1 (non-segwit input, paying to a segwit output) -> # Create a 3-tx chain: tx1 (non-segwit input, paying to a segwit output) ->
@ -302,7 +302,7 @@ class SegWitTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getmempoolentry(txid3)["weight"], tx.get_weight()) assert_equal(self.nodes[0].getmempoolentry(txid3)["weight"], tx.get_weight())
# Mine a block to clear the gbt cache again. # Mine a block to clear the gbt cache again.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.log.info("Verify behaviour of importaddress and listunspent") self.log.info("Verify behaviour of importaddress and listunspent")
@ -592,7 +592,7 @@ class SegWitTest(BitcoinTestFramework):
tx.rehash() tx.rehash()
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex'] signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
txid = self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0) txid = self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
txs_mined[txid] = self.nodes[0].generate(1)[0] txs_mined[txid] = self.generate(self.nodes[0], 1)[0]
self.sync_blocks() self.sync_blocks()
watchcount = 0 watchcount = 0
spendcount = 0 spendcount = 0
@ -642,7 +642,7 @@ class SegWitTest(BitcoinTestFramework):
tx.rehash() tx.rehash()
signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex'] signresults = self.nodes[0].signrawtransactionwithwallet(tx.serialize_without_witness().hex())['hex']
self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0) self.nodes[0].sendrawtransaction(hexstring=signresults, maxfeerate=0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()

View file

@ -51,7 +51,7 @@ class SignetBasicTest(BitcoinTestFramework):
assert_equal(mining_info['networkhashps'], Decimal('0')) assert_equal(mining_info['networkhashps'], Decimal('0'))
assert_equal(mining_info['pooledtx'], 0) assert_equal(mining_info['pooledtx'], 0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.log.info("pregenerated signet blocks check") self.log.info("pregenerated signet blocks check")

View file

@ -1461,7 +1461,7 @@ class TaprootTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Post-taproot activation tests go first (pre-taproot tests' blocks are invalid post-taproot). # Post-taproot activation tests go first (pre-taproot tests' blocks are invalid post-taproot).
self.log.info("Post-activation tests...") self.log.info("Post-activation tests...")
self.nodes[1].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[1], COINBASE_MATURITY + 1)
self.test_spenders(self.nodes[1], spenders_taproot_active(), input_counts=[1, 2, 2, 2, 2, 3]) self.test_spenders(self.nodes[1], spenders_taproot_active(), input_counts=[1, 2, 2, 2, 2, 3])
# Re-connect nodes in case they have been disconnected # Re-connect nodes in case they have been disconnected

View file

@ -31,13 +31,13 @@ class UTXOSetHashTest(BitcoinTestFramework):
# Generate 100 blocks and remove the first since we plan to spend its # Generate 100 blocks and remove the first since we plan to spend its
# coinbase # coinbase
block_hashes = wallet.generate(1) + node.generate(99) block_hashes = self.generate(wallet, 1) + self.generate(node, 99)
blocks = list(map(lambda block: from_hex(CBlock(), node.getblock(block, False)), block_hashes)) blocks = list(map(lambda block: from_hex(CBlock(), node.getblock(block, False)), block_hashes))
blocks.pop(0) blocks.pop(0)
# Create a spending transaction and mine a block which includes it # Create a spending transaction and mine a block which includes it
txid = wallet.send_self_transfer(from_node=node)['txid'] txid = wallet.send_self_transfer(from_node=node)['txid']
tx_block = node.generateblock(output=wallet.get_address(), transactions=[txid]) tx_block = self.generateblock(node, output=wallet.get_address(), transactions=[txid])
blocks.append(from_hex(CBlock(), node.getblock(tx_block['hash'], False))) blocks.append(from_hex(CBlock(), node.getblock(tx_block['hash'], False)))
# Serialize the outputs that should be in the UTXO set and add them to # Serialize the outputs that should be in the UTXO set and add them to

View file

@ -65,12 +65,12 @@ class VersionBitsWarningTest(BitcoinTestFramework):
node_deterministic_address = node.get_deterministic_priv_key().address node_deterministic_address = node.get_deterministic_priv_key().address
# Mine one period worth of blocks # Mine one period worth of blocks
node.generatetoaddress(VB_PERIOD, node_deterministic_address) self.generatetoaddress(node, VB_PERIOD, node_deterministic_address)
self.log.info("Check that there is no warning if previous VB_BLOCKS have <VB_THRESHOLD blocks with unknown versionbits version.") self.log.info("Check that there is no warning if previous VB_BLOCKS have <VB_THRESHOLD blocks with unknown versionbits version.")
# Build one period of blocks with < VB_THRESHOLD blocks signaling some unknown bit # Build one period of blocks with < VB_THRESHOLD blocks signaling some unknown bit
self.send_blocks_with_version(peer, VB_THRESHOLD - 1, VB_UNKNOWN_VERSION) self.send_blocks_with_version(peer, VB_THRESHOLD - 1, VB_UNKNOWN_VERSION)
node.generatetoaddress(VB_PERIOD - VB_THRESHOLD + 1, node_deterministic_address) self.generatetoaddress(node, VB_PERIOD - VB_THRESHOLD + 1, node_deterministic_address)
# Check that we're not getting any versionbit-related errors in get*info() # Check that we're not getting any versionbit-related errors in get*info()
assert not VB_PATTERN.match(node.getmininginfo()["warnings"]) assert not VB_PATTERN.match(node.getmininginfo()["warnings"])
@ -78,21 +78,21 @@ class VersionBitsWarningTest(BitcoinTestFramework):
# Build one period of blocks with VB_THRESHOLD blocks signaling some unknown bit # Build one period of blocks with VB_THRESHOLD blocks signaling some unknown bit
self.send_blocks_with_version(peer, VB_THRESHOLD, VB_UNKNOWN_VERSION) self.send_blocks_with_version(peer, VB_THRESHOLD, VB_UNKNOWN_VERSION)
node.generatetoaddress(VB_PERIOD - VB_THRESHOLD, node_deterministic_address) self.generatetoaddress(node, VB_PERIOD - VB_THRESHOLD, node_deterministic_address)
self.log.info("Check that there is a warning if previous VB_BLOCKS have >=VB_THRESHOLD blocks with unknown versionbits version.") self.log.info("Check that there is a warning if previous VB_BLOCKS have >=VB_THRESHOLD blocks with unknown versionbits version.")
# Mine a period worth of expected blocks so the generic block-version warning # Mine a period worth of expected blocks so the generic block-version warning
# is cleared. This will move the versionbit state to ACTIVE. # is cleared. This will move the versionbit state to ACTIVE.
node.generatetoaddress(VB_PERIOD, node_deterministic_address) self.generatetoaddress(node, VB_PERIOD, node_deterministic_address)
# Stop-start the node. This is required because bitcoind will only warn once about unknown versions or unknown rules activating. # Stop-start the node. This is required because bitcoind will only warn once about unknown versions or unknown rules activating.
self.restart_node(0) self.restart_node(0)
# Generating one block guarantees that we'll get out of IBD # Generating one block guarantees that we'll get out of IBD
node.generatetoaddress(1, node_deterministic_address) self.generatetoaddress(node, 1, node_deterministic_address)
self.wait_until(lambda: not node.getblockchaininfo()['initialblockdownload']) self.wait_until(lambda: not node.getblockchaininfo()['initialblockdownload'])
# Generating one more block will be enough to generate an error. # Generating one more block will be enough to generate an error.
node.generatetoaddress(1, node_deterministic_address) self.generatetoaddress(node, 1, node_deterministic_address)
# Check that get*info() shows the versionbits unknown rules warning # Check that get*info() shows the versionbits unknown rules warning
assert WARN_UNKNOWN_RULES_ACTIVE in node.getmininginfo()["warnings"] assert WARN_UNKNOWN_RULES_ACTIVE in node.getmininginfo()["warnings"]
assert WARN_UNKNOWN_RULES_ACTIVE in node.getnetworkinfo()["warnings"] assert WARN_UNKNOWN_RULES_ACTIVE in node.getnetworkinfo()["warnings"]

View file

@ -77,7 +77,7 @@ class TestBitcoinCli(BitcoinTestFramework):
def run_test(self): def run_test(self):
"""Main test logic""" """Main test logic"""
self.nodes[0].generate(BLOCKS) self.generate(self.nodes[0], BLOCKS)
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`") self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`")
cli_response = self.nodes[0].cli.getblockchaininfo() cli_response = self.nodes[0].cli.getblockchaininfo()
@ -158,7 +158,7 @@ class TestBitcoinCli(BitcoinTestFramework):
w1.sendtoaddress(w3.getnewaddress(), amounts[2]) w1.sendtoaddress(w3.getnewaddress(), amounts[2])
# Mine a block to confirm; adds a block reward (50 BTC) to the default wallet. # Mine a block to confirm; adds a block reward (50 BTC) to the default wallet.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.log.info("Test -getinfo with multiple wallets and -rpcwallet returns specified wallet balance") self.log.info("Test -getinfo with multiple wallets and -rpcwallet returns specified wallet balance")
for i in range(len(wallets)): for i in range(len(wallets)):
@ -291,7 +291,7 @@ class TestBitcoinCli(BitcoinTestFramework):
assert_raises_rpc_error(-19, WALLET_NOT_SPECIFIED, self.nodes[0].cli('-generate', 1, 2, 3).echo) assert_raises_rpc_error(-19, WALLET_NOT_SPECIFIED, self.nodes[0].cli('-generate', 1, 2, 3).echo)
else: else:
self.log.info("*** Wallet not compiled; cli getwalletinfo and -getinfo wallet tests skipped") self.log.info("*** Wallet not compiled; cli getwalletinfo and -getinfo wallet tests skipped")
self.nodes[0].generate(25) # maintain block parity with the wallet_compiled conditional branch self.generate(self.nodes[0], 25) # maintain block parity with the wallet_compiled conditional branch
self.log.info("Test -version with node stopped") self.log.info("Test -version with node stopped")
self.stop_node(0) self.stop_node(0)

View file

@ -80,9 +80,9 @@ class RESTTest (BitcoinTestFramework):
# Random address so node1's balance doesn't increase # Random address so node1's balance doesn't increase
not_related_address = "2MxqoHEdNQTyYeX1mHcbrrpzgojbosTpCvJ" not_related_address = "2MxqoHEdNQTyYeX1mHcbrrpzgojbosTpCvJ"
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
self.nodes[1].generatetoaddress(100, not_related_address) self.generatetoaddress(self.nodes[1], 100, not_related_address)
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(), 50) assert_equal(self.nodes[0].getbalance(), 50)
@ -107,7 +107,7 @@ class RESTTest (BitcoinTestFramework):
self.log.info("Query an unspent TXO using the /getutxos URI") self.log.info("Query an unspent TXO using the /getutxos URI")
self.nodes[1].generatetoaddress(1, not_related_address) self.generatetoaddress(self.nodes[1], 1, not_related_address)
self.sync_all() self.sync_all()
bb_hash = self.nodes[0].getbestblockhash() bb_hash = self.nodes[0].getbestblockhash()
@ -182,7 +182,7 @@ class RESTTest (BitcoinTestFramework):
json_obj = self.test_rest_request(f"/getutxos/checkmempool/{spent[0]}-{spent[1]}") json_obj = self.test_rest_request(f"/getutxos/checkmempool/{spent[0]}-{spent[1]}")
assert_equal(len(json_obj['utxos']), 0) assert_equal(len(json_obj['utxos']), 0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
json_obj = self.test_rest_request(f"/getutxos/{spending[0]}-{spending[1]}") json_obj = self.test_rest_request(f"/getutxos/{spending[0]}-{spending[1]}")
@ -203,7 +203,7 @@ class RESTTest (BitcoinTestFramework):
long_uri = '/'.join([f'{txid}-{n_}' for n_ in range(15)]) long_uri = '/'.join([f'{txid}-{n_}' for n_ in range(15)])
self.test_rest_request(f"/getutxos/checkmempool/{long_uri}", http_method='POST', status=200) self.test_rest_request(f"/getutxos/checkmempool/{long_uri}", http_method='POST', status=200)
self.nodes[0].generate(1) # generate block to not affect upcoming tests self.generate(self.nodes[0], 1) # generate block to not affect upcoming tests
self.sync_all() self.sync_all()
self.log.info("Test the /block, /blockhashbyheight and /headers URIs") self.log.info("Test the /block, /blockhashbyheight and /headers URIs")
@ -274,7 +274,7 @@ class RESTTest (BitcoinTestFramework):
assert_equal(json_obj[0][key], rpc_block_json[key]) assert_equal(json_obj[0][key], rpc_block_json[key])
# See if we can get 5 headers in one response # See if we can get 5 headers in one response
self.nodes[1].generate(5) self.generate(self.nodes[1], 5)
self.sync_all() self.sync_all()
json_obj = self.test_rest_request(f"/headers/5/{bb_hash}") json_obj = self.test_rest_request(f"/headers/5/{bb_hash}")
assert_equal(len(json_obj), 5) # now we should have 5 header objects assert_equal(len(json_obj), 5) # now we should have 5 header objects
@ -302,7 +302,7 @@ class RESTTest (BitcoinTestFramework):
assert_equal(json_obj[tx]['depends'], txs[i - 1:i]) assert_equal(json_obj[tx]['depends'], txs[i - 1:i])
# Now mine the transactions # Now mine the transactions
newblockhash = self.nodes[1].generate(1) newblockhash = self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
# Check if the 3 tx show up in the new block # Check if the 3 tx show up in the new block

View file

@ -185,7 +185,7 @@ class ZMQTest (BitcoinTestFramework):
num_blocks = 5 num_blocks = 5
self.log.info(f"Generate {num_blocks} blocks (and {num_blocks} coinbase txes)") self.log.info(f"Generate {num_blocks} blocks (and {num_blocks} coinbase txes)")
genhashes = self.nodes[0].generatetoaddress(num_blocks, ADDRESS_BCRT1_UNSPENDABLE) genhashes = self.generatetoaddress(self.nodes[0], num_blocks, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() self.sync_all()
@ -226,7 +226,7 @@ class ZMQTest (BitcoinTestFramework):
# Mining the block with this tx should result in second notification # Mining the block with this tx should result in second notification
# after coinbase tx notification # after coinbase tx notification
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
hashtx.receive() hashtx.receive()
txid = hashtx.receive() txid = hashtx.receive()
assert_equal(payment_txid, txid.hex()) assert_equal(payment_txid, txid.hex())
@ -257,14 +257,14 @@ class ZMQTest (BitcoinTestFramework):
# Generate 1 block in nodes[0] with 1 mempool tx and receive all notifications # Generate 1 block in nodes[0] with 1 mempool tx and receive all notifications
payment_txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1.0) payment_txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1.0)
disconnect_block = self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)[0] disconnect_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
disconnect_cb = self.nodes[0].getblock(disconnect_block)["tx"][0] disconnect_cb = self.nodes[0].getblock(disconnect_block)["tx"][0]
assert_equal(self.nodes[0].getbestblockhash(), hashblock.receive().hex()) assert_equal(self.nodes[0].getbestblockhash(), hashblock.receive().hex())
assert_equal(hashtx.receive().hex(), payment_txid) assert_equal(hashtx.receive().hex(), payment_txid)
assert_equal(hashtx.receive().hex(), disconnect_cb) assert_equal(hashtx.receive().hex(), disconnect_cb)
# Generate 2 blocks in nodes[1] to a different address to ensure split # Generate 2 blocks in nodes[1] to a different address to ensure split
connect_blocks = self.nodes[1].generatetoaddress(2, ADDRESS_BCRT1_P2WSH_OP_TRUE) connect_blocks = self.generatetoaddress(self.nodes[1], 2, ADDRESS_BCRT1_P2WSH_OP_TRUE)
# nodes[0] will reorg chain after connecting back nodes[1] # nodes[0] will reorg chain after connecting back nodes[1]
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
@ -308,13 +308,13 @@ class ZMQTest (BitcoinTestFramework):
seq_num = 1 seq_num = 1
# Generate 1 block in nodes[0] and receive all notifications # Generate 1 block in nodes[0] and receive all notifications
dc_block = self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)[0] dc_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
# Note: We are not notified of any block transactions, coinbase or mined # Note: We are not notified of any block transactions, coinbase or mined
assert_equal((self.nodes[0].getbestblockhash(), "C", None), seq.receive_sequence()) assert_equal((self.nodes[0].getbestblockhash(), "C", None), seq.receive_sequence())
# Generate 2 blocks in nodes[1] to a different address to ensure a chain split # Generate 2 blocks in nodes[1] to a different address to ensure a chain split
self.nodes[1].generatetoaddress(2, ADDRESS_BCRT1_P2WSH_OP_TRUE) self.generatetoaddress(self.nodes[1], 2, ADDRESS_BCRT1_P2WSH_OP_TRUE)
# nodes[0] will reorg chain after connecting back nodes[1] # nodes[0] will reorg chain after connecting back nodes[1]
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
@ -349,7 +349,7 @@ class ZMQTest (BitcoinTestFramework):
# though the mempool sequence number does go up by the number of transactions # though the mempool sequence number does go up by the number of transactions
# removed from the mempool by the block mining it. # removed from the mempool by the block mining it.
mempool_size = len(self.nodes[0].getrawmempool()) mempool_size = len(self.nodes[0].getrawmempool())
c_block = self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)[0] c_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
self.sync_all() self.sync_all()
# Make sure the number of mined transactions matches the number of txs out of mempool # Make sure the number of mined transactions matches the number of txs out of mempool
mempool_size_delta = mempool_size - len(self.nodes[0].getrawmempool()) mempool_size_delta = mempool_size - len(self.nodes[0].getrawmempool())
@ -389,7 +389,7 @@ class ZMQTest (BitcoinTestFramework):
# Other things may happen but aren't wallet-deterministic so we don't test for them currently # Other things may happen but aren't wallet-deterministic so we don't test for them currently
self.nodes[0].reconsiderblock(best_hash) self.nodes[0].reconsiderblock(best_hash)
self.nodes[1].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[1], 1, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() self.sync_all()
self.log.info("Evict mempool transaction by block conflict") self.log.info("Evict mempool transaction by block conflict")
@ -441,7 +441,7 @@ class ZMQTest (BitcoinTestFramework):
# Last tx # Last tx
assert_equal((orig_txid_2, "A", mempool_seq), seq.receive_sequence()) assert_equal((orig_txid_2, "A", mempool_seq), seq.receive_sequence())
mempool_seq += 1 mempool_seq += 1
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
self.sync_all() # want to make sure we didn't break "consensus" for other tests self.sync_all() # want to make sure we didn't break "consensus" for other tests
def test_mempool_sync(self): def test_mempool_sync(self):
@ -493,7 +493,7 @@ class ZMQTest (BitcoinTestFramework):
txids.append(self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=0.1, replaceable=True)) txids.append(self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=0.1, replaceable=True))
self.nodes[0].bumpfee(txids[-1]) self.nodes[0].bumpfee(txids[-1])
self.sync_all() self.sync_all()
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
final_txid = self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=0.1, replaceable=True) final_txid = self.nodes[0].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=0.1, replaceable=True)
# 3) Consume ZMQ backlog until we get to "now" for the mempool snapshot # 3) Consume ZMQ backlog until we get to "now" for the mempool snapshot
@ -549,7 +549,7 @@ class ZMQTest (BitcoinTestFramework):
# 5) If you miss a zmq/mempool sequence number, go back to step (2) # 5) If you miss a zmq/mempool sequence number, go back to step (2)
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
def test_multiple_interfaces(self): def test_multiple_interfaces(self):
# Set up two subscribers with different addresses # Set up two subscribers with different addresses
@ -562,7 +562,7 @@ class ZMQTest (BitcoinTestFramework):
], sync_blocks=False) ], sync_blocks=False)
# Generate 1 block in nodes[0] and receive all notifications # Generate 1 block in nodes[0] and receive all notifications
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
# Should receive the same block hash on both subscribers # Should receive the same block hash on both subscribers
assert_equal(self.nodes[0].getbestblockhash(), subscribers[0].receive().hex()) assert_equal(self.nodes[0].getbestblockhash(), subscribers[0].receive().hex())

View file

@ -78,7 +78,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
outputs=[{node.getnewaddress(): 0.3}, {node.getnewaddress(): 49}], outputs=[{node.getnewaddress(): 0.3}, {node.getnewaddress(): 49}],
))['hex'] ))['hex']
txid_in_block = node.sendrawtransaction(hexstring=raw_tx_in_block, maxfeerate=0) txid_in_block = node.sendrawtransaction(hexstring=raw_tx_in_block, maxfeerate=0)
node.generate(1) self.generate(node, 1)
self.mempool_size = 0 self.mempool_size = 0
self.check_mempool_result( self.check_mempool_result(
result_expected=[{'txid': txid_in_block, 'allowed': False, 'reject-reason': 'txn-already-known'}], result_expected=[{'txid': txid_in_block, 'allowed': False, 'reject-reason': 'txn-already-known'}],
@ -172,7 +172,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
outputs=[{node.getnewaddress(): 0.1}] outputs=[{node.getnewaddress(): 0.1}]
))['hex'] ))['hex']
txid_spend_both = node.sendrawtransaction(hexstring=raw_tx_spend_both, maxfeerate=0) txid_spend_both = node.sendrawtransaction(hexstring=raw_tx_spend_both, maxfeerate=0)
node.generate(1) self.generate(node, 1)
self.mempool_size = 0 self.mempool_size = 0
# Now see if we can add the coins back to the utxo set by sending the exact txs again # Now see if we can add the coins back to the utxo set by sending the exact txs again
self.check_mempool_result( self.check_mempool_result(

View file

@ -44,7 +44,7 @@ class MempoolWtxidTest(BitcoinTestFramework):
self.log.info('Start with empty mempool and 101 blocks') self.log.info('Start with empty mempool and 101 blocks')
# The last 100 coinbase transactions are premature # The last 100 coinbase transactions are premature
blockhash = node.generate(101)[0] blockhash = self.generate(node, 101)[0]
txid = node.getblock(blockhash=blockhash, verbosity=2)["tx"][0]["txid"] txid = node.getblock(blockhash=blockhash, verbosity=2)["tx"][0]["txid"]
assert_equal(node.getmempoolinfo()['size'], 0) assert_equal(node.getmempoolinfo()['size'], 0)
@ -62,7 +62,7 @@ class MempoolWtxidTest(BitcoinTestFramework):
privkeys = [node.get_deterministic_priv_key().key] privkeys = [node.get_deterministic_priv_key().key]
raw_parent = node.signrawtransactionwithkey(hexstring=parent.serialize().hex(), privkeys=privkeys)['hex'] raw_parent = node.signrawtransactionwithkey(hexstring=parent.serialize().hex(), privkeys=privkeys)['hex']
parent_txid = node.sendrawtransaction(hexstring=raw_parent, maxfeerate=0) parent_txid = node.sendrawtransaction(hexstring=raw_parent, maxfeerate=0)
node.generate(1) self.generate(node, 1)
peer_wtxid_relay = node.add_p2p_connection(P2PTxInvStore()) peer_wtxid_relay = node.add_p2p_connection(P2PTxInvStore())

View file

@ -38,8 +38,8 @@ class MempoolCompatibilityTest(BitcoinTestFramework):
old_node, new_node = self.nodes old_node, new_node = self.nodes
new_wallet = MiniWallet(new_node) new_wallet = MiniWallet(new_node)
new_wallet.generate(1) self.generate(new_wallet, 1)
new_node.generate(COINBASE_MATURITY) self.generate(new_node, COINBASE_MATURITY)
# Sync the nodes to ensure old_node has the block that contains the coinbase that new_wallet will spend. # Sync the nodes to ensure old_node has the block that contains the coinbase that new_wallet will spend.
# Otherwise, because coinbases are only valid in a block and not as loose txns, if the nodes aren't synced # Otherwise, because coinbases are only valid in a block and not as loose txns, if the nodes aren't synced
# unbroadcasted_tx won't pass old_node's `MemPoolAccept::PreChecks`. # unbroadcasted_tx won't pass old_node's `MemPoolAccept::PreChecks`.

View file

@ -36,8 +36,8 @@ class MempoolExpiryTest(BitcoinTestFramework):
self.wallet = MiniWallet(node) self.wallet = MiniWallet(node)
# Add enough mature utxos to the wallet so that all txs spend confirmed coins. # Add enough mature utxos to the wallet so that all txs spend confirmed coins.
self.wallet.generate(4) self.generate(self.wallet, 4)
node.generate(COINBASE_MATURITY) self.generate(node, COINBASE_MATURITY)
# Send a parent transaction that will expire. # Send a parent transaction that will expire.
parent_txid = self.wallet.send_self_transfer(from_node=node)['txid'] parent_txid = self.wallet.send_self_transfer(from_node=node)['txid']

View file

@ -40,7 +40,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
self.address = node.get_deterministic_priv_key().address self.address = node.get_deterministic_priv_key().address
self.coins = [] self.coins = []
# The last 100 coinbase transactions are premature # The last 100 coinbase transactions are premature
for b in node.generatetoaddress(200, self.address)[:100]: for b in self.generatetoaddress(node, 200, self.address)[:100]:
coinbase = node.getblock(blockhash=b, verbosity=2)["tx"][0] coinbase = node.getblock(blockhash=b, verbosity=2)["tx"][0]
self.coins.append({ self.coins.append({
"txid": coinbase["txid"], "txid": coinbase["txid"],
@ -83,7 +83,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=chain_hex)]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=chain_hex)])
def test_chain_limits(self): def test_chain_limits(self):
@ -174,7 +174,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)])
def test_anc_count_limits(self): def test_anc_count_limits(self):
@ -230,7 +230,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)])
def test_anc_count_limits_2(self): def test_anc_count_limits_2(self):
@ -288,7 +288,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=[pc_hex, pd_hex])]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=[pc_hex, pd_hex])])
def test_anc_count_limits_bushy(self): def test_anc_count_limits_bushy(self):
@ -338,7 +338,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)])
def test_anc_size_limits(self): def test_anc_size_limits(self):
@ -397,7 +397,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=[pc_hex, pd_hex])]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=[pc_hex, pd_hex])])
def test_desc_size_limits(self): def test_desc_size_limits(self):
@ -468,7 +468,7 @@ class MempoolPackageLimitsTest(BitcoinTestFramework):
assert_equal(txres["package-error"], "package-mempool-limits") assert_equal(txres["package-error"], "package-mempool-limits")
# Clear mempool and check that the package passes now # Clear mempool and check that the package passes now
node.generate(1) self.generate(node, 1)
assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)]) assert all([res["allowed"] for res in node.testmempoolaccept(rawtxs=package_hex)])
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -30,7 +30,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Mine some blocks and have them mature. # Mine some blocks and have them mature.
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
utxo = self.nodes[0].listunspent(10) utxo = self.nodes[0].listunspent(10)
txid = utxo[0]['txid'] txid = utxo[0]['txid']
vout = utxo[0]['vout'] vout = utxo[0]['vout']

View file

@ -46,7 +46,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Mine some blocks and have them mature. # Mine some blocks and have them mature.
peer_inv_store = self.nodes[0].add_p2p_connection(P2PTxInvStore()) # keep track of invs peer_inv_store = self.nodes[0].add_p2p_connection(P2PTxInvStore()) # keep track of invs
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
utxo = self.nodes[0].listunspent(10) utxo = self.nodes[0].listunspent(10)
txid = utxo[0]['txid'] txid = utxo[0]['txid']
vout = utxo[0]['vout'] vout = utxo[0]['vout']
@ -179,7 +179,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
# Check that prioritising a tx before it's added to the mempool works # Check that prioritising a tx before it's added to the mempool works
# First clear the mempool by mining a block. # First clear the mempool by mining a block.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(len(self.nodes[0].getrawmempool()), 0)
# Prioritise a transaction that has been mined, then add it back to the # Prioritise a transaction that has been mined, then add it back to the
@ -270,7 +270,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
# Test reorg handling # Test reorg handling
# First, the basics: # First, the basics:
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
self.nodes[1].invalidateblock(self.nodes[0].getbestblockhash()) self.nodes[1].invalidateblock(self.nodes[0].getbestblockhash())
self.nodes[1].reconsiderblock(self.nodes[0].getbestblockhash()) self.nodes[1].reconsiderblock(self.nodes[0].getbestblockhash())
@ -317,7 +317,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
value = sent_value value = sent_value
# Mine these in a block # Mine these in a block
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Now generate tx8, with a big fee # Now generate tx8, with a big fee

View file

@ -160,7 +160,7 @@ class MempoolPersistTest(BitcoinTestFramework):
self.start_node(0) self.start_node(0)
# clear out mempool # clear out mempool
node0.generate(1) self.generate(node0, 1)
# ensure node0 doesn't have any connections # ensure node0 doesn't have any connections
# make a transaction that will remain in the unbroadcast set # make a transaction that will remain in the unbroadcast set

View file

@ -65,7 +65,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
wallet.sendrawtransaction(from_node=self.nodes[0], tx_hex=spend_2['hex']) wallet.sendrawtransaction(from_node=self.nodes[0], tx_hex=spend_2['hex'])
wallet.sendrawtransaction(from_node=self.nodes[0], tx_hex=spend_3['hex']) wallet.sendrawtransaction(from_node=self.nodes[0], tx_hex=spend_3['hex'])
self.log.info("Generate a block") self.log.info("Generate a block")
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.log.info("Check that time-locked transaction is still too immature to spend") self.log.info("Check that time-locked transaction is still too immature to spend")
assert_raises_rpc_error(-26, 'non-final', self.nodes[0].sendrawtransaction, timelock_tx) assert_raises_rpc_error(-26, 'non-final', self.nodes[0].sendrawtransaction, timelock_tx)
@ -78,7 +78,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
self.log.info("Broadcast and mine spend_3_1") self.log.info("Broadcast and mine spend_3_1")
spend_3_1_id = self.nodes[0].sendrawtransaction(spend_3_1['hex']) spend_3_1_id = self.nodes[0].sendrawtransaction(spend_3_1['hex'])
self.log.info("Generate a block") self.log.info("Generate a block")
last_block = self.nodes[0].generate(1) last_block = self.generate(self.nodes[0], 1)
# Sync blocks, so that peer 1 gets the block before timelock_tx # Sync blocks, so that peer 1 gets the block before timelock_tx
# Otherwise, peer 1 would put the timelock_tx in m_recent_rejects # Otherwise, peer 1 would put the timelock_tx in m_recent_rejects
self.sync_all() self.sync_all()

View file

@ -20,8 +20,8 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
wallet = MiniWallet(node) wallet = MiniWallet(node)
# Add enough mature utxos to the wallet so that all txs spend confirmed coins # Add enough mature utxos to the wallet so that all txs spend confirmed coins
wallet.generate(3) self.generate(wallet, 3)
node.generate(COINBASE_MATURITY) self.generate(node, COINBASE_MATURITY)
# Spend block 1/2/3's coinbase transactions # Spend block 1/2/3's coinbase transactions
# Mine a block # Mine a block
@ -34,9 +34,9 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
# ... make sure all the transactions are confirmed again # ... make sure all the transactions are confirmed again
blocks = [] blocks = []
spends1_ids = [wallet.send_self_transfer(from_node=node)['txid'] for _ in range(3)] spends1_ids = [wallet.send_self_transfer(from_node=node)['txid'] for _ in range(3)]
blocks.extend(node.generate(1)) blocks.extend(self.generate(node, 1))
spends2_ids = [wallet.send_self_transfer(from_node=node)['txid'] for _ in range(3)] spends2_ids = [wallet.send_self_transfer(from_node=node)['txid'] for _ in range(3)]
blocks.extend(node.generate(1)) blocks.extend(self.generate(node, 1))
spends_ids = set(spends1_ids + spends2_ids) spends_ids = set(spends1_ids + spends2_ids)
@ -53,7 +53,7 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
assert_equal(set(node.getrawmempool()), spends_ids) assert_equal(set(node.getrawmempool()), spends_ids)
# Generate another block, they should all get mined # Generate another block, they should all get mined
blocks = node.generate(1) blocks = self.generate(node, 1)
# mempool should be empty, all txns confirmed # mempool should be empty, all txns confirmed
assert_equal(set(node.getrawmempool()), set()) assert_equal(set(node.getrawmempool()), set())
confirmed_txns = set(node.getblock(blocks[0])['tx']) confirmed_txns = set(node.getblock(blocks[0])['tx'])

View file

@ -49,7 +49,7 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getrawmempool(), [spend_mature_id]) assert_equal(self.nodes[0].getrawmempool(), [spend_mature_id])
# mine a block, mature one should get confirmed # mine a block, mature one should get confirmed
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert_equal(set(self.nodes[0].getrawmempool()), set()) assert_equal(set(self.nodes[0].getrawmempool()), set())
# ... and now previously immature can be spent: # ... and now previously immature can be spent:

View file

@ -109,7 +109,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
# a block # a block
removal_reason = "Removed {} from set of unbroadcast txns before confirmation that txn was sent out".format(txhsh) removal_reason = "Removed {} from set of unbroadcast txns before confirmation that txn was sent out".format(txhsh)
with node.assert_debug_log([removal_reason]): with node.assert_debug_log([removal_reason]):
node.generate(1) self.generate(node, 1)
if __name__ == "__main__": if __name__ == "__main__":
MempoolUnbroadcastTest().main() MempoolUnbroadcastTest().main()

View file

@ -91,7 +91,7 @@ class MempoolUpdateFromBlockTest(BitcoinTestFramework):
if tx_count in n_tx_to_mine: if tx_count in n_tx_to_mine:
# The created transactions are mined into blocks by batches. # The created transactions are mined into blocks by batches.
self.log.info('The batch of {} transactions has been accepted into the mempool.'.format(len(self.nodes[0].getrawmempool()))) self.log.info('The batch of {} transactions has been accepted into the mempool.'.format(len(self.nodes[0].getrawmempool())))
block_hash = self.nodes[0].generate(1)[0] block_hash = self.generate(self.nodes[0], 1)[0]
if not first_block_hash: if not first_block_hash:
first_block_hash = block_hash first_block_hash = block_hash
assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(len(self.nodes[0].getrawmempool()), 0)

View file

@ -58,7 +58,7 @@ class MiningTest(BitcoinTestFramework):
self.log.info('Create some old blocks') self.log.info('Create some old blocks')
for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600): for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600):
self.nodes[0].setmocktime(t) self.nodes[0].setmocktime(t)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
mining_info = self.nodes[0].getmininginfo() mining_info = self.nodes[0].getmininginfo()
assert_equal(mining_info['blocks'], 200) assert_equal(mining_info['blocks'], 200)
assert_equal(mining_info['currentblocktx'], 0) assert_equal(mining_info['currentblocktx'], 0)
@ -109,7 +109,7 @@ class MiningTest(BitcoinTestFramework):
assert_equal(witness_commitment, script.hex()) assert_equal(witness_commitment, script.hex())
# Mine a block to leave initial block download and clear the mempool # Mine a block to leave initial block download and clear the mempool
node.generatetoaddress(1, node.get_deterministic_priv_key().address) self.generatetoaddress(node, 1, node.get_deterministic_priv_key().address)
tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS) tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS)
self.log.info("getblocktemplate: Test capability advertised") self.log.info("getblocktemplate: Test capability advertised")
assert 'proposal' in tmpl['capabilities'] assert 'proposal' in tmpl['capabilities']
@ -271,7 +271,7 @@ class MiningTest(BitcoinTestFramework):
assert chain_tip(block.hash, status='active', branchlen=0) in node.getchaintips() assert chain_tip(block.hash, status='active', branchlen=0) in node.getchaintips()
# Building a few blocks should give the same results # Building a few blocks should give the same results
node.generatetoaddress(10, node.get_deterministic_priv_key().address) self.generatetoaddress(node, 10, node.get_deterministic_priv_key().address)
assert_raises_rpc_error(-25, 'time-too-old', lambda: node.submitheader(hexdata=CBlockHeader(bad_block_time).serialize().hex())) assert_raises_rpc_error(-25, 'time-too-old', lambda: node.submitheader(hexdata=CBlockHeader(bad_block_time).serialize().hex()))
assert_raises_rpc_error(-25, 'bad-prevblk', lambda: node.submitheader(hexdata=CBlockHeader(bad_block2).serialize().hex())) assert_raises_rpc_error(-25, 'bad-prevblk', lambda: node.submitheader(hexdata=CBlockHeader(bad_block2).serialize().hex()))
node.submitheader(hexdata=CBlockHeader(block).serialize().hex()) node.submitheader(hexdata=CBlockHeader(block).serialize().hex())

View file

@ -35,7 +35,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.") self.log.info("Warning: this test will take about 70 seconds in the best case. Be patient.")
self.log.info("Test that longpollid doesn't change between successive getblocktemplate() invocations if nothing else happens") self.log.info("Test that longpollid doesn't change between successive getblocktemplate() invocations if nothing else happens")
self.nodes[0].generate(10) self.generate(self.nodes[0], 10)
template = self.nodes[0].getblocktemplate({'rules': ['segwit']}) template = self.nodes[0].getblocktemplate({'rules': ['segwit']})
longpollid = template['longpollid'] longpollid = template['longpollid']
template2 = self.nodes[0].getblocktemplate({'rules': ['segwit']}) template2 = self.nodes[0].getblocktemplate({'rules': ['segwit']})
@ -63,7 +63,7 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
assert not thr.is_alive() assert not thr.is_alive()
# Add enough mature utxos to the wallets, so that all txs spend confirmed coins # Add enough mature utxos to the wallets, so that all txs spend confirmed coins
self.nodes[0].generate(COINBASE_MATURITY) self.generate(self.nodes[0], COINBASE_MATURITY)
self.sync_blocks() self.sync_blocks()
self.log.info("Test that introducing a new transaction into the mempool will terminate the longpoll") self.log.info("Test that introducing a new transaction into the mempool will terminate the longpoll")

View file

@ -75,7 +75,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
# also check that a different entry in the cheapest bucket is NOT mined # also check that a different entry in the cheapest bucket is NOT mined
self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(3*base_fee*COIN)) self.nodes[0].prioritisetransaction(txid=txids[0][0], fee_delta=int(3*base_fee*COIN))
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
mempool = self.nodes[0].getrawmempool() mempool = self.nodes[0].getrawmempool()
self.log.info("Assert that prioritised transaction was mined") self.log.info("Assert that prioritised transaction was mined")
@ -105,7 +105,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
# the other high fee transactions. Keep mining until our mempool has # the other high fee transactions. Keep mining until our mempool has
# decreased by all the high fee size that we calculated above. # decreased by all the high fee size that we calculated above.
while (self.nodes[0].getmempoolinfo()['bytes'] > sizes[0] + sizes[1]): while (self.nodes[0].getmempoolinfo()['bytes'] > sizes[0] + sizes[1]):
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# High fee transaction should not have been mined, but other high fee rate # High fee transaction should not have been mined, but other high fee rate
# transactions should have been. # transactions should have been.

View file

@ -56,17 +56,17 @@ class CompactFiltersTest(BitcoinTestFramework):
peer_1 = self.nodes[1].add_p2p_connection(FiltersClient()) peer_1 = self.nodes[1].add_p2p_connection(FiltersClient())
# Nodes 0 & 1 share the same first 999 blocks in the chain. # Nodes 0 & 1 share the same first 999 blocks in the chain.
self.nodes[0].generate(999) self.generate(self.nodes[0], 999)
self.sync_blocks(timeout=600) self.sync_blocks(timeout=600)
# Stale blocks by disconnecting nodes 0 & 1, mining, then reconnecting # Stale blocks by disconnecting nodes 0 & 1, mining, then reconnecting
self.disconnect_nodes(0, 1) self.disconnect_nodes(0, 1)
stale_block_hash = self.nodes[0].generate(1)[0] stale_block_hash = self.generate(self.nodes[0], 1)[0]
self.nodes[0].syncwithvalidationinterfacequeue() self.nodes[0].syncwithvalidationinterfacequeue()
assert_equal(self.nodes[0].getblockcount(), 1000) assert_equal(self.nodes[0].getblockcount(), 1000)
self.nodes[1].generate(1001) self.generate(self.nodes[1], 1001)
assert_equal(self.nodes[1].getblockcount(), 2000) assert_equal(self.nodes[1].getblockcount(), 2000)
# Check that nodes have signalled NODE_COMPACT_FILTERS correctly. # Check that nodes have signalled NODE_COMPACT_FILTERS correctly.

View file

@ -23,8 +23,8 @@ class P2PBlocksOnly(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.miniwallet = MiniWallet(self.nodes[0]) self.miniwallet = MiniWallet(self.nodes[0])
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins # Add enough mature utxos to the wallet, so that all txs spend confirmed coins
self.miniwallet.generate(2) self.generate(self.miniwallet, 2)
self.nodes[0].generate(COINBASE_MATURITY) self.generate(self.nodes[0], COINBASE_MATURITY)
self.blocksonly_mode_tests() self.blocksonly_mode_tests()
self.blocks_relay_conn_tests() self.blocks_relay_conn_tests()
@ -73,7 +73,7 @@ class P2PBlocksOnly(BitcoinTestFramework):
self.log.info("Relay-permission peer's transaction is accepted and relayed") self.log.info("Relay-permission peer's transaction is accepted and relayed")
self.nodes[0].disconnect_p2ps() self.nodes[0].disconnect_p2ps()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
def blocks_relay_conn_tests(self): def blocks_relay_conn_tests(self):
self.log.info('Tests with node in normal mode with block-relay-only connections') self.log.info('Tests with node in normal mode with block-relay-only connections')

View file

@ -165,7 +165,7 @@ class CompactBlocksTest(BitcoinTestFramework):
block = self.build_block_on_tip(self.nodes[0]) block = self.build_block_on_tip(self.nodes[0])
self.segwit_node.send_and_ping(msg_no_witness_block(block)) self.segwit_node.send_and_ping(msg_no_witness_block(block))
assert int(self.nodes[0].getbestblockhash(), 16) == block.sha256 assert int(self.nodes[0].getbestblockhash(), 16) == block.sha256
self.nodes[0].generatetoaddress(COINBASE_MATURITY, self.nodes[0].getnewaddress(address_type="bech32")) self.generatetoaddress(self.nodes[0], COINBASE_MATURITY, self.nodes[0].getnewaddress(address_type="bech32"))
total_value = block.vtx[0].vout[0].nValue total_value = block.vtx[0].vout[0].nValue
out_value = total_value // 10 out_value = total_value // 10
@ -212,7 +212,7 @@ class CompactBlocksTest(BitcoinTestFramework):
def check_announcement_of_new_block(node, peer, predicate): def check_announcement_of_new_block(node, peer, predicate):
peer.clear_block_announcement() peer.clear_block_announcement()
block_hash = int(node.generate(1)[0], 16) block_hash = int(self.generate(node, 1)[0], 16)
peer.wait_for_block_announcement(block_hash, timeout=30) peer.wait_for_block_announcement(block_hash, timeout=30)
assert peer.block_announced assert peer.block_announced
@ -276,7 +276,7 @@ class CompactBlocksTest(BitcoinTestFramework):
# This test actually causes bitcoind to (reasonably!) disconnect us, so do this last. # This test actually causes bitcoind to (reasonably!) disconnect us, so do this last.
def test_invalid_cmpctblock_message(self): def test_invalid_cmpctblock_message(self):
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
block = self.build_block_on_tip(self.nodes[0]) block = self.build_block_on_tip(self.nodes[0])
cmpct_block = P2PHeaderAndShortIDs() cmpct_block = P2PHeaderAndShortIDs()
@ -294,7 +294,7 @@ class CompactBlocksTest(BitcoinTestFramework):
version = test_node.cmpct_version version = test_node.cmpct_version
node = self.nodes[0] node = self.nodes[0]
# Generate a bunch of transactions. # Generate a bunch of transactions.
node.generate(COINBASE_MATURITY + 1) self.generate(node, COINBASE_MATURITY + 1)
num_transactions = 25 num_transactions = 25
address = node.getnewaddress() address = node.getnewaddress()
@ -318,7 +318,7 @@ class CompactBlocksTest(BitcoinTestFramework):
# Now mine a block, and look at the resulting compact block. # Now mine a block, and look at the resulting compact block.
test_node.clear_block_announcement() test_node.clear_block_announcement()
block_hash = int(node.generate(1)[0], 16) block_hash = int(self.generate(node, 1)[0], 16)
# Store the raw block in our internal format. # Store the raw block in our internal format.
block = from_hex(CBlock(), node.getblock("%064x" % block_hash, False)) block = from_hex(CBlock(), node.getblock("%064x" % block_hash, False))
@ -660,7 +660,7 @@ class CompactBlocksTest(BitcoinTestFramework):
new_blocks = [] new_blocks = []
for _ in range(MAX_CMPCTBLOCK_DEPTH + 1): for _ in range(MAX_CMPCTBLOCK_DEPTH + 1):
test_node.clear_block_announcement() test_node.clear_block_announcement()
new_blocks.append(node.generate(1)[0]) new_blocks.append(self.generate(node, 1)[0])
test_node.wait_until(test_node.received_block_announcement, timeout=30) test_node.wait_until(test_node.received_block_announcement, timeout=30)
test_node.clear_block_announcement() test_node.clear_block_announcement()
@ -668,7 +668,7 @@ class CompactBlocksTest(BitcoinTestFramework):
test_node.wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30) test_node.wait_until(lambda: "cmpctblock" in test_node.last_message, timeout=30)
test_node.clear_block_announcement() test_node.clear_block_announcement()
node.generate(1) self.generate(node, 1)
test_node.wait_until(test_node.received_block_announcement, timeout=30) test_node.wait_until(test_node.received_block_announcement, timeout=30)
test_node.clear_block_announcement() test_node.clear_block_announcement()
with p2p_lock: with p2p_lock:
@ -844,7 +844,7 @@ class CompactBlocksTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Get the nodes out of IBD # Get the nodes out of IBD
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Setup the p2p connections # Setup the p2p connections
self.segwit_node = self.nodes[0].add_p2p_connection(TestP2PConn(cmpct_version=2)) self.segwit_node = self.nodes[0].add_p2p_connection(TestP2PConn(cmpct_version=2))

View file

@ -30,7 +30,7 @@ class CompactBlocksConnectionTest(BitcoinTestFramework):
def relay_block_through(self, peer): def relay_block_through(self, peer):
"""Relay a new block through peer peer, and return HB status between 1 and [2,3,4,5].""" """Relay a new block through peer peer, and return HB status between 1 and [2,3,4,5]."""
self.connect_nodes(peer, 0) self.connect_nodes(peer, 0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
self.disconnect_nodes(peer, 0) self.disconnect_nodes(peer, 0)
status_to = [self.peer_info(1, i)['bip152_hb_to'] for i in range(2, 6)] status_to = [self.peer_info(1, i)['bip152_hb_to'] for i in range(2, 6)]
@ -44,7 +44,7 @@ class CompactBlocksConnectionTest(BitcoinTestFramework):
# Connect everyone to node 0, and mine some blocks to get all nodes out of IBD. # Connect everyone to node 0, and mine some blocks to get all nodes out of IBD.
for i in range(1, 6): for i in range(1, 6):
self.connect_nodes(i, 0) self.connect_nodes(i, 0)
self.nodes[0].generate(2) self.generate(self.nodes[0], 2)
self.sync_blocks() self.sync_blocks()
for i in range(1, 6): for i in range(1, 6):
self.disconnect_nodes(i, 0) self.disconnect_nodes(i, 0)

View file

@ -53,7 +53,7 @@ class P2PEvict(BitcoinTestFramework):
protected_peers = set() # peers that we expect to be protected from eviction protected_peers = set() # peers that we expect to be protected from eviction
current_peer = -1 current_peer = -1
node = self.nodes[0] node = self.nodes[0]
node.generatetoaddress(COINBASE_MATURITY + 1, node.get_deterministic_priv_key().address) self.generatetoaddress(node, COINBASE_MATURITY + 1, node.get_deterministic_priv_key().address)
self.log.info("Create 4 peers and protect them from eviction by sending us a block") self.log.info("Create 4 peers and protect them from eviction by sending us a block")
for _ in range(4): for _ in range(4):

View file

@ -81,8 +81,8 @@ class FeeFilterTest(BitcoinTestFramework):
node0 = self.nodes[0] node0 = self.nodes[0]
miniwallet = MiniWallet(node1) miniwallet = MiniWallet(node1)
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins # Add enough mature utxos to the wallet, so that all txs spend confirmed coins
miniwallet.generate(5) self.generate(miniwallet, 5)
node1.generate(COINBASE_MATURITY) self.generate(node1, COINBASE_MATURITY)
conn = self.nodes[0].add_p2p_connection(TestP2PConn()) conn = self.nodes[0].add_p2p_connection(TestP2PConn())

View file

@ -149,7 +149,7 @@ class FilterTest(BitcoinTestFramework):
assert not filter_peer.tx_received assert not filter_peer.tx_received
# Clear the mempool so that this transaction does not impact subsequent tests # Clear the mempool so that this transaction does not impact subsequent tests
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
def test_filter(self, filter_peer): def test_filter(self, filter_peer):
# Set the bloomfilter using filterload # Set the bloomfilter using filterload
@ -159,14 +159,14 @@ class FilterTest(BitcoinTestFramework):
filter_address = self.nodes[0].decodescript(filter_peer.watch_script_pubkey)['address'] filter_address = self.nodes[0].decodescript(filter_peer.watch_script_pubkey)['address']
self.log.info('Check that we receive merkleblock and tx if the filter matches a tx in a block') self.log.info('Check that we receive merkleblock and tx if the filter matches a tx in a block')
block_hash = self.nodes[0].generatetoaddress(1, filter_address)[0] block_hash = self.generatetoaddress(self.nodes[0], 1, filter_address)[0]
txid = self.nodes[0].getblock(block_hash)['tx'][0] txid = self.nodes[0].getblock(block_hash)['tx'][0]
filter_peer.wait_for_merkleblock(block_hash) filter_peer.wait_for_merkleblock(block_hash)
filter_peer.wait_for_tx(txid) filter_peer.wait_for_tx(txid)
self.log.info('Check that we only receive a merkleblock if the filter does not match a tx in a block') self.log.info('Check that we only receive a merkleblock if the filter does not match a tx in a block')
filter_peer.tx_received = False filter_peer.tx_received = False
block_hash = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0] block_hash = self.generatetoaddress(self.nodes[0], 1, self.nodes[0].getnewaddress())[0]
filter_peer.wait_for_merkleblock(block_hash) filter_peer.wait_for_merkleblock(block_hash)
assert not filter_peer.tx_received assert not filter_peer.tx_received
@ -194,7 +194,7 @@ class FilterTest(BitcoinTestFramework):
filter_peer.merkleblock_received = False filter_peer.merkleblock_received = False
filter_peer.tx_received = False filter_peer.tx_received = False
with self.nodes[0].assert_debug_log(expected_msgs=['received getdata']): with self.nodes[0].assert_debug_log(expected_msgs=['received getdata']):
block_hash = self.nodes[0].generatetoaddress(1, self.nodes[0].getnewaddress())[0] block_hash = self.generatetoaddress(self.nodes[0], 1, self.nodes[0].getnewaddress())[0]
filter_peer.wait_for_inv([CInv(MSG_BLOCK, int(block_hash, 16))]) filter_peer.wait_for_inv([CInv(MSG_BLOCK, int(block_hash, 16))])
filter_peer.sync_with_ping() filter_peer.sync_with_ping()
assert not filter_peer.merkleblock_received assert not filter_peer.merkleblock_received

View file

@ -69,7 +69,7 @@ class P2PFingerprintTest(BitcoinTestFramework):
self.nodes[0].setmocktime(int(time.time()) - 60 * 24 * 60 * 60) self.nodes[0].setmocktime(int(time.time()) - 60 * 24 * 60 * 60)
# Generating a chain of 10 blocks # Generating a chain of 10 blocks
block_hashes = self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address) block_hashes = self.generatetoaddress(self.nodes[0], 10, self.nodes[0].get_deterministic_priv_key().address)
# Create longer chain starting 2 blocks before current tip # Create longer chain starting 2 blocks before current tip
height = len(block_hashes) - 2 height = len(block_hashes) - 2
@ -98,7 +98,7 @@ class P2PFingerprintTest(BitcoinTestFramework):
# Longest chain is extended so stale is much older than chain tip # Longest chain is extended so stale is much older than chain tip
self.nodes[0].setmocktime(0) self.nodes[0].setmocktime(0)
block_hash = int(self.nodes[0].generatetoaddress(1, self.nodes[0].get_deterministic_priv_key().address)[-1], 16) block_hash = int(self.generatetoaddress(self.nodes[0], 1, self.nodes[0].get_deterministic_priv_key().address)[-1], 16)
assert_equal(self.nodes[0].getblockcount(), 14) assert_equal(self.nodes[0].getblockcount(), 14)
node0.wait_for_block(block_hash, timeout=3) node0.wait_for_block(block_hash, timeout=3)

View file

@ -29,7 +29,7 @@ class P2PIBDTxRelayTest(BitcoinTestFramework):
self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo())) self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
# Come out of IBD by generating a block # Come out of IBD by generating a block
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
self.log.info("Check that nodes reset minfilter after coming out of IBD") self.log.info("Check that nodes reset minfilter after coming out of IBD")

View file

@ -51,7 +51,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
peer.send_blocks_and_test([block1], node, success=True) peer.send_blocks_and_test([block1], node, success=True)
self.log.info("Mature the block.") self.log.info("Mature the block.")
node.generatetoaddress(100, node.get_deterministic_priv_key().address) self.generatetoaddress(node, 100, node.get_deterministic_priv_key().address)
best_block = node.getblock(node.getbestblockhash()) best_block = node.getblock(node.getbestblockhash())
tip = int(node.getbestblockhash(), 16) tip = int(node.getbestblockhash(), 16)

View file

@ -16,7 +16,7 @@ class InvalidLocatorTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
node = self.nodes[0] # convenience reference to the node node = self.nodes[0] # convenience reference to the node
node.generatetoaddress(1, node.get_deterministic_priv_key().address) # Get node out of IBD self.generatetoaddress(node, 1, node.get_deterministic_priv_key().address) # Get node out of IBD
self.log.info('Test max locator size') self.log.info('Test max locator size')
block_count = node.getblockcount() block_count = node.getblockcount()

View file

@ -64,7 +64,7 @@ class InvalidTxRequestTest(BitcoinTestFramework):
node.p2ps[0].send_blocks_and_test([block], node, success=True) node.p2ps[0].send_blocks_and_test([block], node, success=True)
self.log.info("Mature the block.") self.log.info("Mature the block.")
self.nodes[0].generatetoaddress(100, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 100, self.nodes[0].get_deterministic_priv_key().address)
# Iterate through a list of known invalid transaction types, ensuring each is # Iterate through a list of known invalid transaction types, ensuring each is
# rejected. Some are consensus invalid and some just violate policy. # rejected. Some are consensus invalid and some just violate policy.

View file

@ -133,7 +133,7 @@ class P2PLeakTest(BitcoinTestFramework):
pre_wtxidrelay_peer.wait_until(lambda: pre_wtxidrelay_peer.version_received) pre_wtxidrelay_peer.wait_until(lambda: pre_wtxidrelay_peer.version_received)
# Mine a block and make sure that it's not sent to the connected peers # Mine a block and make sure that it's not sent to the connected peers
self.nodes[0].generate(nblocks=1) self.generate(self.nodes[0], nblocks=1)
# Give the node enough time to possibly leak out a message # Give the node enough time to possibly leak out a message
time.sleep(PEER_TIMEOUT + 2) time.sleep(PEER_TIMEOUT + 2)

View file

@ -27,8 +27,8 @@ class P2PLeakTxTest(BitcoinTestFramework):
gen_node = self.nodes[0] # The block and tx generating node gen_node = self.nodes[0] # The block and tx generating node
miniwallet = MiniWallet(gen_node) miniwallet = MiniWallet(gen_node)
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins # Add enough mature utxos to the wallet, so that all txs spend confirmed coins
miniwallet.generate(1) self.generate(miniwallet, 1)
gen_node.generate(COINBASE_MATURITY) self.generate(gen_node, COINBASE_MATURITY)
inbound_peer = self.nodes[0].add_p2p_connection(P2PNode()) # An "attacking" inbound peer inbound_peer = self.nodes[0].add_p2p_connection(P2PNode()) # An "attacking" inbound peer

View file

@ -59,7 +59,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
self.log.info("Mine enough blocks to reach the NODE_NETWORK_LIMITED range.") self.log.info("Mine enough blocks to reach the NODE_NETWORK_LIMITED range.")
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
blocks = self.nodes[1].generatetoaddress(292, self.nodes[1].get_deterministic_priv_key().address) blocks = self.generatetoaddress(self.nodes[1], 292, self.nodes[1].get_deterministic_priv_key().address)
self.sync_blocks([self.nodes[0], self.nodes[1]]) self.sync_blocks([self.nodes[0], self.nodes[1]])
self.log.info("Make sure we can max retrieve block at tip-288.") self.log.info("Make sure we can max retrieve block at tip-288.")
@ -101,7 +101,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
self.disconnect_all() self.disconnect_all()
# mine 10 blocks on node 0 (pruned node) # mine 10 blocks on node 0 (pruned node)
self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 10, self.nodes[0].get_deterministic_priv_key().address)
# connect node1 (non pruned) with node0 (pruned) and check if the can sync # connect node1 (non pruned) with node0 (pruned) and check if the can sync
self.connect_nodes(0, 1) self.connect_nodes(0, 1)

View file

@ -93,7 +93,7 @@ class P2PPermissionsTests(BitcoinTestFramework):
self.nodes[1].assert_start_raises_init_error(["-whitebind=noban@127.0.0.1/10"], "Cannot resolve -whitebind address", match=ErrorMatch.PARTIAL_REGEX) self.nodes[1].assert_start_raises_init_error(["-whitebind=noban@127.0.0.1/10"], "Cannot resolve -whitebind address", match=ErrorMatch.PARTIAL_REGEX)
def check_tx_relay(self): def check_tx_relay(self):
block_op_true = self.nodes[0].getblock(self.nodes[0].generatetoaddress(100, ADDRESS_BCRT1_P2WSH_OP_TRUE)[0]) block_op_true = self.nodes[0].getblock(self.generatetoaddress(self.nodes[0], 100, ADDRESS_BCRT1_P2WSH_OP_TRUE)[0])
self.sync_all() self.sync_all()
self.log.debug("Create a connection from a forcerelay peer that rebroadcasts raw txs") self.log.debug("Create a connection from a forcerelay peer that rebroadcasts raw txs")

View file

@ -303,7 +303,7 @@ class SegWitTest(BitcoinTestFramework):
self.test_node.send_and_ping(msg_no_witness_block(block)) # make sure the block was processed self.test_node.send_and_ping(msg_no_witness_block(block)) # make sure the block was processed
txid = block.vtx[0].sha256 txid = block.vtx[0].sha256
self.nodes[0].generate(99) # let the block mature self.generate(self.nodes[0], 99) # let the block mature
# Create a transaction that spends the coinbase # Create a transaction that spends the coinbase
tx = CTransaction() tx = CTransaction()
@ -319,7 +319,7 @@ class SegWitTest(BitcoinTestFramework):
assert tx.hash in self.nodes[0].getrawmempool() assert tx.hash in self.nodes[0].getrawmempool()
# Save this transaction for later # Save this transaction for later
self.utxo.append(UTXO(tx.sha256, 0, 49 * 100000000)) self.utxo.append(UTXO(tx.sha256, 0, 49 * 100000000))
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
@subtest # type: ignore @subtest # type: ignore
def test_unnecessary_witness_before_segwit_activation(self): def test_unnecessary_witness_before_segwit_activation(self):
@ -555,7 +555,7 @@ class SegWitTest(BitcoinTestFramework):
test_transaction_acceptance(self.nodes[0], self.test_node, tx, with_witness=False, accepted=True) test_transaction_acceptance(self.nodes[0], self.test_node, tx, with_witness=False, accepted=True)
# Cleanup: mine the first transaction and update utxo # Cleanup: mine the first transaction and update utxo
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(len(self.nodes[0].getrawmempool()), 0)
self.utxo.pop(0) self.utxo.pop(0)
@ -580,7 +580,7 @@ class SegWitTest(BitcoinTestFramework):
# Mine it on test_node to create the confirmed output. # Mine it on test_node to create the confirmed output.
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_tx, with_witness=True, accepted=True) test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_tx, with_witness=True, accepted=True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
# Now test standardness of v0 P2WSH outputs. # Now test standardness of v0 P2WSH outputs.
@ -653,7 +653,7 @@ class SegWitTest(BitcoinTestFramework):
) )
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=True) test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
self.utxo.pop(0) self.utxo.pop(0)
self.utxo.append(UTXO(tx3.sha256, 0, tx3.vout[0].nValue)) self.utxo.append(UTXO(tx3.sha256, 0, tx3.vout[0].nValue))
@ -664,9 +664,9 @@ class SegWitTest(BitcoinTestFramework):
"""Mine enough blocks to activate segwit.""" """Mine enough blocks to activate segwit."""
assert not softfork_active(self.nodes[0], 'segwit') assert not softfork_active(self.nodes[0], 'segwit')
height = self.nodes[0].getblockcount() height = self.nodes[0].getblockcount()
self.nodes[0].generate(SEGWIT_HEIGHT - height - 2) self.generate(self.nodes[0], SEGWIT_HEIGHT - height - 2)
assert not softfork_active(self.nodes[0], 'segwit') assert not softfork_active(self.nodes[0], 'segwit')
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert softfork_active(self.nodes[0], 'segwit') assert softfork_active(self.nodes[0], 'segwit')
self.segwit_active = True self.segwit_active = True
@ -1298,7 +1298,7 @@ class SegWitTest(BitcoinTestFramework):
assert vsize != raw_tx["size"] assert vsize != raw_tx["size"]
# Cleanup: mine the transactions and update utxo for next test # Cleanup: mine the transactions and update utxo for next test
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(len(self.nodes[0].getrawmempool()), 0)
self.utxo.pop(0) self.utxo.pop(0)
@ -1348,7 +1348,7 @@ class SegWitTest(BitcoinTestFramework):
self.utxo.pop(0) self.utxo.pop(0)
temp_utxo.append(UTXO(tx.sha256, 0, tx.vout[0].nValue)) temp_utxo.append(UTXO(tx.sha256, 0, tx.vout[0].nValue))
self.nodes[0].generate(1) # Mine all the transactions self.generate(self.nodes[0], 1) # Mine all the transactions
self.sync_blocks() self.sync_blocks()
assert len(self.nodes[0].getrawmempool()) == 0 assert len(self.nodes[0].getrawmempool()) == 0
@ -1419,14 +1419,14 @@ class SegWitTest(BitcoinTestFramework):
spend_tx.rehash() spend_tx.rehash()
# Now test a premature spend. # Now test a premature spend.
self.nodes[0].generate(98) self.generate(self.nodes[0], 98)
self.sync_blocks() self.sync_blocks()
block2 = self.build_next_block() block2 = self.build_next_block()
self.update_witness_block_with_transactions(block2, [spend_tx]) self.update_witness_block_with_transactions(block2, [spend_tx])
test_witness_block(self.nodes[0], self.test_node, block2, accepted=False) test_witness_block(self.nodes[0], self.test_node, block2, accepted=False)
# Advancing one more block should allow the spend. # Advancing one more block should allow the spend.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
block2 = self.build_next_block() block2 = self.build_next_block()
self.update_witness_block_with_transactions(block2, [spend_tx]) self.update_witness_block_with_transactions(block2, [spend_tx])
test_witness_block(self.nodes[0], self.test_node, block2, accepted=True) test_witness_block(self.nodes[0], self.test_node, block2, accepted=True)
@ -1733,7 +1733,7 @@ class SegWitTest(BitcoinTestFramework):
tx.vout.append(CTxOut(self.utxo[0].nValue - 1000, script_pubkey)) tx.vout.append(CTxOut(self.utxo[0].nValue - 1000, script_pubkey))
tx.rehash() tx.rehash()
test_transaction_acceptance(self.nodes[0], self.test_node, tx, False, True) test_transaction_acceptance(self.nodes[0], self.test_node, tx, False, True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
# We'll add an unnecessary witness to this transaction that would cause # We'll add an unnecessary witness to this transaction that would cause
@ -1762,7 +1762,7 @@ class SegWitTest(BitcoinTestFramework):
test_transaction_acceptance(self.nodes[0], self.test_node, tx2, False, True) test_transaction_acceptance(self.nodes[0], self.test_node, tx2, False, True)
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, False, True) test_transaction_acceptance(self.nodes[0], self.test_node, tx3, False, True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
# Update our utxo list; we spent the first entry. # Update our utxo list; we spent the first entry.
@ -1797,7 +1797,7 @@ class SegWitTest(BitcoinTestFramework):
txid = tx.sha256 txid = tx.sha256
test_transaction_acceptance(self.nodes[0], self.test_node, tx, with_witness=False, accepted=True) test_transaction_acceptance(self.nodes[0], self.test_node, tx, with_witness=False, accepted=True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
# Creating transactions for tests # Creating transactions for tests
@ -1860,7 +1860,7 @@ class SegWitTest(BitcoinTestFramework):
test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-nonstandard') test_transaction_acceptance(self.nodes[1], self.std_node, p2sh_txs[3], True, False, 'bad-witness-nonstandard')
test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True) test_transaction_acceptance(self.nodes[0], self.test_node, p2sh_txs[3], True, True)
self.nodes[0].generate(1) # Mine and clean up the mempool of non-standard node self.generate(self.nodes[0], 1) # Mine and clean up the mempool of non-standard node
# Valid but non-standard transactions in a block should be accepted by standard node # Valid but non-standard transactions in a block should be accepted by standard node
self.sync_blocks() self.sync_blocks()
assert_equal(len(self.nodes[0].getrawmempool()), 0) assert_equal(len(self.nodes[0].getrawmempool()), 0)
@ -1998,7 +1998,7 @@ class SegWitTest(BitcoinTestFramework):
return serialize_with_bogus_witness(self.tx) return serialize_with_bogus_witness(self.tx)
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(address_type='bech32'), 5) self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(address_type='bech32'), 5)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
unspent = next(u for u in self.nodes[0].listunspent() if u['spendable'] and u['address'].startswith('bcrt')) unspent = next(u for u in self.nodes[0].listunspent() if u['spendable'] and u['address'].startswith('bcrt'))
raw = self.nodes[0].createrawtransaction([{"txid": unspent['txid'], "vout": unspent['vout']}], {self.nodes[0].getnewaddress(): 1}) raw = self.nodes[0].createrawtransaction([{"txid": unspent['txid'], "vout": unspent['vout']}], {self.nodes[0].getnewaddress(): 1})

View file

@ -205,7 +205,7 @@ class SendHeadersTest(BitcoinTestFramework):
# Clear out block announcements from each p2p listener # Clear out block announcements from each p2p listener
[x.clear_block_announcements() for x in self.nodes[0].p2ps] [x.clear_block_announcements() for x in self.nodes[0].p2ps]
self.nodes[0].generatetoaddress(count, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], count, self.nodes[0].get_deterministic_priv_key().address)
return int(self.nodes[0].getbestblockhash(), 16) return int(self.nodes[0].getbestblockhash(), 16)
def mine_reorg(self, length): def mine_reorg(self, length):
@ -216,7 +216,7 @@ class SendHeadersTest(BitcoinTestFramework):
return the list of block hashes newly mined.""" return the list of block hashes newly mined."""
# make sure all invalidated blocks are node0's # make sure all invalidated blocks are node0's
self.nodes[0].generatetoaddress(length, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], length, self.nodes[0].get_deterministic_priv_key().address)
self.sync_blocks(self.nodes, wait=0.1) self.sync_blocks(self.nodes, wait=0.1)
for x in self.nodes[0].p2ps: for x in self.nodes[0].p2ps:
x.wait_for_block_announcement(int(self.nodes[0].getbestblockhash(), 16)) x.wait_for_block_announcement(int(self.nodes[0].getbestblockhash(), 16))
@ -225,7 +225,7 @@ class SendHeadersTest(BitcoinTestFramework):
tip_height = self.nodes[1].getblockcount() tip_height = self.nodes[1].getblockcount()
hash_to_invalidate = self.nodes[1].getblockhash(tip_height - (length - 1)) hash_to_invalidate = self.nodes[1].getblockhash(tip_height - (length - 1))
self.nodes[1].invalidateblock(hash_to_invalidate) self.nodes[1].invalidateblock(hash_to_invalidate)
all_hashes = self.nodes[1].generatetoaddress(length + 1, self.nodes[1].get_deterministic_priv_key().address) # Must be longer than the orig chain all_hashes = self.generatetoaddress(self.nodes[1], length + 1, self.nodes[1].get_deterministic_priv_key().address) # Must be longer than the orig chain
self.sync_blocks(self.nodes, wait=0.1) self.sync_blocks(self.nodes, wait=0.1)
return [int(x, 16) for x in all_hashes] return [int(x, 16) for x in all_hashes]
@ -240,7 +240,7 @@ class SendHeadersTest(BitcoinTestFramework):
self.test_nonnull_locators(test_node, inv_node) self.test_nonnull_locators(test_node, inv_node)
def test_null_locators(self, test_node, inv_node): def test_null_locators(self, test_node, inv_node):
tip = self.nodes[0].getblockheader(self.nodes[0].generatetoaddress(1, self.nodes[0].get_deterministic_priv_key().address)[0]) tip = self.nodes[0].getblockheader(self.generatetoaddress(self.nodes[0], 1, self.nodes[0].get_deterministic_priv_key().address)[0])
tip_hash = int(tip["hash"], 16) tip_hash = int(tip["hash"], 16)
inv_node.check_last_inv_announcement(inv=[tip_hash]) inv_node.check_last_inv_announcement(inv=[tip_hash])

View file

@ -40,7 +40,7 @@ class AddressesDeprecationTest(BitcoinTestFramework):
txid = node.sendrawtransaction(hexstring=tx_signed, maxfeerate=0) txid = node.sendrawtransaction(hexstring=tx_signed, maxfeerate=0)
self.log.info("Test RPCResult scriptPubKey no longer returns the fields addresses or reqSigs by default") self.log.info("Test RPCResult scriptPubKey no longer returns the fields addresses or reqSigs by default")
hash = node.generateblock(output=node.getnewaddress(), transactions=[txid])['hash'] hash = self.generateblock(node, output=node.getnewaddress(), transactions=[txid])['hash']
# Ensure both nodes have the newly generated block on disk. # Ensure both nodes have the newly generated block on disk.
self.sync_blocks() self.sync_blocks()
script_pub_key = node.getblock(blockhash=hash, verbose=2)['tx'][-1]['vout'][0]['scriptPubKey'] script_pub_key = node.getblock(blockhash=hash, verbose=2)['tx'][-1]['vout'][0]['scriptPubKey']

View file

@ -84,7 +84,7 @@ class BlockchainTest(BitcoinTestFramework):
self.log.info(f"Generate {HEIGHT} blocks after the genesis block in ten-minute steps") self.log.info(f"Generate {HEIGHT} blocks after the genesis block in ten-minute steps")
for t in range(TIME_GENESIS_BLOCK, TIME_RANGE_END, TIME_RANGE_STEP): for t in range(TIME_GENESIS_BLOCK, TIME_RANGE_END, TIME_RANGE_STEP):
self.nodes[0].setmocktime(t) self.nodes[0].setmocktime(t)
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_P2WSH_OP_TRUE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_P2WSH_OP_TRUE)
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], HEIGHT) assert_equal(self.nodes[0].getblockchaininfo()['blocks'], HEIGHT)
def _test_getblockchaininfo(self): def _test_getblockchaininfo(self):
@ -351,12 +351,12 @@ class BlockchainTest(BitcoinTestFramework):
def _test_stopatheight(self): def _test_stopatheight(self):
self.log.info("Test stopping at height") self.log.info("Test stopping at height")
assert_equal(self.nodes[0].getblockcount(), HEIGHT) assert_equal(self.nodes[0].getblockcount(), HEIGHT)
self.nodes[0].generatetoaddress(6, ADDRESS_BCRT1_P2WSH_OP_TRUE) self.generatetoaddress(self.nodes[0], 6, ADDRESS_BCRT1_P2WSH_OP_TRUE)
assert_equal(self.nodes[0].getblockcount(), HEIGHT + 6) assert_equal(self.nodes[0].getblockcount(), HEIGHT + 6)
self.log.debug('Node should not stop at this height') self.log.debug('Node should not stop at this height')
assert_raises(subprocess.TimeoutExpired, lambda: self.nodes[0].process.wait(timeout=3)) assert_raises(subprocess.TimeoutExpired, lambda: self.nodes[0].process.wait(timeout=3))
try: try:
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_P2WSH_OP_TRUE) self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_P2WSH_OP_TRUE)
except (ConnectionError, http.client.BadStatusLine): except (ConnectionError, http.client.BadStatusLine):
pass # The node already shut down before response pass # The node already shut down before response
self.log.debug('Node should stop at this height...') self.log.debug('Node should stop at this height...')
@ -412,7 +412,7 @@ class BlockchainTest(BitcoinTestFramework):
fee_per_kb = 1000 * fee_per_byte fee_per_kb = 1000 * fee_per_byte
miniwallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node) miniwallet.send_self_transfer(fee_rate=fee_per_kb, from_node=node)
blockhash = node.generate(1)[0] blockhash = self.generate(node, 1)[0]
self.log.info("Test getblock with verbosity 1 doesn't include fee") self.log.info("Test getblock with verbosity 1 doesn't include fee")
block = node.getblock(blockhash, 1) block = node.getblock(blockhash, 1)

View file

@ -45,7 +45,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
self.check_addmultisigaddress_errors() self.check_addmultisigaddress_errors()
self.log.info('Generating blocks ...') self.log.info('Generating blocks ...')
node0.generate(149) self.generate(node0, 149)
self.sync_all() self.sync_all()
self.moved = 0 self.moved = 0
@ -116,7 +116,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
def checkbalances(self): def checkbalances(self):
node0, node1, node2 = self.nodes node0, node1, node2 = self.nodes
node0.generate(COINBASE_MATURITY) self.generate(node0, COINBASE_MATURITY)
self.sync_all() self.sync_all()
bal0 = node0.getbalance() bal0 = node0.getbalance()
@ -179,7 +179,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
value = tx["vout"][vout]["value"] value = tx["vout"][vout]["value"]
prevtxs = [{"txid": txid, "vout": vout, "scriptPubKey": scriptPubKey, "redeemScript": mredeem, "amount": value}] prevtxs = [{"txid": txid, "vout": vout, "scriptPubKey": scriptPubKey, "redeemScript": mredeem, "amount": value}]
node0.generate(1) self.generate(node0, 1)
outval = value - decimal.Decimal("0.00001000") outval = value - decimal.Decimal("0.00001000")
rawtx = node2.createrawtransaction([{"txid": txid, "vout": vout}], [{self.final: outval}]) rawtx = node2.createrawtransaction([{"txid": txid, "vout": vout}], [{self.final: outval}])
@ -215,7 +215,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
self.moved += outval self.moved += outval
tx = node0.sendrawtransaction(rawtx3["hex"], 0) tx = node0.sendrawtransaction(rawtx3["hex"], 0)
blk = node0.generate(1)[0] blk = self.generate(node0, 1)[0]
assert tx in node0.getblock(blk)["tx"] assert tx in node0.getblock(blk)["tx"]
txinfo = node0.getrawtransaction(tx, True, blk) txinfo = node0.getrawtransaction(tx, True, blk)

View file

@ -21,7 +21,7 @@ class DeprecatedRpcTest(BitcoinTestFramework):
# In run_test: # In run_test:
# self.log.info("Test generate RPC") # self.log.info("Test generate RPC")
# assert_raises_rpc_error(-32, 'The wallet generate rpc method is deprecated', self.nodes[0].rpc.generate, 1) # assert_raises_rpc_error(-32, 'The wallet generate rpc method is deprecated', self.nodes[0].rpc.generate, 1)
# self.nodes[1].generate(1) # self.generate(self.nodes[1], 1)
self.log.info("No tested deprecated RPC methods") self.log.info("No tested deprecated RPC methods")

View file

@ -23,7 +23,7 @@ class DumptxoutsetTest(BitcoinTestFramework):
node = self.nodes[0] node = self.nodes[0]
mocktime = node.getblockheader(node.getblockhash(0))['time'] + 1 mocktime = node.getblockheader(node.getblockhash(0))['time'] + 1
node.setmocktime(mocktime) node.setmocktime(mocktime)
node.generate(COINBASE_MATURITY) self.generate(node, COINBASE_MATURITY)
FILENAME = 'txoutset.dat' FILENAME = 'txoutset.dat'
out = node.dumptxoutset(FILENAME) out = node.dumptxoutset(FILENAME)

View file

@ -63,9 +63,9 @@ class RawTransactionsTest(BitcoinTestFramework):
# = 2 bytes * minRelayTxFeePerByte # = 2 bytes * minRelayTxFeePerByte
self.fee_tolerance = 2 * self.min_relay_tx_fee / 1000 self.fee_tolerance = 2 * self.min_relay_tx_fee / 1000
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all() self.sync_all()
self.nodes[0].generate(121) self.generate(self.nodes[0], 121)
self.sync_all() self.sync_all()
self.test_change_position() self.test_change_position()
@ -126,7 +126,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1.0)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 5.0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
wwatch.unloadwallet() wwatch.unloadwallet()
@ -500,7 +500,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# Send 1.2 BTC to msig addr. # Send 1.2 BTC to msig addr.
self.nodes[0].sendtoaddress(mSigObj, 1.2) self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
oldBalance = self.nodes[1].getbalance() oldBalance = self.nodes[1].getbalance()
@ -511,7 +511,7 @@ class RawTransactionsTest(BitcoinTestFramework):
signed_psbt = w2.walletprocesspsbt(funded_psbt) signed_psbt = w2.walletprocesspsbt(funded_psbt)
final_psbt = w2.finalizepsbt(signed_psbt['psbt']) final_psbt = w2.finalizepsbt(signed_psbt['psbt'])
self.nodes[2].sendrawtransaction(final_psbt['hex']) self.nodes[2].sendrawtransaction(final_psbt['hex'])
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all() self.sync_all()
# Make sure funds are received at node1. # Make sure funds are received at node1.
@ -572,7 +572,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[1].walletpassphrase("test", 600) self.nodes[1].walletpassphrase("test", 600)
signedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex']) signedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
self.nodes[1].sendrawtransaction(signedTx['hex']) self.nodes[1].sendrawtransaction(signedTx['hex'])
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
# Make sure funds are received at node1. # Make sure funds are received at node1.
@ -584,12 +584,12 @@ class RawTransactionsTest(BitcoinTestFramework):
# Empty node1, send some small coins from node0 to node1. # Empty node1, send some small coins from node0 to node1.
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True) self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
for _ in range(20): for _ in range(20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Fund a tx with ~20 small inputs. # Fund a tx with ~20 small inputs.
@ -612,12 +612,12 @@ class RawTransactionsTest(BitcoinTestFramework):
# Again, empty node1, send some small coins from node0 to node1. # Again, empty node1, send some small coins from node0 to node1.
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True) self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
for _ in range(20): for _ in range(20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Fund a tx with ~20 small inputs. # Fund a tx with ~20 small inputs.
@ -629,7 +629,7 @@ class RawTransactionsTest(BitcoinTestFramework):
fundedTx = self.nodes[1].fundrawtransaction(rawtx) fundedTx = self.nodes[1].fundrawtransaction(rawtx)
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex']) fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex']) self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex'])
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward assert_equal(oldBalance+Decimal('50.19000000'), self.nodes[0].getbalance()) #0.19+block reward
@ -707,7 +707,7 @@ class RawTransactionsTest(BitcoinTestFramework):
signedtx = self.nodes[0].signrawtransactionwithwallet(signedtx["hex"]) signedtx = self.nodes[0].signrawtransactionwithwallet(signedtx["hex"])
assert signedtx["complete"] assert signedtx["complete"]
self.nodes[0].sendrawtransaction(signedtx["hex"]) self.nodes[0].sendrawtransaction(signedtx["hex"])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
wwatch.unloadwallet() wwatch.unloadwallet()
@ -933,7 +933,7 @@ class RawTransactionsTest(BitcoinTestFramework):
for _ in range(1500): for _ in range(1500):
outputs[recipient.getnewaddress()] = 0.1 outputs[recipient.getnewaddress()] = 0.1
wallet.sendmany("", outputs) wallet.sendmany("", outputs)
self.nodes[0].generate(10) self.generate(self.nodes[0], 10)
assert_raises_rpc_error(-4, "Transaction too large", recipient.fundrawtransaction, rawtx) assert_raises_rpc_error(-4, "Transaction too large", recipient.fundrawtransaction, rawtx)
def test_include_unsafe(self): def test_include_unsafe(self):
@ -962,7 +962,7 @@ class RawTransactionsTest(BitcoinTestFramework):
wallet.sendrawtransaction(signedtx['hex']) wallet.sendrawtransaction(signedtx['hex'])
# And we can also use them once they're confirmed. # And we can also use them once they're confirmed.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
rawtx = wallet.createrawtransaction([], [{self.nodes[2].getnewaddress(): 3}]) rawtx = wallet.createrawtransaction([], [{self.nodes[2].getnewaddress(): 3}])
fundedtx = wallet.fundrawtransaction(rawtx, {"include_unsafe": True}) fundedtx = wallet.fundrawtransaction(rawtx, {"include_unsafe": True})
tx_dec = wallet.decoderawtransaction(fundedtx['hex']) tx_dec = wallet.decoderawtransaction(fundedtx['hex'])
@ -993,7 +993,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# than any single input available, and require more than 1 input. So we make 3 outputs # than any single input available, and require more than 1 input. So we make 3 outputs
for i in range(0, 3): for i in range(0, 3):
funds.sendtoaddress(tester.getnewaddress(address_type="bech32"), 1) funds.sendtoaddress(tester.getnewaddress(address_type="bech32"), 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Create transactions in order to calculate fees for the target bounds that can trigger this bug # Create transactions in order to calculate fees for the target bounds that can trigger this bug
change_tx = tester.fundrawtransaction(tester.createrawtransaction([], [{funds.getnewaddress(): 1.5}])) change_tx = tester.fundrawtransaction(tester.createrawtransaction([], [{funds.getnewaddress(): 1.5}]))

View file

@ -24,13 +24,13 @@ class GenerateBlockTest(BitcoinTestFramework):
self.log.info('Generate an empty block to address') self.log.info('Generate an empty block to address')
address = node.getnewaddress() address = node.getnewaddress()
hash = node.generateblock(output=address, transactions=[])['hash'] hash = self.generateblock(node, output=address, transactions=[])['hash']
block = node.getblock(blockhash=hash, verbose=2) block = node.getblock(blockhash=hash, verbose=2)
assert_equal(len(block['tx']), 1) assert_equal(len(block['tx']), 1)
assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], address) assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], address)
self.log.info('Generate an empty block to a descriptor') self.log.info('Generate an empty block to a descriptor')
hash = node.generateblock('addr(' + address + ')', [])['hash'] hash = self.generateblock(node, 'addr(' + address + ')', [])['hash']
block = node.getblock(blockhash=hash, verbosity=2) block = node.getblock(blockhash=hash, verbosity=2)
assert_equal(len(block['tx']), 1) assert_equal(len(block['tx']), 1)
assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], address) assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], address)
@ -38,7 +38,7 @@ class GenerateBlockTest(BitcoinTestFramework):
self.log.info('Generate an empty block to a combo descriptor with compressed pubkey') self.log.info('Generate an empty block to a combo descriptor with compressed pubkey')
combo_key = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' combo_key = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
combo_address = 'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080' combo_address = 'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080'
hash = node.generateblock('combo(' + combo_key + ')', [])['hash'] hash = self.generateblock(node, 'combo(' + combo_key + ')', [])['hash']
block = node.getblock(hash, 2) block = node.getblock(hash, 2)
assert_equal(len(block['tx']), 1) assert_equal(len(block['tx']), 1)
assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], combo_address) assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], combo_address)
@ -46,13 +46,13 @@ class GenerateBlockTest(BitcoinTestFramework):
self.log.info('Generate an empty block to a combo descriptor with uncompressed pubkey') self.log.info('Generate an empty block to a combo descriptor with uncompressed pubkey')
combo_key = '0408ef68c46d20596cc3f6ddf7c8794f71913add807f1dc55949fa805d764d191c0b7ce6894c126fce0babc6663042f3dde9b0cf76467ea315514e5a6731149c67' combo_key = '0408ef68c46d20596cc3f6ddf7c8794f71913add807f1dc55949fa805d764d191c0b7ce6894c126fce0babc6663042f3dde9b0cf76467ea315514e5a6731149c67'
combo_address = 'mkc9STceoCcjoXEXe6cm66iJbmjM6zR9B2' combo_address = 'mkc9STceoCcjoXEXe6cm66iJbmjM6zR9B2'
hash = node.generateblock('combo(' + combo_key + ')', [])['hash'] hash = self.generateblock(node, 'combo(' + combo_key + ')', [])['hash']
block = node.getblock(hash, 2) block = node.getblock(hash, 2)
assert_equal(len(block['tx']), 1) assert_equal(len(block['tx']), 1)
assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], combo_address) assert_equal(block['tx'][0]['vout'][0]['scriptPubKey']['address'], combo_address)
# Generate 110 blocks to spend # Generate 110 blocks to spend
node.generatetoaddress(110, address) self.generatetoaddress(node, 110, address)
# Generate some extra mempool transactions to verify they don't get mined # Generate some extra mempool transactions to verify they don't get mined
for _ in range(10): for _ in range(10):
@ -60,7 +60,7 @@ class GenerateBlockTest(BitcoinTestFramework):
self.log.info('Generate block with txid') self.log.info('Generate block with txid')
txid = node.sendtoaddress(address, 1) txid = node.sendtoaddress(address, 1)
hash = node.generateblock(address, [txid])['hash'] hash = self.generateblock(node, address, [txid])['hash']
block = node.getblock(hash, 1) block = node.getblock(hash, 1)
assert_equal(len(block['tx']), 2) assert_equal(len(block['tx']), 2)
assert_equal(block['tx'][1], txid) assert_equal(block['tx'][1], txid)
@ -69,7 +69,7 @@ class GenerateBlockTest(BitcoinTestFramework):
utxos = node.listunspent(addresses=[address]) utxos = node.listunspent(addresses=[address])
raw = node.createrawtransaction([{'txid':utxos[0]['txid'], 'vout':utxos[0]['vout']}],[{address:1}]) raw = node.createrawtransaction([{'txid':utxos[0]['txid'], 'vout':utxos[0]['vout']}],[{address:1}])
signed_raw = node.signrawtransactionwithwallet(raw)['hex'] signed_raw = node.signrawtransactionwithwallet(raw)['hex']
hash = node.generateblock(address, [signed_raw])['hash'] hash = self.generateblock(node, address, [signed_raw])['hash']
block = node.getblock(hash, 1) block = node.getblock(hash, 1)
assert_equal(len(block['tx']), 2) assert_equal(len(block['tx']), 2)
txid = block['tx'][1] txid = block['tx'][1]
@ -81,26 +81,26 @@ class GenerateBlockTest(BitcoinTestFramework):
txid1 = node.sendrawtransaction(signed_raw1) txid1 = node.sendrawtransaction(signed_raw1)
raw2 = node.createrawtransaction([{'txid':txid1, 'vout':0}],[{address:0.999}]) raw2 = node.createrawtransaction([{'txid':txid1, 'vout':0}],[{address:0.999}])
signed_raw2 = node.signrawtransactionwithwallet(raw2)['hex'] signed_raw2 = node.signrawtransactionwithwallet(raw2)['hex']
assert_raises_rpc_error(-25, 'TestBlockValidity failed: bad-txns-inputs-missingorspent', node.generateblock, address, [signed_raw2, txid1]) assert_raises_rpc_error(-25, 'TestBlockValidity failed: bad-txns-inputs-missingorspent', self.generateblock, node, address, [signed_raw2, txid1])
self.log.info('Fail to generate block with txid not in mempool') self.log.info('Fail to generate block with txid not in mempool')
missing_txid = '0000000000000000000000000000000000000000000000000000000000000000' missing_txid = '0000000000000000000000000000000000000000000000000000000000000000'
assert_raises_rpc_error(-5, 'Transaction ' + missing_txid + ' not in mempool.', node.generateblock, address, [missing_txid]) assert_raises_rpc_error(-5, 'Transaction ' + missing_txid + ' not in mempool.', self.generateblock, node, address, [missing_txid])
self.log.info('Fail to generate block with invalid raw tx') self.log.info('Fail to generate block with invalid raw tx')
invalid_raw_tx = '0000' invalid_raw_tx = '0000'
assert_raises_rpc_error(-22, 'Transaction decode failed for ' + invalid_raw_tx, node.generateblock, address, [invalid_raw_tx]) assert_raises_rpc_error(-22, 'Transaction decode failed for ' + invalid_raw_tx, self.generateblock, node, address, [invalid_raw_tx])
self.log.info('Fail to generate block with invalid address/descriptor') self.log.info('Fail to generate block with invalid address/descriptor')
assert_raises_rpc_error(-5, 'Invalid address or descriptor', node.generateblock, '1234', []) assert_raises_rpc_error(-5, 'Invalid address or descriptor', self.generateblock, node, '1234', [])
self.log.info('Fail to generate block with a ranged descriptor') self.log.info('Fail to generate block with a ranged descriptor')
ranged_descriptor = 'pkh(tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp/0/*)' ranged_descriptor = 'pkh(tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp/0/*)'
assert_raises_rpc_error(-8, 'Ranged descriptor not accepted. Maybe pass through deriveaddresses first?', node.generateblock, ranged_descriptor, []) assert_raises_rpc_error(-8, 'Ranged descriptor not accepted. Maybe pass through deriveaddresses first?', self.generateblock, node, ranged_descriptor, [])
self.log.info('Fail to generate block with a descriptor missing a private key') self.log.info('Fail to generate block with a descriptor missing a private key')
child_descriptor = 'pkh(tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp/0\'/0)' child_descriptor = 'pkh(tpubD6NzVbkrYhZ4XgiXtGrdW5XDAPFCL9h7we1vwNCpn8tGbBcgfVYjXyhWo4E1xkh56hjod1RhGjxbaTLV3X4FyWuejifB9jusQ46QzG87VKp/0\'/0)'
assert_raises_rpc_error(-5, 'Cannot derive script without private keys', node.generateblock, child_descriptor, []) assert_raises_rpc_error(-5, 'Cannot derive script without private keys', self.generateblock, node, child_descriptor, [])
if __name__ == '__main__': if __name__ == '__main__':
GenerateBlockTest().main() GenerateBlockTest().main()

View file

@ -21,8 +21,8 @@ class GetBlockFilterTest(BitcoinTestFramework):
# Create two chains by disconnecting nodes 0 & 1, mining, then reconnecting # Create two chains by disconnecting nodes 0 & 1, mining, then reconnecting
self.disconnect_nodes(0, 1) self.disconnect_nodes(0, 1)
self.nodes[0].generate(3) self.generate(self.nodes[0], 3)
self.nodes[1].generate(4) self.generate(self.nodes[1], 4)
assert_equal(self.nodes[0].getblockcount(), 3) assert_equal(self.nodes[0].getblockcount(), 3)
chain0_hashes = [self.nodes[0].getblockhash(block_height) for block_height in range(4)] chain0_hashes = [self.nodes[0].getblockhash(block_height) for block_height in range(4)]

View file

@ -43,11 +43,11 @@ class GetblockstatsTest(BitcoinTestFramework):
def generate_test_data(self, filename): def generate_test_data(self, filename):
mocktime = 1525107225 mocktime = 1525107225
self.nodes[0].setmocktime(mocktime) self.nodes[0].setmocktime(mocktime)
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
address = self.nodes[0].get_deterministic_priv_key().address address = self.nodes[0].get_deterministic_priv_key().address
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
@ -55,7 +55,7 @@ class GetblockstatsTest(BitcoinTestFramework):
self.nodes[0].settxfee(amount=0.003) self.nodes[0].settxfee(amount=0.003)
self.nodes[0].sendtoaddress(address=address, amount=1, subtractfeefromamount=True) self.nodes[0].sendtoaddress(address=address, amount=1, subtractfeefromamount=True)
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.expected_stats = self.get_stats() self.expected_stats = self.get_stats()

View file

@ -26,8 +26,8 @@ class GetChainTipsTest (BitcoinTestFramework):
# Split the network and build two chains of different lengths. # Split the network and build two chains of different lengths.
self.split_network() self.split_network()
self.nodes[0].generatetoaddress(10, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 10, self.nodes[0].get_deterministic_priv_key().address)
self.nodes[2].generatetoaddress(20, self.nodes[2].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[2], 20, self.nodes[2].get_deterministic_priv_key().address)
self.sync_all(self.nodes[:2]) self.sync_all(self.nodes[:2])
self.sync_all(self.nodes[2:]) self.sync_all(self.nodes[2:])

View file

@ -22,12 +22,12 @@ class InvalidateTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:") self.log.info("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
self.log.info("Mine 4 blocks on Node 0") self.log.info("Mine 4 blocks on Node 0")
self.nodes[0].generatetoaddress(4, self.nodes[0].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[0], 4, self.nodes[0].get_deterministic_priv_key().address)
assert_equal(self.nodes[0].getblockcount(), 4) assert_equal(self.nodes[0].getblockcount(), 4)
besthash_n0 = self.nodes[0].getbestblockhash() besthash_n0 = self.nodes[0].getbestblockhash()
self.log.info("Mine competing 6 blocks on Node 1") self.log.info("Mine competing 6 blocks on Node 1")
self.nodes[1].generatetoaddress(6, self.nodes[1].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[1], 6, self.nodes[1].get_deterministic_priv_key().address)
assert_equal(self.nodes[1].getblockcount(), 6) assert_equal(self.nodes[1].getblockcount(), 6)
self.log.info("Connect nodes to force a reorg") self.log.info("Connect nodes to force a reorg")
@ -53,14 +53,14 @@ class InvalidateTest(BitcoinTestFramework):
self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3)) self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3))
assert_equal(self.nodes[2].getblockcount(), 2) assert_equal(self.nodes[2].getblockcount(), 2)
self.log.info("..and then mine a block") self.log.info("..and then mine a block")
self.nodes[2].generatetoaddress(1, self.nodes[2].get_deterministic_priv_key().address) self.generatetoaddress(self.nodes[2], 1, self.nodes[2].get_deterministic_priv_key().address)
self.log.info("Verify all nodes are at the right height") self.log.info("Verify all nodes are at the right height")
self.wait_until(lambda: self.nodes[2].getblockcount() == 3, timeout=5) self.wait_until(lambda: self.nodes[2].getblockcount() == 3, timeout=5)
self.wait_until(lambda: self.nodes[0].getblockcount() == 4, timeout=5) self.wait_until(lambda: self.nodes[0].getblockcount() == 4, timeout=5)
self.wait_until(lambda: self.nodes[1].getblockcount() == 4, timeout=5) self.wait_until(lambda: self.nodes[1].getblockcount() == 4, timeout=5)
self.log.info("Verify that we reconsider all ancestors as well") self.log.info("Verify that we reconsider all ancestors as well")
blocks = self.nodes[1].generatetodescriptor(10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR) blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR)
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
# Invalidate the two blocks at the tip # Invalidate the two blocks at the tip
self.nodes[1].invalidateblock(blocks[-1]) self.nodes[1].invalidateblock(blocks[-1])
@ -72,7 +72,7 @@ class InvalidateTest(BitcoinTestFramework):
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
self.log.info("Verify that we reconsider all descendants") self.log.info("Verify that we reconsider all descendants")
blocks = self.nodes[1].generatetodescriptor(10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR) blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR)
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1]) assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
# Invalidate the two blocks at the tip # Invalidate the two blocks at the tip
self.nodes[1].invalidateblock(blocks[-2]) self.nodes[1].invalidateblock(blocks[-2])

View file

@ -52,9 +52,9 @@ class NetTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# We need miniwallet to make a transaction # We need miniwallet to make a transaction
self.wallet = MiniWallet(self.nodes[0]) self.wallet = MiniWallet(self.nodes[0])
self.wallet.generate(1) self.generate(self.wallet, 1)
# Get out of IBD for the minfeefilter and getpeerinfo tests. # Get out of IBD for the minfeefilter and getpeerinfo tests.
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
# By default, the test framework sets up an addnode connection from # By default, the test framework sets up an addnode connection from
# node 1 --> node0. By connecting node0 --> node 1, we're left with # node 1 --> node0. By connecting node0 --> node 1, we're left with
@ -81,7 +81,7 @@ class NetTest(BitcoinTestFramework):
self.log.info("Test getpeerinfo") self.log.info("Test getpeerinfo")
# Create a few getpeerinfo last_block/last_transaction values. # Create a few getpeerinfo last_block/last_transaction values.
self.wallet.send_self_transfer(from_node=self.nodes[0]) # Make a transaction so we can see it in the getpeerinfo results self.wallet.send_self_transfer(from_node=self.nodes[0]) # Make a transaction so we can see it in the getpeerinfo results
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
time_now = int(time.time()) time_now = int(time.time())
peer_info = [x.getpeerinfo() for x in self.nodes] peer_info = [x.getpeerinfo() for x in self.nodes]

View file

@ -51,7 +51,7 @@ class RPCPackagesTest(BitcoinTestFramework):
self.address = node.get_deterministic_priv_key().address self.address = node.get_deterministic_priv_key().address
self.coins = [] self.coins = []
# The last 100 coinbase transactions are premature # The last 100 coinbase transactions are premature
for b in node.generatetoaddress(200, self.address)[:100]: for b in self.generatetoaddress(node, 200, self.address)[:100]:
coinbase = node.getblock(blockhash=b, verbosity=2)["tx"][0] coinbase = node.getblock(blockhash=b, verbosity=2)["tx"][0]
self.coins.append({ self.coins.append({
"txid": coinbase["txid"], "txid": coinbase["txid"],
@ -151,7 +151,7 @@ class RPCPackagesTest(BitcoinTestFramework):
assert_equal(testres_single, testres_multiple) assert_equal(testres_single, testres_multiple)
# Clean up by clearing the mempool # Clean up by clearing the mempool
node.generate(1) self.generate(node, 1)
def test_multiple_children(self): def test_multiple_children(self):
node = self.nodes[0] node = self.nodes[0]

View file

@ -43,18 +43,18 @@ class PreciousTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Ensure submitblock can in principle reorg to a competing chain") self.log.info("Ensure submitblock can in principle reorg to a competing chain")
gen_address = lambda i: self.nodes[i].get_deterministic_priv_key().address # A non-wallet address to mine to gen_address = lambda i: self.nodes[i].get_deterministic_priv_key().address # A non-wallet address to mine to
self.nodes[0].generatetoaddress(1, gen_address(0)) self.generatetoaddress(self.nodes[0], 1, gen_address(0))
assert_equal(self.nodes[0].getblockcount(), 1) assert_equal(self.nodes[0].getblockcount(), 1)
hashZ = self.nodes[1].generatetoaddress(2, gen_address(1))[-1] hashZ = self.generatetoaddress(self.nodes[1], 2, gen_address(1))[-1]
assert_equal(self.nodes[1].getblockcount(), 2) assert_equal(self.nodes[1].getblockcount(), 2)
node_sync_via_rpc(self.nodes[0:3]) node_sync_via_rpc(self.nodes[0:3])
assert_equal(self.nodes[0].getbestblockhash(), hashZ) assert_equal(self.nodes[0].getbestblockhash(), hashZ)
self.log.info("Mine blocks A-B-C on Node 0") self.log.info("Mine blocks A-B-C on Node 0")
hashC = self.nodes[0].generatetoaddress(3, gen_address(0))[-1] hashC = self.generatetoaddress(self.nodes[0], 3, gen_address(0))[-1]
assert_equal(self.nodes[0].getblockcount(), 5) assert_equal(self.nodes[0].getblockcount(), 5)
self.log.info("Mine competing blocks E-F-G on Node 1") self.log.info("Mine competing blocks E-F-G on Node 1")
hashG = self.nodes[1].generatetoaddress(3, gen_address(1))[-1] hashG = self.generatetoaddress(self.nodes[1], 3, gen_address(1))[-1]
assert_equal(self.nodes[1].getblockcount(), 5) assert_equal(self.nodes[1].getblockcount(), 5)
assert hashC != hashG assert hashC != hashG
self.log.info("Connect nodes and check no reorg occurs") self.log.info("Connect nodes and check no reorg occurs")
@ -83,7 +83,7 @@ class PreciousTest(BitcoinTestFramework):
self.nodes[1].preciousblock(hashC) self.nodes[1].preciousblock(hashC)
assert_equal(self.nodes[1].getbestblockhash(), hashC) assert_equal(self.nodes[1].getbestblockhash(), hashC)
self.log.info("Mine another block (E-F-G-)H on Node 0 and reorg Node 1") self.log.info("Mine another block (E-F-G-)H on Node 0 and reorg Node 1")
self.nodes[0].generatetoaddress(1, gen_address(0)) self.generatetoaddress(self.nodes[0], 1, gen_address(0))
assert_equal(self.nodes[0].getblockcount(), 6) assert_equal(self.nodes[0].getblockcount(), 6)
self.sync_blocks(self.nodes[0:2]) self.sync_blocks(self.nodes[0:2])
hashH = self.nodes[0].getbestblockhash() hashH = self.nodes[0].getbestblockhash()
@ -92,7 +92,7 @@ class PreciousTest(BitcoinTestFramework):
self.nodes[1].preciousblock(hashC) self.nodes[1].preciousblock(hashC)
assert_equal(self.nodes[1].getbestblockhash(), hashH) assert_equal(self.nodes[1].getbestblockhash(), hashH)
self.log.info("Mine competing blocks I-J-K-L on Node 2") self.log.info("Mine competing blocks I-J-K-L on Node 2")
self.nodes[2].generatetoaddress(4, gen_address(2)) self.generatetoaddress(self.nodes[2], 4, gen_address(2))
assert_equal(self.nodes[2].getblockcount(), 6) assert_equal(self.nodes[2].getblockcount(), 6)
hashL = self.nodes[2].getbestblockhash() hashL = self.nodes[2].getbestblockhash()
self.log.info("Connect nodes and check no reorg occurs") self.log.info("Connect nodes and check no reorg occurs")

View file

@ -57,7 +57,7 @@ class PSBTTest(BitcoinTestFramework):
online_addr = w2.getnewaddress(address_type="p2sh-segwit") online_addr = w2.getnewaddress(address_type="p2sh-segwit")
wonline.importaddress(offline_addr, "", False) wonline.importaddress(offline_addr, "", False)
mining_node.sendtoaddress(address=offline_addr, amount=1.0) mining_node.sendtoaddress(address=offline_addr, amount=1.0)
mining_node.generate(nblocks=1) self.generate(mining_node, nblocks=1)
self.sync_blocks([mining_node, online_node]) self.sync_blocks([mining_node, online_node])
# Construct an unsigned PSBT on the online node (who doesn't know the output is Segwit, so will include a non-witness UTXO) # Construct an unsigned PSBT on the online node (who doesn't know the output is Segwit, so will include a non-witness UTXO)
@ -72,7 +72,7 @@ class PSBTTest(BitcoinTestFramework):
# Make sure we can mine the resulting transaction # Make sure we can mine the resulting transaction
txid = mining_node.sendrawtransaction(mining_node.finalizepsbt(signed_psbt)["hex"]) txid = mining_node.sendrawtransaction(mining_node.finalizepsbt(signed_psbt)["hex"])
mining_node.generate(1) self.generate(mining_node, 1)
self.sync_blocks([mining_node, online_node]) self.sync_blocks([mining_node, online_node])
assert_equal(online_node.gettxout(txid,0)["confirmations"], 1) assert_equal(online_node.gettxout(txid,0)["confirmations"], 1)
@ -148,7 +148,7 @@ class PSBTTest(BitcoinTestFramework):
rawtx = self.nodes[0].fundrawtransaction(rawtx, {"changePosition":3}) rawtx = self.nodes[0].fundrawtransaction(rawtx, {"changePosition":3})
signed_tx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])['hex'] signed_tx = self.nodes[0].signrawtransactionwithwallet(rawtx['hex'])['hex']
txid = self.nodes[0].sendrawtransaction(signed_tx) txid = self.nodes[0].sendrawtransaction(signed_tx)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
# Find the output pos # Find the output pos
@ -307,7 +307,7 @@ class PSBTTest(BitcoinTestFramework):
node2_addr = self.nodes[2].getnewaddress() node2_addr = self.nodes[2].getnewaddress()
txid1 = self.nodes[0].sendtoaddress(node1_addr, 13) txid1 = self.nodes[0].sendtoaddress(node1_addr, 13)
txid2 = self.nodes[0].sendtoaddress(node2_addr, 13) txid2 = self.nodes[0].sendtoaddress(node2_addr, 13)
blockhash = self.nodes[0].generate(6)[0] blockhash = self.generate(self.nodes[0], 6)[0]
self.sync_all() self.sync_all()
vout1 = find_output(self.nodes[1], txid1, 13, blockhash=blockhash) vout1 = find_output(self.nodes[1], txid1, 13, blockhash=blockhash)
vout2 = find_output(self.nodes[2], txid2, 13, blockhash=blockhash) vout2 = find_output(self.nodes[2], txid2, 13, blockhash=blockhash)
@ -335,7 +335,7 @@ class PSBTTest(BitcoinTestFramework):
combined = self.nodes[0].combinepsbt([psbt1, psbt2]) combined = self.nodes[0].combinepsbt([psbt1, psbt2])
finalized = self.nodes[0].finalizepsbt(combined)['hex'] finalized = self.nodes[0].finalizepsbt(combined)['hex']
self.nodes[0].sendrawtransaction(finalized) self.nodes[0].sendrawtransaction(finalized)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
# Test additional args in walletcreatepsbt # Test additional args in walletcreatepsbt
@ -530,7 +530,7 @@ class PSBTTest(BitcoinTestFramework):
addr4 = self.nodes[1].getnewaddress("", "p2sh-segwit") addr4 = self.nodes[1].getnewaddress("", "p2sh-segwit")
txid4 = self.nodes[0].sendtoaddress(addr4, 5) txid4 = self.nodes[0].sendtoaddress(addr4, 5)
vout4 = find_output(self.nodes[0], txid4, 5) vout4 = find_output(self.nodes[0], txid4, 5)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
psbt2 = self.nodes[1].createpsbt([{"txid":txid4, "vout":vout4}], {self.nodes[0].getnewaddress():Decimal('4.999')}) psbt2 = self.nodes[1].createpsbt([{"txid":txid4, "vout":vout4}], {self.nodes[0].getnewaddress():Decimal('4.999')})
psbt2 = self.nodes[1].walletprocesspsbt(psbt2)['psbt'] psbt2 = self.nodes[1].walletprocesspsbt(psbt2)['psbt']
@ -554,7 +554,7 @@ class PSBTTest(BitcoinTestFramework):
addr = self.nodes[1].getnewaddress("", "p2sh-segwit") addr = self.nodes[1].getnewaddress("", "p2sh-segwit")
txid = self.nodes[0].sendtoaddress(addr, 7) txid = self.nodes[0].sendtoaddress(addr, 7)
addrinfo = self.nodes[1].getaddressinfo(addr) addrinfo = self.nodes[1].getaddressinfo(addr)
blockhash = self.nodes[0].generate(6)[0] blockhash = self.generate(self.nodes[0], 6)[0]
self.sync_all() self.sync_all()
vout = find_output(self.nodes[0], txid, 7, blockhash=blockhash) vout = find_output(self.nodes[0], txid, 7, blockhash=blockhash)
psbt = self.nodes[1].createpsbt([{"txid":txid, "vout":vout}], {self.nodes[0].getnewaddress("", "p2sh-segwit"):Decimal('6.999')}) psbt = self.nodes[1].createpsbt([{"txid":txid, "vout":vout}], {self.nodes[0].getnewaddress("", "p2sh-segwit"):Decimal('6.999')})

View file

@ -74,14 +74,14 @@ class RawTransactionsTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Prepare some coins for multiple *rawtransaction commands") self.log.info("Prepare some coins for multiple *rawtransaction commands")
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all() self.sync_all()
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
self.sync_all() self.sync_all()
for amount in [1.5, 1.0, 5.0]: for amount in [1.5, 1.0, 5.0]:
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), amount) self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), amount)
self.sync_all() self.sync_all()
self.nodes[0].generate(5) self.generate(self.nodes[0], 5)
self.sync_all() self.sync_all()
self.getrawtransaction_tests() self.getrawtransaction_tests()
@ -97,13 +97,13 @@ class RawTransactionsTest(BitcoinTestFramework):
def getrawtransaction_tests(self): def getrawtransaction_tests(self):
addr = self.nodes[1].getnewaddress() addr = self.nodes[1].getnewaddress()
txid = self.nodes[0].sendtoaddress(addr, 10) txid = self.nodes[0].sendtoaddress(addr, 10)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
vout = find_vout_for_address(self.nodes[1], txid, addr) vout = find_vout_for_address(self.nodes[1], txid, addr)
rawTx = self.nodes[1].createrawtransaction([{'txid': txid, 'vout': vout}], {self.nodes[1].getnewaddress(): 9.999}) rawTx = self.nodes[1].createrawtransaction([{'txid': txid, 'vout': vout}], {self.nodes[1].getnewaddress(): 9.999})
rawTxSigned = self.nodes[1].signrawtransactionwithwallet(rawTx) rawTxSigned = self.nodes[1].signrawtransactionwithwallet(rawTx)
txId = self.nodes[1].sendrawtransaction(rawTxSigned['hex']) txId = self.nodes[1].sendrawtransaction(rawTxSigned['hex'])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
for n in [0, 3]: for n in [0, 3]:
@ -136,7 +136,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# Make a tx by sending, then generate 2 blocks; block1 has the tx in it # Make a tx by sending, then generate 2 blocks; block1 has the tx in it
tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1) tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1)
block1, block2 = self.nodes[2].generate(2) block1, block2 = self.generate(self.nodes[2], 2)
self.sync_all() self.sync_all()
for n in [0, 3]: for n in [0, 3]:
self.log.info(f"Test getrawtransaction {'with' if n == 0 else 'without'} -txindex, with blockhash") self.log.info(f"Test getrawtransaction {'with' if n == 0 else 'without'} -txindex, with blockhash")
@ -368,7 +368,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.20000000') self.nodes[2].sendrawtransaction(hexstring=rawTxSigned['hex'], maxfeerate='0.20000000')
self.log.info("Test sendrawtransaction/testmempoolaccept with tx already in the chain") self.log.info("Test sendrawtransaction/testmempoolaccept with tx already in the chain")
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_blocks() self.sync_blocks()
for node in self.nodes: for node in self.nodes:
testres = node.testmempoolaccept([rawTxSigned['hex']])[0] testres = node.testmempoolaccept([rawTxSigned['hex']])[0]
@ -442,7 +442,7 @@ class RawTransactionsTest(BitcoinTestFramework):
# send 1.2 BTC to msig adr # send 1.2 BTC to msig adr
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2) txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# node2 has both keys of the 2of2 ms addr, tx should affect the balance # node2 has both keys of the 2of2 ms addr, tx should affect the balance
assert_equal(self.nodes[2].getbalance(), bal + Decimal('1.20000000')) assert_equal(self.nodes[2].getbalance(), bal + Decimal('1.20000000'))
@ -464,7 +464,7 @@ class RawTransactionsTest(BitcoinTestFramework):
decTx = self.nodes[0].gettransaction(txId) decTx = self.nodes[0].gettransaction(txId)
rawTx = self.nodes[0].decoderawtransaction(decTx['hex']) rawTx = self.nodes[0].decoderawtransaction(decTx['hex'])
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# THIS IS AN INCOMPLETE FEATURE # THIS IS AN INCOMPLETE FEATURE
@ -487,7 +487,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[2].sendrawtransaction(rawTxSigned['hex']) self.nodes[2].sendrawtransaction(rawTxSigned['hex'])
rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex']) rawTx = self.nodes[0].decoderawtransaction(rawTxSigned['hex'])
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx assert_equal(self.nodes[0].getbalance(), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx
@ -507,7 +507,7 @@ class RawTransactionsTest(BitcoinTestFramework):
decTx = self.nodes[0].gettransaction(txId) decTx = self.nodes[0].gettransaction(txId)
rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex']) rawTx2 = self.nodes[0].decoderawtransaction(decTx['hex'])
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
assert_equal(self.nodes[2].getbalance(), bal) # the funds of a 2of2 multisig tx should not be marked as spendable assert_equal(self.nodes[2].getbalance(), bal) # the funds of a 2of2 multisig tx should not be marked as spendable
@ -532,7 +532,7 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[2].sendrawtransaction(rawTxComb) self.nodes[2].sendrawtransaction(rawTxComb)
rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb)
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx assert_equal(self.nodes[0].getbalance(), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx

View file

@ -23,7 +23,7 @@ class ScantxoutsetTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Mining blocks...") self.log.info("Mining blocks...")
self.nodes[0].generate(110) self.generate(self.nodes[0], 110)
addr_P2SH_SEGWIT = self.nodes[0].getnewaddress("", "p2sh-segwit") addr_P2SH_SEGWIT = self.nodes[0].getnewaddress("", "p2sh-segwit")
pubk1 = self.nodes[0].getaddressinfo(addr_P2SH_SEGWIT)['pubkey'] pubk1 = self.nodes[0].getaddressinfo(addr_P2SH_SEGWIT)['pubkey']
@ -50,14 +50,14 @@ class ScantxoutsetTest(BitcoinTestFramework):
self.nodes[0].sendtoaddress("mpQ8rokAhp1TAtJQR6F6TaUmjAWkAWYYBq", 16.384) # (m/1/1/1500) self.nodes[0].sendtoaddress("mpQ8rokAhp1TAtJQR6F6TaUmjAWkAWYYBq", 16.384) # (m/1/1/1500)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.log.info("Stop node, remove wallet, mine again some blocks...") self.log.info("Stop node, remove wallet, mine again some blocks...")
self.stop_node(0) self.stop_node(0)
shutil.rmtree(os.path.join(self.nodes[0].datadir, self.chain, 'wallets')) shutil.rmtree(os.path.join(self.nodes[0].datadir, self.chain, 'wallets'))
self.start_node(0, ['-nowallet']) self.start_node(0, ['-nowallet'])
self.import_deterministic_coinbase_privkeys() self.import_deterministic_coinbase_privkeys()
self.nodes[0].generate(110) self.generate(self.nodes[0], 110)
scan = self.nodes[0].scantxoutset("start", []) scan = self.nodes[0].scantxoutset("start", [])
info = self.nodes[0].gettxoutsetinfo() info = self.nodes[0].gettxoutsetinfo()

View file

@ -183,7 +183,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
def test_fully_signed_tx(self): def test_fully_signed_tx(self):
self.log.info("Test signing a fully signed transaction does nothing") self.log.info("Test signing a fully signed transaction does nothing")
self.nodes[0].walletpassphrase("password", 9999) self.nodes[0].walletpassphrase("password", 9999)
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
rawtx = self.nodes[0].createrawtransaction([], [{self.nodes[0].getnewaddress(): 10}]) rawtx = self.nodes[0].createrawtransaction([], [{self.nodes[0].getnewaddress(): 10}])
fundedtx = self.nodes[0].fundrawtransaction(rawtx) fundedtx = self.nodes[0].fundrawtransaction(rawtx)
signedtx = self.nodes[0].signrawtransactionwithwallet(fundedtx["hex"]) signedtx = self.nodes[0].signrawtransactionwithwallet(fundedtx["hex"])
@ -202,9 +202,9 @@ class SignRawTransactionsTest(BitcoinTestFramework):
embedded_pubkey = eckey.get_pubkey().get_bytes().hex() embedded_pubkey = eckey.get_pubkey().get_bytes().hex()
p2sh_p2wsh_address = self.nodes[1].createmultisig(1, [embedded_pubkey], "p2sh-segwit") p2sh_p2wsh_address = self.nodes[1].createmultisig(1, [embedded_pubkey], "p2sh-segwit")
# send transaction to P2SH-P2WSH 1-of-1 multisig address # send transaction to P2SH-P2WSH 1-of-1 multisig address
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
self.nodes[0].sendtoaddress(p2sh_p2wsh_address["address"], 49.999) self.nodes[0].sendtoaddress(p2sh_p2wsh_address["address"], 49.999)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Get the UTXO info from scantxoutset # Get the UTXO info from scantxoutset
unspent_output = self.nodes[1].scantxoutset('start', [p2sh_p2wsh_address['descriptor']])['unspents'][0] unspent_output = self.nodes[1].scantxoutset('start', [p2sh_p2wsh_address['descriptor']])['unspents'][0]
@ -239,7 +239,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
# Fund that address # Fund that address
txid = self.nodes[0].sendtoaddress(addr, 10) txid = self.nodes[0].sendtoaddress(addr, 10)
vout = find_vout_for_address(self.nodes[0], txid, addr) vout = find_vout_for_address(self.nodes[0], txid, addr)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Now create and sign a transaction spending that output on node[0], which doesn't know the scripts or keys # Now create and sign a transaction spending that output on node[0], which doesn't know the scripts or keys
spending_tx = self.nodes[0].createrawtransaction([{'txid': txid, 'vout': vout}], {self.nodes[1].getnewaddress(): Decimal("9.999")}) spending_tx = self.nodes[0].createrawtransaction([{'txid': txid, 'vout': vout}], {self.nodes[1].getnewaddress(): Decimal("9.999")})
spending_tx_signed = self.nodes[0].signrawtransactionwithkey(spending_tx, [embedded_privkey], [{'txid': txid, 'vout': vout, 'scriptPubKey': script_pub_key, 'redeemScript': redeem_script, 'witnessScript': witness_script, 'amount': 10}]) spending_tx_signed = self.nodes[0].signrawtransactionwithkey(spending_tx, [embedded_privkey], [{'txid': txid, 'vout': vout, 'scriptPubKey': script_pub_key, 'redeemScript': redeem_script, 'witnessScript': witness_script, 'amount': 10}])
@ -283,7 +283,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
# Fund that address and make the spend # Fund that address and make the spend
txid = self.nodes[0].sendtoaddress(address, 1) txid = self.nodes[0].sendtoaddress(address, 1)
vout = find_vout_for_address(self.nodes[0], txid, address) vout = find_vout_for_address(self.nodes[0], txid, address)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
utxo = self.nodes[0].listunspent()[0] utxo = self.nodes[0].listunspent()[0]
amt = Decimal(1) + utxo["amount"] - Decimal(0.00001) amt = Decimal(1) + utxo["amount"] - Decimal(0.00001)
tx = self.nodes[0].createrawtransaction( tx = self.nodes[0].createrawtransaction(
@ -318,7 +318,7 @@ class SignRawTransactionsTest(BitcoinTestFramework):
# Fund that address and make the spend # Fund that address and make the spend
txid = self.nodes[0].sendtoaddress(address, 1) txid = self.nodes[0].sendtoaddress(address, 1)
vout = find_vout_for_address(self.nodes[0], txid, address) vout = find_vout_for_address(self.nodes[0], txid, address)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
utxo = self.nodes[0].listunspent()[0] utxo = self.nodes[0].listunspent()[0]
amt = Decimal(1) + utxo["amount"] - Decimal(0.00001) amt = Decimal(1) + utxo["amount"] - Decimal(0.00001)
tx = self.nodes[0].createrawtransaction( tx = self.nodes[0].createrawtransaction(

View file

@ -29,8 +29,8 @@ class MerkleBlockTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
miniwallet = MiniWallet(self.nodes[0]) miniwallet = MiniWallet(self.nodes[0])
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins # Add enough mature utxos to the wallet, so that all txs spend confirmed coins
miniwallet.generate(5) self.generate(miniwallet, 5)
self.nodes[0].generate(COINBASE_MATURITY) self.generate(self.nodes[0], COINBASE_MATURITY)
self.sync_all() self.sync_all()
chain_height = self.nodes[1].getblockcount() chain_height = self.nodes[1].getblockcount()
@ -41,7 +41,7 @@ class MerkleBlockTest(BitcoinTestFramework):
# This will raise an exception because the transaction is not yet in a block # This will raise an exception because the transaction is not yet in a block
assert_raises_rpc_error(-5, "Transaction not yet in block", self.nodes[0].gettxoutproof, [txid1]) assert_raises_rpc_error(-5, "Transaction not yet in block", self.nodes[0].gettxoutproof, [txid1])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
blockhash = self.nodes[0].getblockhash(chain_height + 1) blockhash = self.nodes[0].getblockhash(chain_height + 1)
self.sync_all() self.sync_all()
@ -57,7 +57,7 @@ class MerkleBlockTest(BitcoinTestFramework):
txin_spent = miniwallet.get_utxo() # Get the change from txid2 txin_spent = miniwallet.get_utxo() # Get the change from txid2
tx3 = miniwallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=txin_spent) tx3 = miniwallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=txin_spent)
txid3 = tx3['txid'] txid3 = tx3['txid']
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
txid_spent = txin_spent["txid"] txid_spent = txin_spent["txid"]

View file

@ -94,7 +94,7 @@ rewards to a wallet address owned by the mining node.
``` ```
>>> address = test.nodes[0].getnewaddress() >>> address = test.nodes[0].getnewaddress()
>>> test.nodes[0].generatetoaddress(101, address) >>> test.self.generatetoaddress(nodes[0], 101, address)
['2b98dd0044aae6f1cca7f88a0acf366a4bfe053c7f7b00da3c0d115f03d67efb', ... ['2b98dd0044aae6f1cca7f88a0acf366a4bfe053c7f7b00da3c0d115f03d67efb', ...
``` ```
Since the two nodes are both initialized by default to establish an outbound Since the two nodes are both initialized by default to establish an outbound

View file

@ -242,7 +242,7 @@ class ToolWalletTest(BitcoinTestFramework):
""" """
self.start_node(0) self.start_node(0)
self.log.info('Generating transaction to mutate wallet') self.log.info('Generating transaction to mutate wallet')
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.stop_node(0) self.stop_node(0)
self.log.info('Calling wallet tool info after generating a transaction, testing output') self.log.info('Calling wallet tool info after generating a transaction, testing output')

View file

@ -29,14 +29,14 @@ class AbandonConflictTest(BitcoinTestFramework):
self.skip_if_no_wallet() self.skip_if_no_wallet()
def run_test(self): def run_test(self):
self.nodes[1].generate(COINBASE_MATURITY) self.generate(self.nodes[1], COINBASE_MATURITY)
self.sync_blocks() self.sync_blocks()
balance = self.nodes[0].getbalance() balance = self.nodes[0].getbalance()
txA = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10")) txA = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
txB = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10")) txB = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
txC = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10")) txC = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
self.sync_mempools() self.sync_mempools()
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
# Can not abandon non-wallet transaction # Can not abandon non-wallet transaction
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', lambda: self.nodes[0].abandontransaction(txid='ff' * 32)) assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', lambda: self.nodes[0].abandontransaction(txid='ff' * 32))
@ -158,7 +158,7 @@ class AbandonConflictTest(BitcoinTestFramework):
tx = self.nodes[0].createrawtransaction(inputs, outputs) tx = self.nodes[0].createrawtransaction(inputs, outputs)
signed = self.nodes[0].signrawtransactionwithwallet(tx) signed = self.nodes[0].signrawtransactionwithwallet(tx)
self.nodes[1].sendrawtransaction(signed["hex"]) self.nodes[1].sendrawtransaction(signed["hex"])
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
self.sync_blocks() self.sync_blocks()

View file

@ -221,7 +221,7 @@ class AddressTypeTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Mine 101 blocks on node5 to bring nodes out of IBD and make sure that # Mine 101 blocks on node5 to bring nodes out of IBD and make sure that
# no coinbases are maturing for the nodes-under-test during the test # no coinbases are maturing for the nodes-under-test during the test
self.nodes[5].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[5], COINBASE_MATURITY + 1)
self.sync_blocks() self.sync_blocks()
uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee" uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee"
@ -306,7 +306,7 @@ class AddressTypeTest(BitcoinTestFramework):
assert_equal(unconf_balances[to_node], to_send * 10 * (2 + n)) assert_equal(unconf_balances[to_node], to_send * 10 * (2 + n))
# node5 collects fee and block subsidy to keep accounting simple # node5 collects fee and block subsidy to keep accounting simple
self.nodes[5].generate(1) self.generate(self.nodes[5], 1)
self.sync_blocks() self.sync_blocks()
# Verify that the receiving wallet contains a UTXO with the expected address, and expected descriptor # Verify that the receiving wallet contains a UTXO with the expected address, and expected descriptor
@ -336,7 +336,7 @@ class AddressTypeTest(BitcoinTestFramework):
# Fund node 4: # Fund node 4:
self.nodes[5].sendtoaddress(self.nodes[4].getnewaddress(), Decimal("1")) self.nodes[5].sendtoaddress(self.nodes[4].getnewaddress(), Decimal("1"))
self.nodes[5].generate(1) self.generate(self.nodes[5], 1)
self.sync_blocks() self.sync_blocks()
assert_equal(self.nodes[4].getbalance(), 1) assert_equal(self.nodes[4].getbalance(), 1)

View file

@ -79,7 +79,7 @@ class AvoidReuseTest(BitcoinTestFramework):
self.test_persistence() self.test_persistence()
self.test_immutable() self.test_immutable()
self.nodes[0].generate(110) self.generate(self.nodes[0], 110)
self.sync_all() self.sync_all()
self.test_change_remains_change(self.nodes[1]) self.test_change_remains_change(self.nodes[1])
reset_balance(self.nodes[1], self.nodes[0].getnewaddress()) reset_balance(self.nodes[1], self.nodes[0].getnewaddress())
@ -174,7 +174,7 @@ class AvoidReuseTest(BitcoinTestFramework):
retaddr = self.nodes[0].getnewaddress() retaddr = self.nodes[0].getnewaddress()
self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].sendtoaddress(fundaddr, 10)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# listunspent should show 1 single, unused 10 btc output # listunspent should show 1 single, unused 10 btc output
@ -185,7 +185,7 @@ class AvoidReuseTest(BitcoinTestFramework):
assert("used" not in self.nodes[0].getbalances()["mine"]) assert("used" not in self.nodes[0].getbalances()["mine"])
self.nodes[1].sendtoaddress(retaddr, 5) self.nodes[1].sendtoaddress(retaddr, 5)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# listunspent should show 1 single, unused 5 btc output # listunspent should show 1 single, unused 5 btc output
@ -194,7 +194,7 @@ class AvoidReuseTest(BitcoinTestFramework):
assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5}) assert_balances(self.nodes[1], mine={"used": 0, "trusted": 5})
self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].sendtoaddress(fundaddr, 10)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10) # listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10)
@ -228,7 +228,7 @@ class AvoidReuseTest(BitcoinTestFramework):
retaddr = self.nodes[0].getnewaddress() retaddr = self.nodes[0].getnewaddress()
self.nodes[0].sendtoaddress(fundaddr, 10) self.nodes[0].sendtoaddress(fundaddr, 10)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# listunspent should show 1 single, unused 10 btc output # listunspent should show 1 single, unused 10 btc output
@ -237,7 +237,7 @@ class AvoidReuseTest(BitcoinTestFramework):
assert_balances(self.nodes[1], mine={"used": 0, "trusted": 10}) assert_balances(self.nodes[1], mine={"used": 0, "trusted": 10})
self.nodes[1].sendtoaddress(retaddr, 5) self.nodes[1].sendtoaddress(retaddr, 5)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# listunspent should show 1 single, unused 5 btc output # listunspent should show 1 single, unused 5 btc output
@ -259,7 +259,7 @@ class AvoidReuseTest(BitcoinTestFramework):
assert_equal(second_addr_type, "legacy") assert_equal(second_addr_type, "legacy")
self.nodes[0].sendtoaddress(new_fundaddr, 10) self.nodes[0].sendtoaddress(new_fundaddr, 10)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10) # listunspent should show 2 total outputs (5, 10 btc), one unused (5), one reused (10)
@ -302,7 +302,7 @@ class AvoidReuseTest(BitcoinTestFramework):
for _ in range(101): for _ in range(101):
self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].sendtoaddress(new_addr, 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# send transaction that should not use all the available outputs # send transaction that should not use all the available outputs
@ -334,7 +334,7 @@ class AvoidReuseTest(BitcoinTestFramework):
for _ in range(101): for _ in range(101):
self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].sendtoaddress(new_addr, 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Sending a transaction that is smaller than each one of the # Sending a transaction that is smaller than each one of the
@ -363,7 +363,7 @@ class AvoidReuseTest(BitcoinTestFramework):
for _ in range(202): for _ in range(202):
self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].sendtoaddress(new_addr, 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Sending a transaction that needs to use the full groups # Sending a transaction that needs to use the full groups

View file

@ -88,7 +88,7 @@ class WalletBackupTest(BitcoinTestFramework):
# Have the miner (node3) mine a block. # Have the miner (node3) mine a block.
# Must sync mempools before mining. # Must sync mempools before mining.
self.sync_mempools() self.sync_mempools()
self.nodes[3].generate(1) self.generate(self.nodes[3], 1)
self.sync_blocks() self.sync_blocks()
# As above, this mirrors the original bash test. # As above, this mirrors the original bash test.
@ -130,13 +130,13 @@ class WalletBackupTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Generating initial blockchain") self.log.info("Generating initial blockchain")
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_blocks() self.sync_blocks()
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_blocks() self.sync_blocks()
self.nodes[3].generate(COINBASE_MATURITY) self.generate(self.nodes[3], COINBASE_MATURITY)
self.sync_blocks() self.sync_blocks()
assert_equal(self.nodes[0].getbalance(), 50) assert_equal(self.nodes[0].getbalance(), 50)
@ -165,7 +165,7 @@ class WalletBackupTest(BitcoinTestFramework):
self.do_one_round() self.do_one_round()
# Generate 101 more blocks, so any fees paid mature # Generate 101 more blocks, so any fees paid mature
self.nodes[3].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[3], COINBASE_MATURITY + 1)
self.sync_all() self.sync_all()
balance0 = self.nodes[0].getbalance() balance0 = self.nodes[0].getbalance()

View file

@ -70,10 +70,10 @@ class WalletTest(BitcoinTestFramework):
assert 'watchonly' not in self.nodes[1].getbalances() assert 'watchonly' not in self.nodes[1].getbalances()
self.log.info("Mining blocks ...") self.log.info("Mining blocks ...")
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.nodes[1].generatetoaddress(COINBASE_MATURITY + 1, ADDRESS_WATCHONLY) self.generatetoaddress(self.nodes[1], COINBASE_MATURITY + 1, ADDRESS_WATCHONLY)
self.sync_all() self.sync_all()
if not self.options.descriptors: if not self.options.descriptors:
@ -196,7 +196,7 @@ class WalletTest(BitcoinTestFramework):
self.log.info("Test getbalance and getbalances.mine.untrusted_pending with conflicted unconfirmed inputs") self.log.info("Test getbalance and getbalances.mine.untrusted_pending with conflicted unconfirmed inputs")
test_balances(fee_node_1=Decimal('0.02')) test_balances(fee_node_1=Decimal('0.02'))
self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY) self.generatetoaddress(self.nodes[1], 1, ADDRESS_WATCHONLY)
self.sync_all() self.sync_all()
# balances are correct after the transactions are confirmed # balances are correct after the transactions are confirmed
@ -210,7 +210,7 @@ class WalletTest(BitcoinTestFramework):
# Send total balance away from node 1 # Send total balance away from node 1
txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), Decimal('29.97'), [Decimal('0.01')]) txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), Decimal('29.97'), [Decimal('0.01')])
self.nodes[1].sendrawtransaction(txs[0]['hex']) self.nodes[1].sendrawtransaction(txs[0]['hex'])
self.nodes[1].generatetoaddress(2, ADDRESS_WATCHONLY) self.generatetoaddress(self.nodes[1], 2, ADDRESS_WATCHONLY)
self.sync_all() self.sync_all()
# getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago # getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
@ -257,7 +257,7 @@ class WalletTest(BitcoinTestFramework):
self.nodes[1].sendrawtransaction(hexstring=tx_replace, maxfeerate=0) self.nodes[1].sendrawtransaction(hexstring=tx_replace, maxfeerate=0)
# Now confirm tx_replace # Now confirm tx_replace
block_reorg = self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY)[0] block_reorg = self.generatetoaddress(self.nodes[1], 1, ADDRESS_WATCHONLY)[0]
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(minconf=0), total_amount) assert_equal(self.nodes[0].getbalance(minconf=0), total_amount)
@ -265,7 +265,7 @@ class WalletTest(BitcoinTestFramework):
self.nodes[0].invalidateblock(block_reorg) self.nodes[0].invalidateblock(block_reorg)
self.nodes[1].invalidateblock(block_reorg) self.nodes[1].invalidateblock(block_reorg)
assert_equal(self.nodes[0].getbalance(minconf=0), 0) # wallet txs not in the mempool are untrusted assert_equal(self.nodes[0].getbalance(minconf=0), 0) # wallet txs not in the mempool are untrusted
self.nodes[0].generatetoaddress(1, ADDRESS_WATCHONLY) self.generatetoaddress(self.nodes[0], 1, ADDRESS_WATCHONLY)
assert_equal(self.nodes[0].getbalance(minconf=0), 0) # wallet txs not in the mempool are untrusted assert_equal(self.nodes[0].getbalance(minconf=0), 0) # wallet txs not in the mempool are untrusted
# Now confirm tx_orig # Now confirm tx_orig
@ -273,7 +273,7 @@ class WalletTest(BitcoinTestFramework):
self.connect_nodes(0, 1) self.connect_nodes(0, 1)
self.sync_blocks() self.sync_blocks()
self.nodes[1].sendrawtransaction(tx_orig) self.nodes[1].sendrawtransaction(tx_orig)
self.nodes[1].generatetoaddress(1, ADDRESS_WATCHONLY) self.generatetoaddress(self.nodes[1], 1, ADDRESS_WATCHONLY)
self.sync_all() self.sync_all()
assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) # The reorg recovered our fee of 1 coin assert_equal(self.nodes[0].getbalance(minconf=0), total_amount + 1) # The reorg recovered our fee of 1 coin

View file

@ -59,14 +59,14 @@ class WalletTest(BitcoinTestFramework):
self.log.info("Mining blocks...") self.log.info("Mining blocks...")
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
walletinfo = self.nodes[0].getwalletinfo() walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['immature_balance'], 50) assert_equal(walletinfo['immature_balance'], 50)
assert_equal(walletinfo['balance'], 0) assert_equal(walletinfo['balance'], 0)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
self.nodes[1].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[1], COINBASE_MATURITY + 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
assert_equal(self.nodes[0].getbalance(), 50) assert_equal(self.nodes[0].getbalance(), 50)
@ -115,7 +115,7 @@ class WalletTest(BitcoinTestFramework):
assert_equal(walletinfo['immature_balance'], 0) assert_equal(walletinfo['immature_balance'], 0)
# Have node0 mine a block, thus it will collect its own fee. # Have node0 mine a block, thus it will collect its own fee.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
# Exercise locking of unspent outputs # Exercise locking of unspent outputs
@ -159,7 +159,7 @@ class WalletTest(BitcoinTestFramework):
assert_equal(len(self.nodes[1].listlockunspent()), 0) assert_equal(len(self.nodes[1].listlockunspent()), 0)
# Have node1 generate 100 blocks (so node0 can recover the fee) # Have node1 generate 100 blocks (so node0 can recover the fee)
self.nodes[1].generate(COINBASE_MATURITY) self.generate(self.nodes[1], COINBASE_MATURITY)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
# node0 should end up with 100 btc in block rewards plus fees, but # node0 should end up with 100 btc in block rewards plus fees, but
@ -188,7 +188,7 @@ class WalletTest(BitcoinTestFramework):
self.nodes[1].sendrawtransaction(hexstring=txns_to_send[1]["hex"], maxfeerate=0) self.nodes[1].sendrawtransaction(hexstring=txns_to_send[1]["hex"], maxfeerate=0)
# Have node1 mine a block to confirm transactions: # Have node1 mine a block to confirm transactions:
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
assert_equal(self.nodes[0].getbalance(), 0) assert_equal(self.nodes[0].getbalance(), 0)
@ -203,14 +203,14 @@ class WalletTest(BitcoinTestFramework):
fee_per_byte = Decimal('0.001') / 1000 fee_per_byte = Decimal('0.001') / 1000
self.nodes[2].settxfee(fee_per_byte * 1000) self.nodes[2].settxfee(fee_per_byte * 1000)
txid = self.nodes[2].sendtoaddress(address, 10, "", "", False) txid = self.nodes[2].sendtoaddress(address, 10, "", "", False)
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
assert_equal(self.nodes[0].getbalance(), Decimal('10')) assert_equal(self.nodes[0].getbalance(), Decimal('10'))
# Send 10 BTC with subtract fee from amount # Send 10 BTC with subtract fee from amount
txid = self.nodes[2].sendtoaddress(address, 10, "", "", True) txid = self.nodes[2].sendtoaddress(address, 10, "", "", True)
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
node_2_bal -= Decimal('10') node_2_bal -= Decimal('10')
assert_equal(self.nodes[2].getbalance(), node_2_bal) assert_equal(self.nodes[2].getbalance(), node_2_bal)
@ -220,7 +220,7 @@ class WalletTest(BitcoinTestFramework):
# Sendmany 10 BTC # Sendmany 10 BTC
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", []) txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [])
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
node_0_bal += Decimal('10') node_0_bal += Decimal('10')
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
@ -228,7 +228,7 @@ class WalletTest(BitcoinTestFramework):
# Sendmany 10 BTC with subtract fee from amount # Sendmany 10 BTC with subtract fee from amount
txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [address]) txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [address])
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
node_2_bal -= Decimal('10') node_2_bal -= Decimal('10')
assert_equal(self.nodes[2].getbalance(), node_2_bal) assert_equal(self.nodes[2].getbalance(), node_2_bal)
@ -241,7 +241,7 @@ class WalletTest(BitcoinTestFramework):
# Test passing fee_rate as a string # Test passing fee_rate as a string
txid = self.nodes[2].sendmany(amounts={address: 10}, fee_rate=str(fee_rate_sat_vb)) txid = self.nodes[2].sendmany(amounts={address: 10}, fee_rate=str(fee_rate_sat_vb))
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
balance = self.nodes[2].getbalance() balance = self.nodes[2].getbalance()
node_2_bal = self.check_fee_amount(balance, node_2_bal - Decimal('10'), explicit_fee_rate_btc_kvb, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) node_2_bal = self.check_fee_amount(balance, node_2_bal - Decimal('10'), explicit_fee_rate_btc_kvb, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
@ -252,7 +252,7 @@ class WalletTest(BitcoinTestFramework):
# Test passing fee_rate as an integer # Test passing fee_rate as an integer
amount = Decimal("0.0001") amount = Decimal("0.0001")
txid = self.nodes[2].sendmany(amounts={address: amount}, fee_rate=fee_rate_sat_vb) txid = self.nodes[2].sendmany(amounts={address: amount}, fee_rate=fee_rate_sat_vb)
self.nodes[2].generate(1) self.generate(self.nodes[2], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
balance = self.nodes[2].getbalance() balance = self.nodes[2].getbalance()
node_2_bal = self.check_fee_amount(balance, node_2_bal - amount, explicit_fee_rate_btc_kvb, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) node_2_bal = self.check_fee_amount(balance, node_2_bal - amount, explicit_fee_rate_btc_kvb, self.get_vsize(self.nodes[2].gettransaction(txid)['hex']))
@ -314,7 +314,7 @@ class WalletTest(BitcoinTestFramework):
self.nodes[1].sendrawtransaction(signed_raw_tx['hex']) self.nodes[1].sendrawtransaction(signed_raw_tx['hex'])
self.sync_all() self.sync_all()
self.nodes[1].generate(1) # mine a block self.generate(self.nodes[1], 1) # mine a block
self.sync_all() self.sync_all()
unspent_txs = self.nodes[0].listunspent() # zero value tx must be in listunspents output unspent_txs = self.nodes[0].listunspent() # zero value tx must be in listunspents output
@ -337,13 +337,13 @@ class WalletTest(BitcoinTestFramework):
txid_not_broadcast = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2) txid_not_broadcast = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast) tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast)
self.nodes[1].generate(1) # mine a block, tx should not be in there self.generate(self.nodes[1], 1) # mine a block, tx should not be in there
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
assert_equal(self.nodes[2].getbalance(), node_2_bal) # should not be changed because tx was not broadcasted assert_equal(self.nodes[2].getbalance(), node_2_bal) # should not be changed because tx was not broadcasted
# now broadcast from another node, mine a block, sync, and check the balance # now broadcast from another node, mine a block, sync, and check the balance
self.nodes[1].sendrawtransaction(tx_obj_not_broadcast['hex']) self.nodes[1].sendrawtransaction(tx_obj_not_broadcast['hex'])
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
node_2_bal += 2 node_2_bal += 2
tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast) tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast)
@ -362,7 +362,7 @@ class WalletTest(BitcoinTestFramework):
self.connect_nodes(0, 2) self.connect_nodes(0, 2)
self.sync_blocks(self.nodes[0:3]) self.sync_blocks(self.nodes[0:3])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks(self.nodes[0:3]) self.sync_blocks(self.nodes[0:3])
node_2_bal += 2 node_2_bal += 2
@ -391,7 +391,7 @@ class WalletTest(BitcoinTestFramework):
assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].sendtoaddress, self.nodes[2].getnewaddress(), "1f-4") assert_raises_rpc_error(-3, "Invalid amount", self.nodes[0].sendtoaddress, self.nodes[2].getnewaddress(), "1f-4")
# This will raise an exception since generate does not accept a string # This will raise an exception since generate does not accept a string
assert_raises_rpc_error(-1, "not an integer", self.nodes[0].generate, "2") assert_raises_rpc_error(-1, "not an integer", self.generate, self.nodes[0], "2")
if not self.options.descriptors: if not self.options.descriptors:
@ -427,7 +427,7 @@ class WalletTest(BitcoinTestFramework):
# 1. Send some coins to generate new UTXO # 1. Send some coins to generate new UTXO
address_to_import = self.nodes[2].getnewaddress() address_to_import = self.nodes[2].getnewaddress()
txid = self.nodes[0].sendtoaddress(address_to_import, 1) txid = self.nodes[0].sendtoaddress(address_to_import, 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
self.log.info("Test sendtoaddress with fee_rate param (explicit fee rate in sat/vB)") self.log.info("Test sendtoaddress with fee_rate param (explicit fee rate in sat/vB)")
@ -440,7 +440,7 @@ class WalletTest(BitcoinTestFramework):
# Test passing fee_rate as an integer # Test passing fee_rate as an integer
txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=fee_rate_sat_vb) txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=fee_rate_sat_vb)
tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex']) tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
postbalance = self.nodes[2].getbalance() postbalance = self.nodes[2].getbalance()
fee = prebalance - postbalance - Decimal(amount) fee = prebalance - postbalance - Decimal(amount)
@ -453,7 +453,7 @@ class WalletTest(BitcoinTestFramework):
# Test passing fee_rate as a string # Test passing fee_rate as a string
txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=str(fee_rate_sat_vb)) txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=str(fee_rate_sat_vb))
tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex']) tx_size = self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
postbalance = self.nodes[2].getbalance() postbalance = self.nodes[2].getbalance()
fee = prebalance - postbalance - amount fee = prebalance - postbalance - amount
@ -515,7 +515,7 @@ class WalletTest(BitcoinTestFramework):
# Mine a block from node0 to an address from node1 # Mine a block from node0 to an address from node1
coinbase_addr = self.nodes[1].getnewaddress() coinbase_addr = self.nodes[1].getnewaddress()
block_hash = self.nodes[0].generatetoaddress(1, coinbase_addr)[0] block_hash = self.generatetoaddress(self.nodes[0], 1, coinbase_addr)[0]
coinbase_txid = self.nodes[0].getblock(block_hash)['tx'][0] coinbase_txid = self.nodes[0].getblock(block_hash)['tx'][0]
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
@ -524,7 +524,7 @@ class WalletTest(BitcoinTestFramework):
# check if wallet or blockchain maintenance changes the balance # check if wallet or blockchain maintenance changes the balance
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
blocks = self.nodes[0].generate(2) blocks = self.generate(self.nodes[0], 2)
self.sync_all(self.nodes[0:3]) self.sync_all(self.nodes[0:3])
balance_nodes = [self.nodes[i].getbalance() for i in range(3)] balance_nodes = [self.nodes[i].getbalance() for i in range(3)]
block_count = self.nodes[0].getblockcount() block_count = self.nodes[0].getblockcount()
@ -572,13 +572,13 @@ class WalletTest(BitcoinTestFramework):
# Get all non-zero utxos together # Get all non-zero utxos together
chain_addrs = [self.nodes[0].getnewaddress(), self.nodes[0].getnewaddress()] chain_addrs = [self.nodes[0].getnewaddress(), self.nodes[0].getnewaddress()]
singletxid = self.nodes[0].sendtoaddress(chain_addrs[0], self.nodes[0].getbalance(), "", "", True) singletxid = self.nodes[0].sendtoaddress(chain_addrs[0], self.nodes[0].getbalance(), "", "", True)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
node0_balance = self.nodes[0].getbalance() node0_balance = self.nodes[0].getbalance()
# Split into two chains # Split into two chains
rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], {chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')}) rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], {chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')})
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx) signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0) singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Make a long chain of unconfirmed payments without hitting mempool limit # Make a long chain of unconfirmed payments without hitting mempool limit
# Each tx we make leaves only one output of change on a chain 1 longer # Each tx we make leaves only one output of change on a chain 1 longer
@ -629,7 +629,7 @@ class WalletTest(BitcoinTestFramework):
assert not address_info["ischange"] assert not address_info["ischange"]
# Test getaddressinfo 'ischange' field on change address. # Test getaddressinfo 'ischange' field on change address.
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
destination = self.nodes[1].getnewaddress() destination = self.nodes[1].getnewaddress()
txid = self.nodes[0].sendtoaddress(destination, 0.123) txid = self.nodes[0].sendtoaddress(destination, 0.123)
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex']) tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex'])

View file

@ -59,7 +59,7 @@ class BumpFeeTest(BitcoinTestFramework):
def clear_mempool(self): def clear_mempool(self):
# Clear mempool between subtests. The subtests may only depend on chainstate (utxos) # Clear mempool between subtests. The subtests may only depend on chainstate (utxos)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
self.sync_all() self.sync_all()
def run_test(self): def run_test(self):
@ -72,12 +72,12 @@ class BumpFeeTest(BitcoinTestFramework):
# fund rbf node with 10 coins of 0.001 btc (100,000 satoshis) # fund rbf node with 10 coins of 0.001 btc (100,000 satoshis)
self.log.info("Mining blocks...") self.log.info("Mining blocks...")
peer_node.generate(110) self.generate(peer_node, 110)
self.sync_all() self.sync_all()
for _ in range(25): for _ in range(25):
peer_node.sendtoaddress(rbf_node_address, 0.001) peer_node.sendtoaddress(rbf_node_address, 0.001)
self.sync_all() self.sync_all()
peer_node.generate(1) self.generate(peer_node, 1)
self.sync_all() self.sync_all()
assert_equal(rbf_node.getbalance(), Decimal("0.025")) assert_equal(rbf_node.getbalance(), Decimal("0.025"))
@ -272,7 +272,7 @@ def test_small_output_with_feerate_succeeds(self, rbf_node, dest_address):
self.log.info('Testing small output with feerate bump succeeds') self.log.info('Testing small output with feerate bump succeeds')
# Make sure additional inputs exist # Make sure additional inputs exist
rbf_node.generatetoaddress(COINBASE_MATURITY + 1, rbf_node.getnewaddress()) self.generatetoaddress(rbf_node, COINBASE_MATURITY + 1, rbf_node.getnewaddress())
rbfid = spend_one_input(rbf_node, dest_address) rbfid = spend_one_input(rbf_node, dest_address)
input_list = rbf_node.getrawtransaction(rbfid, 1)["vin"] input_list = rbf_node.getrawtransaction(rbfid, 1)["vin"]
assert_equal(len(input_list), 1) assert_equal(len(input_list), 1)
@ -305,7 +305,7 @@ def test_small_output_with_feerate_succeeds(self, rbf_node, dest_address):
if txin["txid"] == original_txin["txid"] if txin["txid"] == original_txin["txid"]
and txin["vout"] == original_txin["vout"]] and txin["vout"] == original_txin["vout"]]
rbf_node.generatetoaddress(1, rbf_node.getnewaddress()) self.generatetoaddress(rbf_node, 1, rbf_node.getnewaddress())
assert_equal(rbf_node.gettransaction(rbfid)["confirmations"], 1) assert_equal(rbf_node.gettransaction(rbfid)["confirmations"], 1)
self.clear_mempool() self.clear_mempool()
@ -433,7 +433,7 @@ def test_watchonly_psbt(self, peer_node, rbf_node, dest_address):
funding_address1 = watcher.getnewaddress(address_type='bech32') funding_address1 = watcher.getnewaddress(address_type='bech32')
funding_address2 = watcher.getnewaddress(address_type='bech32') funding_address2 = watcher.getnewaddress(address_type='bech32')
peer_node.sendmany("", {funding_address1: 0.001, funding_address2: 0.001}) peer_node.sendmany("", {funding_address1: 0.001, funding_address2: 0.001})
peer_node.generate(1) self.generate(peer_node, 1)
self.sync_all() self.sync_all()
# Create single-input PSBT for transaction to be bumped # Create single-input PSBT for transaction to be bumped
@ -519,7 +519,7 @@ def test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address):
assert_equal([t for t in rbf_node.listunspent(minconf=0, include_unsafe=False) if t["txid"] == rbfid], []) assert_equal([t for t in rbf_node.listunspent(minconf=0, include_unsafe=False) if t["txid"] == rbfid], [])
# check that the main output from the rbf tx is spendable after confirmed # check that the main output from the rbf tx is spendable after confirmed
rbf_node.generate(1) self.generate(rbf_node, 1)
assert_equal( assert_equal(
sum(1 for t in rbf_node.listunspent(minconf=0, include_unsafe=False) sum(1 for t in rbf_node.listunspent(minconf=0, include_unsafe=False)
if t["txid"] == rbfid and t["address"] == rbf_node_address and t["spendable"]), 1) if t["txid"] == rbfid and t["address"] == rbf_node_address and t["spendable"]), 1)
@ -529,7 +529,7 @@ def test_unconfirmed_not_spendable(self, rbf_node, rbf_node_address):
def test_bumpfee_metadata(self, rbf_node, dest_address): def test_bumpfee_metadata(self, rbf_node, dest_address):
self.log.info('Test that bumped txn metadata persists to new txn record') self.log.info('Test that bumped txn metadata persists to new txn record')
assert(rbf_node.getbalance() < 49) assert(rbf_node.getbalance() < 49)
rbf_node.generatetoaddress(101, rbf_node.getnewaddress()) self.generatetoaddress(rbf_node, 101, rbf_node.getnewaddress())
rbfid = rbf_node.sendtoaddress(dest_address, 49, "comment value", "to value") rbfid = rbf_node.sendtoaddress(dest_address, 49, "comment value", "to value")
bumped_tx = rbf_node.bumpfee(rbfid) bumped_tx = rbf_node.bumpfee(rbfid)
bumped_wtx = rbf_node.gettransaction(bumped_tx["txid"]) bumped_wtx = rbf_node.gettransaction(bumped_tx["txid"])
@ -599,7 +599,7 @@ def submit_block_with_tx(node, tx):
def test_no_more_inputs_fails(self, rbf_node, dest_address): def test_no_more_inputs_fails(self, rbf_node, dest_address):
self.log.info('Test that bumpfee fails when there are no available confirmed outputs') self.log.info('Test that bumpfee fails when there are no available confirmed outputs')
# feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient # feerate rbf requires confirmed outputs when change output doesn't exist or is insufficient
rbf_node.generatetoaddress(1, dest_address) self.generatetoaddress(rbf_node, 1, dest_address)
# spend all funds, no change output # spend all funds, no change output
rbfid = rbf_node.sendtoaddress(rbf_node.getnewaddress(), rbf_node.getbalance(), "", "", True) rbfid = rbf_node.sendtoaddress(rbf_node.getnewaddress(), rbf_node.getbalance(), "", "", True)
assert_raises_rpc_error(-4, "Unable to create transaction. Insufficient funds", rbf_node.bumpfee, rbfid) assert_raises_rpc_error(-4, "Unable to create transaction. Insufficient funds", rbf_node.bumpfee, rbfid)

View file

@ -33,7 +33,7 @@ class CoinbaseCategoryTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
# Generate one block to an address # Generate one block to an address
address = self.nodes[0].getnewaddress() address = self.nodes[0].getnewaddress()
self.nodes[0].generatetoaddress(1, address) self.generatetoaddress(self.nodes[0], 1, address)
hash = self.nodes[0].getbestblockhash() hash = self.nodes[0].getbestblockhash()
txid = self.nodes[0].getblock(hash)["tx"][0] txid = self.nodes[0].getblock(hash)["tx"][0]
@ -41,12 +41,12 @@ class CoinbaseCategoryTest(BitcoinTestFramework):
self.assert_category("immature", address, txid, 0) self.assert_category("immature", address, txid, 0)
# Mine another 99 blocks on top # Mine another 99 blocks on top
self.nodes[0].generate(99) self.generate(self.nodes[0], 99)
# Coinbase transaction is still immature after 100 confirmations # Coinbase transaction is still immature after 100 confirmations
self.assert_category("immature", address, txid, 99) self.assert_category("immature", address, txid, 99)
# Mine one more block # Mine one more block
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Coinbase transaction is now matured, so category is "generate" # Coinbase transaction is now matured, so category is "generate"
self.assert_category("generate", address, txid, 100) self.assert_category("generate", address, txid, 100)

View file

@ -24,7 +24,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info('Create some old blocks') self.log.info('Create some old blocks')
self.nodes[0].setmocktime(TIME_GENESIS_BLOCK) self.nodes[0].setmocktime(TIME_GENESIS_BLOCK)
self.nodes[0].generate(200) self.generate(self.nodes[0], 200)
self.nodes[0].setmocktime(0) self.nodes[0].setmocktime(0)
self.test_anti_fee_sniping() self.test_anti_fee_sniping()
@ -38,7 +38,7 @@ class CreateTxWalletTest(BitcoinTestFramework):
assert_equal(tx['locktime'], 0) assert_equal(tx['locktime'], 0)
self.log.info('Check that anti-fee-sniping is enabled when we mine a recent block') self.log.info('Check that anti-fee-sniping is enabled when we mine a recent block')
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex']) tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex'])
assert 0 < tx['locktime'] <= 201 assert 0 < tx['locktime'] <= 201

View file

@ -24,7 +24,7 @@ class CreateWalletTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
node = self.nodes[0] node = self.nodes[0]
node.generate(1) # Leave IBD for sethdseed self.generate(node, 1) # Leave IBD for sethdseed
self.nodes[0].createwallet(wallet_name='w0') self.nodes[0].createwallet(wallet_name='w0')
w0 = node.get_wallet_rpc('w0') w0 = node.get_wallet_rpc('w0')

View file

@ -28,8 +28,8 @@ class DisableWalletTest (BitcoinTestFramework):
# Checking mining to an address without a wallet. Generating to a valid address should succeed # Checking mining to an address without a wallet. Generating to a valid address should succeed
# but generating to an invalid address will fail. # but generating to an invalid address will fail.
self.nodes[0].generatetoaddress(1, 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ') self.generatetoaddress(self.nodes[0], 1, 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
assert_raises_rpc_error(-5, "Invalid address", self.nodes[0].generatetoaddress, 1, '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy') assert_raises_rpc_error(-5, "Invalid address", self.generatetoaddress, self.nodes[0], 1, '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
if __name__ == '__main__': if __name__ == '__main__':
DisableWalletTest ().main () DisableWalletTest ().main ()

View file

@ -134,7 +134,7 @@ class WalletDumpTest(BitcoinTestFramework):
self.log.info('Mine a block one second before the wallet is dumped') self.log.info('Mine a block one second before the wallet is dumped')
dump_time = int(time.time()) dump_time = int(time.time())
self.nodes[0].setmocktime(dump_time - 1) self.nodes[0].setmocktime(dump_time - 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.nodes[0].setmocktime(dump_time) self.nodes[0].setmocktime(dump_time)
dump_time_str = '# * Created on {}Z'.format( dump_time_str = '# * Created on {}Z'.format(
datetime.datetime.fromtimestamp( datetime.datetime.fromtimestamp(

View file

@ -17,7 +17,7 @@ class WalletRBFTest(BitcoinTestFramework):
self.skip_if_no_wallet() self.skip_if_no_wallet()
def run_test(self): def run_test(self):
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
# sending a transaction without fee estimations must be possible by default on regtest # sending a transaction without fee estimations must be possible by default on regtest
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)

View file

@ -34,7 +34,7 @@ class WalletGroupTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Setting up") self.log.info("Setting up")
# Mine some coins # Mine some coins
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
# Get some addresses from the two nodes # Get some addresses from the two nodes
addr1 = [self.nodes[1].getnewaddress() for _ in range(3)] addr1 = [self.nodes[1].getnewaddress() for _ in range(3)]
@ -45,7 +45,7 @@ class WalletGroupTest(BitcoinTestFramework):
[self.nodes[0].sendtoaddress(addr, 1.0) for addr in addrs] [self.nodes[0].sendtoaddress(addr, 1.0) for addr in addrs]
[self.nodes[0].sendtoaddress(addr, 0.5) for addr in addrs] [self.nodes[0].sendtoaddress(addr, 0.5) for addr in addrs]
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# For each node, send 0.2 coins back to 0; # For each node, send 0.2 coins back to 0;
@ -77,7 +77,7 @@ class WalletGroupTest(BitcoinTestFramework):
self.log.info("Test avoiding partial spends if warranted, even if avoidpartialspends is disabled") self.log.info("Test avoiding partial spends if warranted, even if avoidpartialspends is disabled")
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# Nodes 1-2 now have confirmed UTXOs (letters denote destinations): # Nodes 1-2 now have confirmed UTXOs (letters denote destinations):
# Node #1: Node #2: # Node #1: Node #2:
# - A 1.0 - D0 1.0 # - A 1.0 - D0 1.0
@ -113,7 +113,7 @@ class WalletGroupTest(BitcoinTestFramework):
addr_aps = self.nodes[3].getnewaddress() addr_aps = self.nodes[3].getnewaddress()
self.nodes[0].sendtoaddress(addr_aps, 1.0) self.nodes[0].sendtoaddress(addr_aps, 1.0)
self.nodes[0].sendtoaddress(addr_aps, 1.0) self.nodes[0].sendtoaddress(addr_aps, 1.0)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
with self.nodes[3].assert_debug_log(['Fee non-grouped = 2820, grouped = 4160, using grouped']): with self.nodes[3].assert_debug_log(['Fee non-grouped = 2820, grouped = 4160, using grouped']):
txid4 = self.nodes[3].sendtoaddress(self.nodes[0].getnewaddress(), 0.1) txid4 = self.nodes[3].sendtoaddress(self.nodes[0].getnewaddress(), 0.1)
@ -125,7 +125,7 @@ class WalletGroupTest(BitcoinTestFramework):
addr_aps2 = self.nodes[3].getnewaddress() addr_aps2 = self.nodes[3].getnewaddress()
[self.nodes[0].sendtoaddress(addr_aps2, 1.0) for _ in range(5)] [self.nodes[0].sendtoaddress(addr_aps2, 1.0) for _ in range(5)]
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
with self.nodes[3].assert_debug_log(['Fee non-grouped = 5520, grouped = 8240, using non-grouped']): with self.nodes[3].assert_debug_log(['Fee non-grouped = 5520, grouped = 8240, using non-grouped']):
txid5 = self.nodes[3].sendtoaddress(self.nodes[0].getnewaddress(), 2.95) txid5 = self.nodes[3].sendtoaddress(self.nodes[0].getnewaddress(), 2.95)
@ -139,7 +139,7 @@ class WalletGroupTest(BitcoinTestFramework):
self.log.info("Test wallet option maxapsfee threshold from non-grouped to grouped") self.log.info("Test wallet option maxapsfee threshold from non-grouped to grouped")
addr_aps3 = self.nodes[4].getnewaddress() addr_aps3 = self.nodes[4].getnewaddress()
[self.nodes[0].sendtoaddress(addr_aps3, 1.0) for _ in range(5)] [self.nodes[0].sendtoaddress(addr_aps3, 1.0) for _ in range(5)]
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
with self.nodes[4].assert_debug_log(['Fee non-grouped = 5520, grouped = 8240, using grouped']): with self.nodes[4].assert_debug_log(['Fee non-grouped = 5520, grouped = 8240, using grouped']):
txid6 = self.nodes[4].sendtoaddress(self.nodes[0].getnewaddress(), 2.95) txid6 = self.nodes[4].sendtoaddress(self.nodes[0].getnewaddress(), 2.95)
@ -151,7 +151,7 @@ class WalletGroupTest(BitcoinTestFramework):
# Empty out node2's wallet # Empty out node2's wallet
self.nodes[2].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=self.nodes[2].getbalance(), subtractfeefromamount=True) self.nodes[2].sendtoaddress(address=self.nodes[0].getnewaddress(), amount=self.nodes[2].getbalance(), subtractfeefromamount=True)
self.sync_all() self.sync_all()
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.log.info("Fill a wallet with 10,000 outputs corresponding to the same scriptPubKey") self.log.info("Fill a wallet with 10,000 outputs corresponding to the same scriptPubKey")
for _ in range(5): for _ in range(5):
@ -162,7 +162,7 @@ class WalletGroupTest(BitcoinTestFramework):
funded_tx = self.nodes[0].fundrawtransaction(tx.serialize().hex()) funded_tx = self.nodes[0].fundrawtransaction(tx.serialize().hex())
signed_tx = self.nodes[0].signrawtransactionwithwallet(funded_tx['hex']) signed_tx = self.nodes[0].signrawtransactionwithwallet(funded_tx['hex'])
self.nodes[0].sendrawtransaction(signed_tx['hex']) self.nodes[0].sendrawtransaction(signed_tx['hex'])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# Check that we can create a transaction that only requires ~100 of our # Check that we can create a transaction that only requires ~100 of our

View file

@ -49,7 +49,7 @@ class WalletHDTest(BitcoinTestFramework):
# Derive some HD addresses and remember the last # Derive some HD addresses and remember the last
# Also send funds to each add # Also send funds to each add
self.nodes[0].generate(COINBASE_MATURITY + 1) self.generate(self.nodes[0], COINBASE_MATURITY + 1)
hd_add = None hd_add = None
NUM_HD_ADDS = 10 NUM_HD_ADDS = 10
for i in range(1, NUM_HD_ADDS + 1): for i in range(1, NUM_HD_ADDS + 1):
@ -61,9 +61,9 @@ class WalletHDTest(BitcoinTestFramework):
assert_equal(hd_info["hdkeypath"], "m/0'/0'/" + str(i) + "'") assert_equal(hd_info["hdkeypath"], "m/0'/0'/" + str(i) + "'")
assert_equal(hd_info["hdmasterfingerprint"], hd_fingerprint) assert_equal(hd_info["hdmasterfingerprint"], hd_fingerprint)
self.nodes[0].sendtoaddress(hd_add, 1) self.nodes[0].sendtoaddress(hd_add, 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.nodes[0].sendtoaddress(non_hd_add, 1) self.nodes[0].sendtoaddress(non_hd_add, 1)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
# create an internal key (again) # create an internal key (again)
change_addr = self.nodes[1].getrawchangeaddress() change_addr = self.nodes[1].getrawchangeaddress()
@ -179,7 +179,7 @@ class WalletHDTest(BitcoinTestFramework):
assert_raises_rpc_error(-5, "Already have this key", self.nodes[1].sethdseed, False, self.nodes[1].dumpprivkey(self.nodes[1].getnewaddress())) assert_raises_rpc_error(-5, "Already have this key", self.nodes[1].sethdseed, False, self.nodes[1].dumpprivkey(self.nodes[1].getnewaddress()))
self.log.info('Test sethdseed restoring with keys outside of the initial keypool') self.log.info('Test sethdseed restoring with keys outside of the initial keypool')
self.nodes[0].generate(10) self.generate(self.nodes[0], 10)
# Restart node 1 with keypool of 3 and a different wallet # Restart node 1 with keypool of 3 and a different wallet
self.nodes[1].createwallet(wallet_name='origin', blank=True) self.nodes[1].createwallet(wallet_name='origin', blank=True)
self.restart_node(1, extra_args=['-keypool=3', '-wallet=origin']) self.restart_node(1, extra_args=['-keypool=3', '-wallet=origin'])
@ -228,7 +228,7 @@ class WalletHDTest(BitcoinTestFramework):
# The wallet that has set a new seed (restore_rpc) should not detect this transaction. # The wallet that has set a new seed (restore_rpc) should not detect this transaction.
txid = self.nodes[0].sendtoaddress(addr, 1) txid = self.nodes[0].sendtoaddress(addr, 1)
origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex']) origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex'])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
origin_rpc.gettransaction(txid) origin_rpc.gettransaction(txid)
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', restore_rpc.gettransaction, txid) assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', restore_rpc.gettransaction, txid)
@ -239,7 +239,7 @@ class WalletHDTest(BitcoinTestFramework):
# The previous transaction (out_of_kp_txid) should still not be detected as a rescan is required. # The previous transaction (out_of_kp_txid) should still not be detected as a rescan is required.
txid = self.nodes[0].sendtoaddress(last_addr, 1) txid = self.nodes[0].sendtoaddress(last_addr, 1)
origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex']) origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex'])
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_blocks() self.sync_blocks()
origin_rpc.gettransaction(txid) origin_rpc.gettransaction(txid)
restore_rpc.gettransaction(txid) restore_rpc.gettransaction(txid)

View file

@ -178,7 +178,7 @@ class ImportRescanTest(BitcoinTestFramework):
variant.key = self.nodes[1].dumpprivkey(variant.address["address"]) variant.key = self.nodes[1].dumpprivkey(variant.address["address"])
variant.initial_amount = get_rand_amount() variant.initial_amount = get_rand_amount()
variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount) variant.initial_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.initial_amount)
self.nodes[0].generate(1) # Generate one block for each send self.generate(self.nodes[0], 1) # Generate one block for each send
variant.confirmation_height = self.nodes[0].getblockcount() variant.confirmation_height = self.nodes[0].getblockcount()
variant.timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())["time"] variant.timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())["time"]
self.sync_all() # Conclude sync before calling setmocktime to avoid timeouts self.sync_all() # Conclude sync before calling setmocktime to avoid timeouts
@ -189,7 +189,7 @@ class ImportRescanTest(BitcoinTestFramework):
self.nodes, self.nodes,
self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())["time"] + TIMESTAMP_WINDOW + 1, self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())["time"] + TIMESTAMP_WINDOW + 1,
) )
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# For each variation of wallet key import, invoke the import RPC and # For each variation of wallet key import, invoke the import RPC and
@ -212,7 +212,7 @@ class ImportRescanTest(BitcoinTestFramework):
for i, variant in enumerate(IMPORT_VARIANTS): for i, variant in enumerate(IMPORT_VARIANTS):
variant.sent_amount = get_rand_amount() variant.sent_amount = get_rand_amount()
variant.sent_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.sent_amount) variant.sent_txid = self.nodes[0].sendtoaddress(variant.address["address"], variant.sent_amount)
self.nodes[0].generate(1) # Generate one block for each send self.generate(self.nodes[0], 1) # Generate one block for each send
variant.confirmation_height = self.nodes[0].getblockcount() variant.confirmation_height = self.nodes[0].getblockcount()
assert_equal(self.nodes[0].getrawmempool(), []) assert_equal(self.nodes[0].getrawmempool(), [])

View file

@ -451,12 +451,12 @@ class ImportDescriptorsTest(BitcoinTestFramework):
assert_equal(change_addr, 'bcrt1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsy44n8e') assert_equal(change_addr, 'bcrt1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsy44n8e')
assert_equal(wmulti_priv.getwalletinfo()['keypoolsize'], 1000) assert_equal(wmulti_priv.getwalletinfo()['keypoolsize'], 1000)
txid = w0.sendtoaddress(addr, 10) txid = w0.sendtoaddress(addr, 10)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
send_txid = wmulti_priv.sendtoaddress(w0.getnewaddress(), 8) send_txid = wmulti_priv.sendtoaddress(w0.getnewaddress(), 8)
decoded = wmulti_priv.decoderawtransaction(wmulti_priv.gettransaction(send_txid)['hex']) decoded = wmulti_priv.decoderawtransaction(wmulti_priv.gettransaction(send_txid)['hex'])
assert_equal(len(decoded['vin'][0]['txinwitness']), 4) assert_equal(len(decoded['vin'][0]['txinwitness']), 4)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
self.nodes[1].createwallet(wallet_name="wmulti_pub", disable_private_keys=True, blank=True, descriptors=True) self.nodes[1].createwallet(wallet_name="wmulti_pub", disable_private_keys=True, blank=True, descriptors=True)
@ -494,7 +494,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
txid2 = w0.sendtoaddress(addr2, 10) txid2 = w0.sendtoaddress(addr2, 10)
vout2 = find_vout_for_address(self.nodes[0], txid2, addr2) vout2 = find_vout_for_address(self.nodes[0], txid2, addr2)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
assert_equal(wmulti_pub.getbalance(), wmulti_priv.getbalance()) assert_equal(wmulti_pub.getbalance(), wmulti_priv.getbalance())
@ -582,7 +582,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
addr = wmulti_priv_big.getnewaddress() addr = wmulti_priv_big.getnewaddress()
w0.sendtoaddress(addr, 10) w0.sendtoaddress(addr, 10)
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.sync_all() self.sync_all()
# It is standard and would relay. # It is standard and would relay.
txid = wmulti_priv_big.sendtoaddress(w0.getnewaddress(), 9.999) txid = wmulti_priv_big.sendtoaddress(w0.getnewaddress(), 9.999)
@ -617,7 +617,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
addr = multi_priv_big.getnewaddress("", "legacy") addr = multi_priv_big.getnewaddress("", "legacy")
w0.sendtoaddress(addr, 10) w0.sendtoaddress(addr, 10)
self.nodes[0].generate(6) self.generate(self.nodes[0], 6)
self.sync_all() self.sync_all()
# It is standard and would relay. # It is standard and would relay.
txid = multi_priv_big.sendtoaddress(w0.getnewaddress(), 10, "", "", txid = multi_priv_big.sendtoaddress(w0.getnewaddress(), 10, "", "",

View file

@ -62,8 +62,8 @@ class ImportMultiTest(BitcoinTestFramework):
def run_test(self): def run_test(self):
self.log.info("Mining blocks...") self.log.info("Mining blocks...")
self.nodes[0].generate(1) self.generate(self.nodes[0], 1)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue() # Sync the timestamp to the wallet, so that importmulti works self.nodes[1].syncwithvalidationinterfacequeue() # Sync the timestamp to the wallet, so that importmulti works
@ -256,9 +256,9 @@ class ImportMultiTest(BitcoinTestFramework):
# P2SH address # P2SH address
multisig = get_multisig(self.nodes[0]) multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(COINBASE_MATURITY) self.generate(self.nodes[1], COINBASE_MATURITY)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue() self.nodes[1].syncwithvalidationinterfacequeue()
@ -277,9 +277,9 @@ class ImportMultiTest(BitcoinTestFramework):
# P2SH + Redeem script # P2SH + Redeem script
multisig = get_multisig(self.nodes[0]) multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(COINBASE_MATURITY) self.generate(self.nodes[1], COINBASE_MATURITY)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue() self.nodes[1].syncwithvalidationinterfacequeue()
@ -298,9 +298,9 @@ class ImportMultiTest(BitcoinTestFramework):
# P2SH + Redeem script + Private Keys + !Watchonly # P2SH + Redeem script + Private Keys + !Watchonly
multisig = get_multisig(self.nodes[0]) multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(COINBASE_MATURITY) self.generate(self.nodes[1], COINBASE_MATURITY)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue() self.nodes[1].syncwithvalidationinterfacequeue()
@ -324,9 +324,9 @@ class ImportMultiTest(BitcoinTestFramework):
# P2SH + Redeem script + Private Keys + Watchonly # P2SH + Redeem script + Private Keys + Watchonly
multisig = get_multisig(self.nodes[0]) multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(COINBASE_MATURITY) self.generate(self.nodes[1], COINBASE_MATURITY)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00) self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1) self.generate(self.nodes[1], 1)
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime'] timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
self.nodes[1].syncwithvalidationinterfacequeue() self.nodes[1].syncwithvalidationinterfacequeue()

Some files were not shown because too many files have changed in this diff Show more