mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
merge bitcoin#23300: Implicitly sync after generate*, unless opted out
This commit is contained in:
parent
e913a45eaf
commit
9b3fbdde10
@ -148,8 +148,7 @@ class ExampleTest(BitcoinTestFramework):
|
||||
peer_messaging = self.nodes[0].add_p2p_connection(BaseNode())
|
||||
|
||||
# Generating a block on one of the nodes will get us out of IBD
|
||||
blocks = [int(self.generate(self.nodes[0], nblocks=1)[0], 16)]
|
||||
self.sync_all(self.nodes[0:2])
|
||||
blocks = [int(self.generate(self.nodes[0], sync_fun=lambda: self.sync_all(self.nodes[0:2]), nblocks=1)[0], 16)]
|
||||
|
||||
# Notice above how we called an RPC by calling a method with the same
|
||||
# name on the node object. Notice also how we used a keyword argument
|
||||
|
@ -26,7 +26,7 @@ class AbortNodeTest(BitcoinTestFramework):
|
||||
# We'll connect the nodes later
|
||||
|
||||
def run_test(self):
|
||||
self.generate(self.nodes[0], 3)
|
||||
self.generate(self.nodes[0], 3, sync_fun=self.no_op)
|
||||
datadir = get_datadir_path(self.options.tmpdir, 0)
|
||||
|
||||
# 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
|
||||
# attempt.
|
||||
self.generate(self.nodes[1], 3)
|
||||
self.generate(self.nodes[1], 3, sync_fun=self.no_op)
|
||||
with self.nodes[0].assert_debug_log(["Failed to disconnect block"]):
|
||||
self.connect_nodes(0, 1)
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
|
||||
# Check that node0 aborted
|
||||
self.log.info("Waiting for crash")
|
||||
|
@ -272,7 +272,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
cur_time = self.mocktime
|
||||
for _ in range(10):
|
||||
self.nodes[0].setmocktime(cur_time + 600)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
cur_time += 600
|
||||
|
||||
assert tx2.hash in self.nodes[0].getrawmempool()
|
||||
@ -348,7 +348,7 @@ class BIP68Test(BitcoinTestFramework):
|
||||
# Reset the chain and get rid of the mocktimed-blocks
|
||||
self.nodes[0].setmocktime(self.mocktime)
|
||||
self.nodes[0].invalidateblock(self.nodes[0].getblockhash(cur_height+1))
|
||||
self.generate(self.nodes[0], 10)
|
||||
self.generate(self.nodes[0], 10, sync_fun=self.no_op)
|
||||
|
||||
# Make sure that BIP68 isn't being used to validate blocks prior to
|
||||
# activation height. If more blocks are mined prior to this test
|
||||
@ -401,9 +401,9 @@ class BIP68Test(BitcoinTestFramework):
|
||||
min_activation_height = 432
|
||||
height = self.nodes[0].getblockcount()
|
||||
assert_greater_than(min_activation_height - height, 2)
|
||||
self.generate(self.nodes[0], min_activation_height - height - 2)
|
||||
self.generate(self.nodes[0], min_activation_height - height - 2, sync_fun=self.no_op)
|
||||
assert not softfork_active(self.nodes[0], 'csv')
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
assert softfork_active(self.nodes[0], 'csv')
|
||||
self.sync_blocks()
|
||||
|
||||
|
@ -242,7 +242,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
res9 = index_node.gettxoutsetinfo('muhash')
|
||||
assert_equal(res8, res9)
|
||||
|
||||
self.generate(index_node, 1)
|
||||
self.generate(index_node, 1, sync_fun=self.no_op)
|
||||
res10 = index_node.gettxoutsetinfo('muhash')
|
||||
assert(res8['txouts'] < res10['txouts'])
|
||||
|
||||
@ -268,7 +268,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
|
||||
assert_equal(index_node.gettxoutsetinfo('muhash')['height'], 110)
|
||||
|
||||
# Add two new blocks
|
||||
block = self.generate(index_node, 2)[1]
|
||||
block = self.generate(index_node, 2, sync_fun=self.no_op)[1]
|
||||
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
|
||||
|
@ -217,7 +217,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||
|
||||
# Start by creating a lot of utxos on node3
|
||||
initial_height = self.nodes[3].getblockcount()
|
||||
utxo_list = create_confirmed_utxos(self, self.nodes[3].getnetworkinfo()['relayfee'], self.nodes[3], 5000)
|
||||
utxo_list = create_confirmed_utxos(self, self.nodes[3].getnetworkinfo()['relayfee'], self.nodes[3], 5000, sync_fun=self.no_op)
|
||||
self.log.info("Prepped %d utxo entries", len(utxo_list))
|
||||
|
||||
# Sync these blocks with the other nodes
|
||||
@ -258,6 +258,7 @@ class ChainstateWriteCrashTest(BitcoinTestFramework):
|
||||
nblocks=min(10, current_height + 1 - self.nodes[3].getblockcount()),
|
||||
# new address to avoid mining a block that has just been invalidated
|
||||
address=self.nodes[3].getnewaddress(),
|
||||
sync_fun=self.no_op,
|
||||
))
|
||||
self.log.debug("Syncing %d new blocks...", len(block_hashes))
|
||||
self.sync_node3blocks(block_hashes)
|
||||
|
@ -231,7 +231,7 @@ class EstimateFeeTest(BitcoinTestFramework):
|
||||
|
||||
# Mine
|
||||
while len(self.nodes[0].getrawmempool()) > 0:
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
|
||||
# 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
|
||||
@ -241,12 +241,12 @@ class EstimateFeeTest(BitcoinTestFramework):
|
||||
while len(self.txouts) > 0:
|
||||
split_inputs(self.nodes[0], self.txouts, self.txouts2)
|
||||
while len(self.nodes[0].getrawmempool()) > 0:
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
# Double txouts2 to txouts
|
||||
while len(self.txouts2) > 0:
|
||||
split_inputs(self.nodes[0], self.txouts2, self.txouts)
|
||||
while len(self.nodes[0].getrawmempool()) > 0:
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
reps += 1
|
||||
self.log.info("Finished splitting")
|
||||
|
||||
|
@ -29,7 +29,7 @@ class LoadblockTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
self.nodes[1].setnetworkactive(state=False)
|
||||
self.generate(self.nodes[0], COINBASE_MATURITY)
|
||||
self.generate(self.nodes[0], COINBASE_MATURITY, sync_fun=self.no_op)
|
||||
|
||||
# Parsing the url of our node to get settings for config file
|
||||
data_dir = self.nodes[0].datadir
|
||||
|
@ -58,7 +58,7 @@ class MinimumChainWorkTest(BitcoinTestFramework):
|
||||
num_blocks_to_generate = int((self.node_min_work[1] - starting_chain_work) / REGTEST_WORK_PER_BLOCK)
|
||||
self.log.info("Generating %d blocks on node0", 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, sync_fun=self.no_op)
|
||||
|
||||
self.log.info("Node0 current chain work: %s", self.nodes[0].getblockheader(hashes[-1])['chainwork'])
|
||||
|
||||
@ -88,7 +88,7 @@ class MinimumChainWorkTest(BitcoinTestFramework):
|
||||
assert ("headers" not in peer.last_message or len(peer.last_message["headers"].headers) == 0)
|
||||
|
||||
self.log.info("Generating one more block")
|
||||
self.generatetoaddress(self.nodes[0], 1, self.nodes[0].get_deterministic_priv_key().address)
|
||||
self.generate(self.nodes[0], 1)
|
||||
|
||||
self.log.info("Verifying nodes are all synced")
|
||||
|
||||
|
@ -116,7 +116,7 @@ class NotificationsTest(DashTestFramework):
|
||||
|
||||
self.log.info("Mine single block, wait for chainlock")
|
||||
self.bump_mocktime(1)
|
||||
tip = self.generate(self.nodes[0], 1)[-1]
|
||||
tip = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[-1]
|
||||
self.wait_for_chainlocked_block_all_nodes(tip)
|
||||
# directory content should equal the chainlocked block hash
|
||||
assert_equal([tip], sorted(os.listdir(self.chainlocknotify_dir)))
|
||||
|
@ -120,9 +120,8 @@ class PruneTest(BitcoinTestFramework):
|
||||
|
||||
def create_big_chain(self):
|
||||
# Start by creating some coinbases we can spend later
|
||||
self.generate(self.nodes[1], 200)
|
||||
self.sync_blocks(self.nodes[0:2])
|
||||
self.generate(self.nodes[0], 150)
|
||||
self.generate(self.nodes[1], 200, sync_fun=lambda: self.sync_blocks(self.nodes[0:2]))
|
||||
self.generate(self.nodes[0], 150, sync_fun=self.no_op)
|
||||
|
||||
# Then mine enough full blocks to create more than 550MiB of data
|
||||
mine_large_blocks(self.nodes[0], 645)
|
||||
@ -220,7 +219,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
self.disconnect_nodes(1, 2)
|
||||
|
||||
self.log.info("Generating new longer chain of 300 more blocks")
|
||||
self.generate(self.nodes[1], 299)
|
||||
self.generate(self.nodes[1], 299, sync_fun=self.no_op)
|
||||
|
||||
self.log.info("Reconnect nodes")
|
||||
self.connect_nodes(0, 1)
|
||||
@ -272,7 +271,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
self.nodes[0].invalidateblock(curchainhash)
|
||||
assert_equal(self.nodes[0].getblockcount(), self.mainchainheight)
|
||||
assert_equal(self.nodes[0].getbestblockhash(), self.mainchainhash2)
|
||||
goalbesthash = self.generate(self.nodes[0], blocks_to_mine)[-1]
|
||||
goalbesthash = self.generate(self.nodes[0], blocks_to_mine, sync_fun=self.no_op)[-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")
|
||||
@ -315,7 +314,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
assert_equal(block1_details["nTx"], len(block1_details["tx"]))
|
||||
|
||||
# mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight)
|
||||
self.generate(node, 6)
|
||||
self.generate(node, 6, sync_fun=self.no_op)
|
||||
assert_equal(node.getblockchaininfo()["blocks"], 1001)
|
||||
|
||||
# prune parameter in the future (block or timestamp) should raise an exception
|
||||
@ -353,7 +352,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
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)
|
||||
self.generate(node, 288)
|
||||
self.generate(node, 288, sync_fun=self.no_op)
|
||||
prune(1000)
|
||||
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"
|
||||
|
@ -77,9 +77,8 @@ class ZMQTestSetupBlock:
|
||||
the generated block's hash, it's (coinbase) transaction id, the raw block or
|
||||
raw transaction data.
|
||||
"""
|
||||
|
||||
def __init__(self, test_framework, node):
|
||||
self.block_hash = test_framework.generate(node, 1)[0]
|
||||
self.block_hash = test_framework.generate(node, 1, sync_fun=test_framework.no_op)[0]
|
||||
coinbase = node.getblock(self.block_hash, 2)['tx'][0]
|
||||
self.tx_hash = coinbase['txid']
|
||||
self.raw_tx = coinbase['hex']
|
||||
@ -261,14 +260,14 @@ class ZMQTest (BitcoinTestFramework):
|
||||
|
||||
# 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)
|
||||
disconnect_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
|
||||
disconnect_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE, sync_fun=self.no_op)[0]
|
||||
disconnect_cb = self.nodes[0].getblock(disconnect_block)["tx"][0]
|
||||
assert_equal(self.nodes[0].getbestblockhash(), hashblock.receive().hex())
|
||||
assert_equal(hashtx.receive().hex(), payment_txid)
|
||||
assert_equal(hashtx.receive().hex(), disconnect_cb)
|
||||
|
||||
# Generate 2 blocks in nodes[1] to a different address to ensure split
|
||||
connect_blocks = self.generatetoaddress(self.nodes[1], 2, ADDRESS_BCRT1_P2SH_OP_TRUE)
|
||||
connect_blocks = self.generatetoaddress(self.nodes[1], 2, ADDRESS_BCRT1_P2SH_OP_TRUE, sync_fun=self.no_op)
|
||||
|
||||
# nodes[0] will reorg chain after connecting back nodes[1]
|
||||
self.connect_nodes(0, 1)
|
||||
@ -312,13 +311,13 @@ class ZMQTest (BitcoinTestFramework):
|
||||
seq_num = 1
|
||||
|
||||
# Generate 1 block in nodes[0] and receive all notifications
|
||||
dc_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
|
||||
dc_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE, sync_fun=self.no_op)[0]
|
||||
|
||||
# Note: We are not notified of any block transactions, coinbase or mined
|
||||
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
|
||||
self.generatetoaddress(self.nodes[1], 2, ADDRESS_BCRT1_P2SH_OP_TRUE)
|
||||
self.generatetoaddress(self.nodes[1], 2, ADDRESS_BCRT1_P2SH_OP_TRUE, sync_fun=self.no_op)
|
||||
|
||||
# nodes[0] will reorg chain after connecting back nodes[1]
|
||||
self.connect_nodes(0, 1)
|
||||
@ -458,7 +457,7 @@ class ZMQTest (BitcoinTestFramework):
|
||||
# 1) Consume backlog until we get a mempool sequence number
|
||||
(hash_str, label, zmq_mem_seq) = seq.receive_sequence()
|
||||
while zmq_mem_seq is None:
|
||||
(hash_str, label, zmq_mem_seq) = seq.receive_sequence()
|
||||
(hash_str, label, zmq_mem_seq) = seq.receive_sequence()
|
||||
|
||||
assert label == "A" or label == "R"
|
||||
assert hash_str is not None
|
||||
@ -548,7 +547,7 @@ class ZMQTest (BitcoinTestFramework):
|
||||
], sync_blocks=False)
|
||||
|
||||
# Generate 1 block in nodes[0] and receive all notifications
|
||||
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
|
||||
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE, sync_fun=self.no_op)
|
||||
|
||||
# Should receive the same block hash on both subscribers
|
||||
assert_equal(self.nodes[0].getbestblockhash(), subscribers[0].receive().hex())
|
||||
|
@ -41,8 +41,8 @@ class MempoolCompatibilityTest(BitcoinTestFramework):
|
||||
|
||||
old_node, new_node = self.nodes
|
||||
new_wallet = MiniWallet(new_node)
|
||||
self.generate(new_wallet, 1)
|
||||
self.generate(new_node, 100)
|
||||
self.generate(new_wallet, 1, sync_fun=self.no_op)
|
||||
self.generate(new_node, 100, sync_fun=self.no_op)
|
||||
# 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
|
||||
# unbroadcasted_tx won't pass old_node's `MemPoolAccept::PreChecks`.
|
||||
|
@ -173,7 +173,7 @@ class MempoolPersistTest(BitcoinTestFramework):
|
||||
self.start_node(0)
|
||||
|
||||
# clear out mempool
|
||||
self.generate(node0, 1)
|
||||
self.generate(node0, 1, sync_fun=self.no_op)
|
||||
|
||||
# ensure node0 doesn't have any connections
|
||||
# make a transaction that will remain in the unbroadcast set
|
||||
|
@ -79,9 +79,8 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
|
||||
spend_3_1_id = self.nodes[0].sendrawtransaction(spend_3_1['hex'])
|
||||
self.log.info("Generate a block")
|
||||
last_block = self.generate(self.nodes[0], 1)
|
||||
# Sync blocks, so that peer 1 gets the block before timelock_tx
|
||||
# generate() implicitly syncs blocks, so that peer 1 gets the block before timelock_tx
|
||||
# Otherwise, peer 1 would put the timelock_tx in m_recent_rejects
|
||||
self.sync_all()
|
||||
|
||||
self.log.info("The time-locked transaction can now be spent")
|
||||
timelock_tx_id = self.nodes[0].sendrawtransaction(timelock_tx)
|
||||
|
@ -111,7 +111,8 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
|
||||
# a block
|
||||
removal_reason = "Removed {} from set of unbroadcast txns before confirmation that txn was sent out".format(txhsh)
|
||||
with node.assert_debug_log([removal_reason]):
|
||||
self.generate(node, 1)
|
||||
self.generate(node, 1, sync_fun=self.no_op)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
MempoolUnbroadcastTest().main()
|
||||
|
@ -52,7 +52,7 @@ class MiningTest(BitcoinTestFramework):
|
||||
self.log.info('Create some old blocks')
|
||||
for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 156, 156):
|
||||
self.bump_mocktime(156)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
mining_info = self.nodes[0].getmininginfo()
|
||||
assert_equal(mining_info['blocks'], 200)
|
||||
assert_equal(mining_info['currentblocktx'], 0)
|
||||
|
@ -99,7 +99,7 @@ class PrioritiseTransactionTest(BitcoinTestFramework):
|
||||
# the other high fee transactions. Keep mining until our mempool has
|
||||
# decreased by all the high fee size that we calculated above.
|
||||
while (self.nodes[0].getmempoolinfo()['bytes'] > sizes[0] + sizes[1]):
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
|
||||
# High fee transaction should not have been mined, but other high fee rate
|
||||
# transactions should have been.
|
||||
|
@ -62,11 +62,11 @@ class CompactFiltersTest(BitcoinTestFramework):
|
||||
# Stale blocks by disconnecting nodes 0 & 1, mining, then reconnecting
|
||||
self.disconnect_nodes(0, 1)
|
||||
|
||||
stale_block_hash = self.generate(self.nodes[0], 1)[0]
|
||||
stale_block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
|
||||
self.nodes[0].syncwithvalidationinterfacequeue()
|
||||
assert_equal(self.nodes[0].getblockcount(), 1000)
|
||||
|
||||
self.generate(self.nodes[1], 1001)
|
||||
self.generate(self.nodes[1], 1001, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[1].getblockcount(), 2000)
|
||||
|
||||
# Check that nodes have signalled NODE_COMPACT_FILTERS correctly.
|
||||
|
@ -32,7 +32,7 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
|
||||
self.sync_all()
|
||||
|
||||
def build_block_on_tip(self):
|
||||
blockhash = self.generate(self.nodes[2], 1)[0]
|
||||
blockhash = self.generate(self.nodes[2], 1, sync_fun=self.no_op)[0]
|
||||
block_hex = self.nodes[2].getblock(blockhash=blockhash, verbosity=0)
|
||||
block = from_hex(CBlock(), block_hex)
|
||||
block.rehash()
|
||||
|
@ -57,7 +57,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
|
||||
|
||||
self.log.info("Mine enough blocks to reach the NODE_NETWORK_LIMITED range.")
|
||||
self.connect_nodes(0, 1)
|
||||
blocks = self.generatetoaddress(self.nodes[1], 292, self.nodes[1].get_deterministic_priv_key().address)
|
||||
blocks = self.generate(self.nodes[1], 292, sync_fun=self.no_op)
|
||||
self.sync_blocks([self.nodes[0], self.nodes[1]])
|
||||
|
||||
self.log.info("Make sure we can max retrieve block at tip-288.")
|
||||
@ -89,7 +89,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
|
||||
self.disconnect_all()
|
||||
|
||||
# mine 10 blocks on node 0 (pruned node)
|
||||
self.generatetoaddress(self.nodes[0], 10, self.nodes[0].get_deterministic_priv_key().address)
|
||||
self.generate(self.nodes[0], 10, sync_fun=self.no_op)
|
||||
|
||||
# connect node1 (non pruned) with node0 (pruned) and check if the can sync
|
||||
self.connect_nodes(0, 1)
|
||||
|
@ -73,7 +73,7 @@ class AcceptBlockTest(BitcoinTestFramework):
|
||||
min_work_node = self.nodes[1].add_p2p_connection(P2PInterface())
|
||||
|
||||
# 1. Have nodes mine a block (leave IBD)
|
||||
[self.generatetoaddress(n, 1, n.get_deterministic_priv_key().address) for n in self.nodes]
|
||||
[self.generate(n, 1, sync_fun=self.no_op) for n in self.nodes]
|
||||
tips = [int("0x" + n.getbestblockhash(), 0) for n in self.nodes]
|
||||
|
||||
# 2. Send one block that builds on each tip.
|
||||
|
@ -352,7 +352,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
self.log.debug('Node should not stop at this height')
|
||||
assert_raises(subprocess.TimeoutExpired, lambda: self.nodes[0].process.wait(timeout=3))
|
||||
try:
|
||||
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_P2SH_OP_TRUE)
|
||||
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_P2SH_OP_TRUE, sync_fun=self.no_op)
|
||||
except (ConnectionError, http.client.BadStatusLine):
|
||||
pass # The node already shut down before response
|
||||
self.log.debug('Node should stop at this height...')
|
||||
|
@ -21,8 +21,8 @@ class GetBlockFilterTest(BitcoinTestFramework):
|
||||
# Create two chains by disconnecting nodes 0 & 1, mining, then reconnecting
|
||||
self.disconnect_nodes(0, 1)
|
||||
|
||||
self.generate(self.nodes[0], 3)
|
||||
self.generate(self.nodes[1], 4)
|
||||
self.generate(self.nodes[0], 3, sync_fun=self.no_op)
|
||||
self.generate(self.nodes[1], 4, sync_fun=self.no_op)
|
||||
|
||||
assert_equal(self.nodes[0].getblockcount(), 3)
|
||||
chain0_hashes = [self.nodes[0].getblockhash(block_height) for block_height in range(4)]
|
||||
|
@ -27,11 +27,11 @@ class GetBlockFromPeerTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
self.log.info("Mine 4 blocks on Node 0")
|
||||
self.generate(self.nodes[0], 4)
|
||||
self.generate(self.nodes[0], 4, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[0].getblockcount(), 204)
|
||||
|
||||
self.log.info("Mine competing 3 blocks on Node 1")
|
||||
self.generate(self.nodes[1], 3)
|
||||
self.generate(self.nodes[1], 3, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[1].getblockcount(), 203)
|
||||
short_tip = self.nodes[1].getbestblockhash()
|
||||
|
||||
|
@ -26,10 +26,8 @@ class GetChainTipsTest (BitcoinTestFramework):
|
||||
|
||||
# Split the network and build two chains of different lengths.
|
||||
self.split_network()
|
||||
self.generatetoaddress(self.nodes[0], 10, self.nodes[0].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.generate(self.nodes[0], 10, sync_fun=lambda: self.sync_all(self.nodes[:2]))
|
||||
self.generate(self.nodes[2], 20, sync_fun=lambda: self.sync_all(self.nodes[2:]))
|
||||
|
||||
tips = self.nodes[1].getchaintips ()
|
||||
assert_equal (len (tips), 1)
|
||||
|
@ -23,12 +23,12 @@ class InvalidateTest(BitcoinTestFramework):
|
||||
def run_test(self):
|
||||
self.log.info("Make sure we repopulate setBlockIndexCandidates after InvalidateBlock:")
|
||||
self.log.info("Mine 4 blocks on Node 0")
|
||||
self.generatetoaddress(self.nodes[0], 4, self.nodes[0].get_deterministic_priv_key().address)
|
||||
self.generate(self.nodes[0], 4, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[0].getblockcount(), 4)
|
||||
besthash_n0 = self.nodes[0].getbestblockhash()
|
||||
|
||||
self.log.info("Mine competing 6 blocks on Node 1")
|
||||
self.generatetoaddress(self.nodes[1], 6, self.nodes[1].get_deterministic_priv_key().address)
|
||||
self.generate(self.nodes[1], 6, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[1].getblockcount(), 6)
|
||||
|
||||
self.log.info("Connect nodes to force a reorg")
|
||||
@ -54,7 +54,7 @@ class InvalidateTest(BitcoinTestFramework):
|
||||
self.nodes[2].invalidateblock(self.nodes[2].getblockhash(3))
|
||||
assert_equal(self.nodes[2].getblockcount(), 2)
|
||||
self.log.info("..and then mine a block")
|
||||
self.generatetoaddress(self.nodes[2], 1, self.nodes[2].get_deterministic_priv_key().address)
|
||||
self.generate(self.nodes[2], 1, sync_fun=self.no_op)
|
||||
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[0].getblockcount() == 4, timeout=5)
|
||||
@ -64,13 +64,12 @@ class InvalidateTest(BitcoinTestFramework):
|
||||
self.restart_node(0, extra_args=["-checkblocks=5"])
|
||||
self.restart_node(1, extra_args=["-checkblocks=5"])
|
||||
self.connect_nodes(0, 1)
|
||||
self.generate(self.nodes[0], 10)
|
||||
self.sync_blocks(self.nodes[0:2])
|
||||
self.generate(self.nodes[0], 10, sync_fun=lambda: self.sync_blocks(self.nodes[0:2]))
|
||||
newheight = self.nodes[0].getblockcount()
|
||||
for j in range(2):
|
||||
self.restart_node(0, extra_args=["-checkblocks=5"])
|
||||
tip = self.generate(self.nodes[0], 10)[-1]
|
||||
self.generate(self.nodes[1], 9)
|
||||
tip = self.generate(self.nodes[0], 10, sync_fun=self.no_op)[-1]
|
||||
self.generate(self.nodes[1], 9, sync_fun=self.no_op)
|
||||
self.connect_nodes(0, 1)
|
||||
self.sync_blocks(self.nodes[0:2])
|
||||
assert_equal(self.nodes[0].getblockcount(), newheight + 10 * (j + 1))
|
||||
@ -87,7 +86,7 @@ class InvalidateTest(BitcoinTestFramework):
|
||||
assert_equal(tip, self.nodes[1].getbestblockhash())
|
||||
|
||||
self.log.info("Verify that we reconsider all ancestors as well")
|
||||
blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR)
|
||||
blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
|
||||
# Invalidate the two blocks at the tip
|
||||
self.nodes[1].invalidateblock(blocks[-1])
|
||||
@ -99,7 +98,7 @@ class InvalidateTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
|
||||
|
||||
self.log.info("Verify that we reconsider all descendants")
|
||||
blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR)
|
||||
blocks = self.generatetodescriptor(self.nodes[1], 10, ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[1].getbestblockhash(), blocks[-1])
|
||||
# Invalidate the two blocks at the tip
|
||||
self.nodes[1].invalidateblock(blocks[-2])
|
||||
|
@ -42,19 +42,18 @@ class PreciousTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
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
|
||||
self.generatetoaddress(self.nodes[0], 1, gen_address(0))
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[0].getblockcount(), 1)
|
||||
hashZ = self.generatetoaddress(self.nodes[1], 2, gen_address(1))[-1]
|
||||
hashZ = self.generate(self.nodes[1], 2, sync_fun=self.no_op)[-1]
|
||||
assert_equal(self.nodes[1].getblockcount(), 2)
|
||||
node_sync_via_rpc(self.nodes[0:3])
|
||||
assert_equal(self.nodes[0].getbestblockhash(), hashZ)
|
||||
|
||||
self.log.info("Mine blocks A-B-C on Node 0")
|
||||
hashC = self.generatetoaddress(self.nodes[0], 3, gen_address(0))[-1]
|
||||
hashC = self.generate(self.nodes[0], 3, sync_fun=self.no_op)[-1]
|
||||
assert_equal(self.nodes[0].getblockcount(), 5)
|
||||
self.log.info("Mine competing blocks E-F-G on Node 1")
|
||||
hashG = self.generatetoaddress(self.nodes[1], 3, gen_address(1))[-1]
|
||||
hashG = self.generate(self.nodes[1], 3, sync_fun=self.no_op)[-1]
|
||||
assert_equal(self.nodes[1].getblockcount(), 5)
|
||||
assert hashC != hashG
|
||||
self.log.info("Connect nodes and check no reorg occurs")
|
||||
@ -83,7 +82,7 @@ class PreciousTest(BitcoinTestFramework):
|
||||
self.nodes[1].preciousblock(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.generatetoaddress(self.nodes[0], 1, gen_address(0))
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[0].getblockcount(), 6)
|
||||
self.sync_blocks(self.nodes[0:2])
|
||||
hashH = self.nodes[0].getbestblockhash()
|
||||
@ -92,7 +91,7 @@ class PreciousTest(BitcoinTestFramework):
|
||||
self.nodes[1].preciousblock(hashC)
|
||||
assert_equal(self.nodes[1].getbestblockhash(), hashH)
|
||||
self.log.info("Mine competing blocks I-J-K-L on Node 2")
|
||||
self.generatetoaddress(self.nodes[2], 4, gen_address(2))
|
||||
self.generate(self.nodes[2], 4, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[2].getblockcount(), 6)
|
||||
hashL = self.nodes[2].getbestblockhash()
|
||||
self.log.info("Connect nodes and check no reorg occurs")
|
||||
|
@ -45,7 +45,6 @@ class MerkleBlockTest(BitcoinTestFramework):
|
||||
|
||||
self.generate(self.nodes[0], 1)
|
||||
blockhash = self.nodes[0].getblockhash(chain_height + 1)
|
||||
self.sync_all()
|
||||
|
||||
txlist = []
|
||||
blocktxn = self.nodes[0].getblock(blockhash, True)["tx"]
|
||||
|
@ -18,9 +18,9 @@ class WipeWalletTxesTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
self.log.info("Test that wipewallettxes removes txes and rescanblockchain is able to recover them")
|
||||
self.generate(self.nodes[0], 101)
|
||||
self.generate(self.nodes[0], 101, sync_fun=self.no_op)
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 103)
|
||||
self.nodes[0].wipewallettxes()
|
||||
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 0)
|
||||
|
@ -455,7 +455,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
if not self.disable_mocktime:
|
||||
self.log.debug('Generate a block with current mocktime')
|
||||
self.bump_mocktime(156 * 200, update_schedulers=False)
|
||||
block_hash = self.generate(self.nodes[0], 1)[0]
|
||||
block_hash = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
|
||||
block = self.nodes[0].getblock(blockhash=block_hash, verbosity=0)
|
||||
for n in self.nodes:
|
||||
n.submitblock(block)
|
||||
@ -766,20 +766,27 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
self.connect_nodes(1, 2)
|
||||
self.sync_all()
|
||||
|
||||
def generate(self, generator, *args, **kwargs):
|
||||
def no_op(self):
|
||||
pass
|
||||
|
||||
def generate(self, generator, *args, sync_fun=None, **kwargs):
|
||||
blocks = generator.generate(*args, invalid_call=False, **kwargs)
|
||||
sync_fun() if sync_fun else self.sync_all()
|
||||
return blocks
|
||||
|
||||
def generateblock(self, generator, *args, **kwargs):
|
||||
def generateblock(self, generator, *args, sync_fun=None, **kwargs):
|
||||
blocks = generator.generateblock(*args, invalid_call=False, **kwargs)
|
||||
sync_fun() if sync_fun else self.sync_all()
|
||||
return blocks
|
||||
|
||||
def generatetoaddress(self, generator, *args, **kwargs):
|
||||
def generatetoaddress(self, generator, *args, sync_fun=None, **kwargs):
|
||||
blocks = generator.generatetoaddress(*args, invalid_call=False, **kwargs)
|
||||
sync_fun() if sync_fun else self.sync_all()
|
||||
return blocks
|
||||
|
||||
def generatetodescriptor(self, generator, *args, **kwargs):
|
||||
def generatetodescriptor(self, generator, *args, sync_fun=None, **kwargs):
|
||||
blocks = generator.generatetodescriptor(*args, invalid_call=False, **kwargs)
|
||||
sync_fun() if sync_fun else self.sync_all()
|
||||
return blocks
|
||||
|
||||
def sync_blocks(self, nodes=None, wait=1, timeout=60):
|
||||
@ -1178,23 +1185,19 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
# Hence the last block prior to the activation is (expected_activation_height - 2).
|
||||
while expected_activation_height - height - 2 > batch_size:
|
||||
self.bump_mocktime(batch_size)
|
||||
self.generate(self.nodes[0], batch_size)
|
||||
self.generate(self.nodes[0], batch_size, sync_fun=lambda: self.sync_blocks())
|
||||
height += batch_size
|
||||
self.sync_blocks()
|
||||
blocks_left = expected_activation_height - height - 2
|
||||
assert blocks_left <= batch_size
|
||||
self.bump_mocktime(blocks_left)
|
||||
self.generate(self.nodes[0], blocks_left)
|
||||
self.sync_blocks()
|
||||
self.generate(self.nodes[0], blocks_left, sync_fun=lambda: self.sync_blocks())
|
||||
assert not softfork_active(self.nodes[0], name)
|
||||
self.bump_mocktime(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks()
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks())
|
||||
else:
|
||||
while not softfork_active(self.nodes[0], name):
|
||||
self.bump_mocktime(batch_size)
|
||||
self.generate(self.nodes[0], batch_size)
|
||||
self.sync_blocks()
|
||||
self.generate(self.nodes[0], batch_size, sync_fun=lambda: self.sync_blocks())
|
||||
|
||||
assert softfork_active(self.nodes[0], name)
|
||||
|
||||
@ -1283,7 +1286,6 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
collateral_txid = self.nodes[0].sendmany("", outputs)
|
||||
self.wait_for_instantlock(collateral_txid, self.nodes[0])
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
self.sync_all()
|
||||
|
||||
rawtx = self.nodes[0].getrawtransaction(collateral_txid, 1, tip)
|
||||
assert_equal(rawtx['confirmations'], 1)
|
||||
@ -1305,7 +1307,6 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
|
||||
self.wait_for_instantlock(protx_result, self.nodes[0])
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
|
||||
mn_info = MasternodeInfo(protx_result, owner_address, voting_address, reward_address, operatorReward, bls['public'], bls['secret'], collateral_address, collateral_txid, collateral_vout, ipAndPort, evo)
|
||||
@ -1327,7 +1328,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
|
||||
fund_txid = self.nodes[0].sendtoaddress(funds_address, 1)
|
||||
self.wait_for_instantlock(fund_txid, self.nodes[0])
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
tip = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
|
||||
assert_equal(self.nodes[0].getrawtransaction(fund_txid, 1, tip)['confirmations'], 1)
|
||||
self.sync_all()
|
||||
|
||||
@ -1335,7 +1336,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
try:
|
||||
protx_result = self.nodes[0].protx('update_service_evo', evo_info.proTxHash, evo_info.addr, evo_info.keyOperator, platform_node_id, platform_p2p_port, platform_http_port, operator_reward_address, funds_address)
|
||||
self.wait_for_instantlock(protx_result, self.nodes[0])
|
||||
tip = self.generate(self.nodes[0], 1)[0]
|
||||
tip = self.generate(self.nodes[0], 1, sync_fun=self.no_op)[0]
|
||||
assert_equal(self.nodes[0].getrawtransaction(protx_result, 1, tip)['confirmations'], 1)
|
||||
self.sync_all()
|
||||
self.log.info("Updated EvoNode %s: platformNodeID=%s, platformP2PPort=%s, platformHTTPPort=%s" % (evo_info.proTxHash, platform_node_id, platform_p2p_port, platform_http_port))
|
||||
@ -1487,7 +1488,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.log.info("Generating %d coins" % required_balance)
|
||||
while self.nodes[0].getbalance() < required_balance:
|
||||
self.bump_mocktime(1)
|
||||
self.generate(self.nodes[0], 10)
|
||||
self.generate(self.nodes[0], 10, sync_fun=self.no_op)
|
||||
|
||||
# create masternodes
|
||||
self.prepare_masternodes()
|
||||
@ -1506,8 +1507,6 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
|
||||
self.bump_mocktime(1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
# sync nodes
|
||||
self.sync_all()
|
||||
for i in range(0, num_simple_nodes):
|
||||
force_finish_mnsync(self.nodes[i + 1])
|
||||
|
||||
@ -1780,8 +1779,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if quorum_hash in self.nodes[0].quorum("list")[llmq_type_name]:
|
||||
return True
|
||||
self.bump_mocktime(sleep, nodes=nodes)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
return False
|
||||
wait_until_helper(wait_func, timeout=timeout, sleep=sleep)
|
||||
|
||||
@ -1792,15 +1790,13 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if quorum_hash_1 in self.nodes[0].quorum("list")[llmq_type_name]:
|
||||
return True
|
||||
self.bump_mocktime(sleep, nodes=nodes)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
return False
|
||||
wait_until_helper(wait_func, timeout=timeout, sleep=sleep)
|
||||
|
||||
def move_blocks(self, nodes, num_blocks):
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.generate(self.nodes[0], num_blocks)
|
||||
self.sync_blocks(nodes)
|
||||
self.generate(self.nodes[0], num_blocks, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
|
||||
def mine_quorum(self, llmq_type_name="llmq_test", llmq_type=100, expected_connections=None, expected_members=None, expected_contributions=None, expected_complaints=0, expected_justifications=0, expected_commitments=None, mninfos_online=None, mninfos_valid=None):
|
||||
spork21_active = self.nodes[0].spork('show')['SPORK_21_QUORUM_ALL_CONNECTED'] <= 1
|
||||
@ -1829,7 +1825,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
skip_count = 24 - (self.nodes[0].getblockcount() % 24)
|
||||
if skip_count != 0:
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.generate(self.nodes[0], skip_count)
|
||||
self.generate(self.nodes[0], skip_count, sync_fun=self.no_op)
|
||||
self.sync_blocks(nodes)
|
||||
|
||||
q = self.nodes[0].getbestblockhash()
|
||||
@ -1871,8 +1867,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.log.info("Mining final commitment")
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].getblocktemplate() # this calls CreateNewBlock
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
|
||||
self.log.info("Waiting for quorum to appear in the list")
|
||||
self.wait_for_quorum_list(q, nodes, llmq_type_name=llmq_type_name)
|
||||
@ -1882,9 +1877,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
quorum_info = self.nodes[0].quorum("info", llmq_type, new_quorum)
|
||||
|
||||
# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks to make sure that the new quorum gets eligible for signing sessions
|
||||
self.generate(self.nodes[0], 8)
|
||||
|
||||
self.sync_blocks(nodes)
|
||||
self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
|
||||
self.log.info("New quorum: height=%d, quorumHash=%s, quorumIndex=%d, minedBlock=%s" % (quorum_info["height"], new_quorum, quorum_info["quorumIndex"], quorum_info["minedBlock"]))
|
||||
|
||||
@ -1992,8 +1985,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
self.log.info("Mining final commitments")
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.nodes[0].getblocktemplate() # this calls CreateNewBlock
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(nodes)
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
|
||||
self.log.info("Waiting for quorum(s) to appear in the list")
|
||||
self.wait_for_quorums_list(q_0, q_1, nodes, llmq_type_name)
|
||||
@ -2001,9 +1993,8 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
quorum_info_0 = self.nodes[0].quorum("info", llmq_type, q_0)
|
||||
quorum_info_1 = self.nodes[0].quorum("info", llmq_type, q_1)
|
||||
# Mine 8 (SIGN_HEIGHT_OFFSET) more blocks to make sure that the new quorum gets eligible for signing sessions
|
||||
self.generate(self.nodes[0], 8)
|
||||
self.generate(self.nodes[0], 8, sync_fun=lambda: self.sync_blocks(nodes))
|
||||
|
||||
self.sync_blocks(nodes)
|
||||
self.log.info("New quorum: height=%d, quorumHash=%s, quorumIndex=%d, minedBlock=%s" % (quorum_info_0["height"], q_0, quorum_info_0["quorumIndex"], quorum_info_0["minedBlock"]))
|
||||
self.log.info("New quorum: height=%d, quorumHash=%s, quorumIndex=%d, minedBlock=%s" % (quorum_info_1["height"], q_1, quorum_info_1["quorumIndex"], quorum_info_1["minedBlock"]))
|
||||
|
||||
@ -2027,7 +2018,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
skip_count = cycle_length - (cur_block % cycle_length)
|
||||
if skip_count != 0:
|
||||
self.bump_mocktime(1, nodes=nodes)
|
||||
self.generate(self.nodes[0], skip_count)
|
||||
self.generate(self.nodes[0], skip_count, sync_fun=self.no_op)
|
||||
self.sync_blocks(nodes)
|
||||
self.log.info('Moved from block %d to %d' % (cur_block, self.nodes[0].getblockcount()))
|
||||
|
||||
@ -2089,8 +2080,7 @@ class DashTestFramework(BitcoinTestFramework):
|
||||
if recover:
|
||||
if self.mocktime % 2:
|
||||
self.bump_mocktime(self.quorum_data_request_expiration_timeout + 1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks()
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks())
|
||||
else:
|
||||
self.bump_mocktime(self.quorum_data_thread_request_timeout_seconds + 1)
|
||||
|
||||
|
@ -514,10 +514,10 @@ def find_output(node, txid, amount, *, blockhash=None):
|
||||
|
||||
# Helper to create at least "count" utxos
|
||||
# Pass in a fee that is sufficient for relay and mining new transactions.
|
||||
def create_confirmed_utxos(test_framework, fee, node, count):
|
||||
def create_confirmed_utxos(test_framework, fee, node, count, **kwargs):
|
||||
to_generate = int(0.5 * count) + 101
|
||||
while to_generate > 0:
|
||||
test_framework.generate(node, min(25, to_generate))
|
||||
test_framework.generate(node, min(25, to_generate), **kwargs)
|
||||
to_generate -= 25
|
||||
utxos = node.listunspent()
|
||||
iterations = count - len(utxos)
|
||||
@ -538,7 +538,7 @@ def create_confirmed_utxos(test_framework, fee, node, count):
|
||||
node.sendrawtransaction(signed_tx)
|
||||
|
||||
while (node.getmempoolinfo()['size'] > 0):
|
||||
test_framework.generate(node, 1)
|
||||
test_framework.generate(node, 1, **kwargs)
|
||||
|
||||
utxos = node.listunspent()
|
||||
assert len(utxos) >= count
|
||||
|
@ -43,7 +43,6 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||
# Can not abandon confirmed transaction
|
||||
assert_raises_rpc_error(-5, 'Transaction not eligible for abandonment', lambda: self.nodes[0].abandontransaction(txid=txA))
|
||||
|
||||
self.sync_blocks()
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
assert balance - newbalance < Decimal("0.001") #no more than fees lost
|
||||
balance = newbalance
|
||||
@ -167,7 +166,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||
tx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||
signed = self.nodes[0].signrawtransactionwithwallet(tx)
|
||||
self.nodes[1].sendrawtransaction(signed["hex"])
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
|
||||
self.connect_nodes(0, 1)
|
||||
self.sync_blocks()
|
||||
|
@ -269,7 +269,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
self.nodes[0].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
|
||||
self.generatetoaddress(self.nodes[0], 1, ADDRESS_WATCHONLY)
|
||||
self.generatetoaddress(self.nodes[0], 1, ADDRESS_WATCHONLY, sync_fun=self.no_op)
|
||||
assert_equal(self.nodes[0].getbalance(minconf=0), 0) # wallet txs not in the mempool are untrusted
|
||||
|
||||
# Now confirm tx_orig
|
||||
|
@ -66,15 +66,14 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
self.log.info("Mining blocks...")
|
||||
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
|
||||
walletinfo = self.nodes[0].getwalletinfo()
|
||||
assert_equal(walletinfo['immature_balance'], 500)
|
||||
assert_equal(walletinfo['balance'], 0)
|
||||
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY + 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 500)
|
||||
assert_equal(self.nodes[1].getbalance(), 500)
|
||||
@ -124,8 +123,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
assert_equal(walletinfo['immature_balance'], 0)
|
||||
|
||||
# Have node0 mine a block, thus it will collect its own fee.
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
|
||||
# Exercise locking of unspent outputs
|
||||
unspent_0 = self.nodes[2].listunspent()[0]
|
||||
@ -168,8 +166,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
assert_equal(len(self.nodes[1].listlockunspent()), 0)
|
||||
|
||||
# Have node1 generate 100 blocks (so node0 can recover the fee)
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
|
||||
# node0 should end up with 1000 DASH in block rewards plus fees, but
|
||||
# minus the 210 plus fees sent to node2
|
||||
@ -200,8 +197,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
self.nodes[1].sendrawtransaction(hexstring=txns_to_send[1]["hex"], maxfeerate=0)
|
||||
|
||||
# Have node1 mine a block to confirm transactions:
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
|
||||
assert_equal(self.nodes[0].getbalance(), 0)
|
||||
assert_equal(self.nodes[2].getbalance(), 1000 - totalfee)
|
||||
@ -215,15 +211,13 @@ class WalletTest(BitcoinTestFramework):
|
||||
fee_per_byte = Decimal('0.00001') / 1000
|
||||
self.nodes[2].settxfee(fee_per_byte * 1000)
|
||||
txid = self.nodes[2].sendtoaddress(address, 100, "", "", False)
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('900') - totalfee, fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex']))
|
||||
assert_equal(self.nodes[0].getbalance(), Decimal('100'))
|
||||
|
||||
# Send 100 DASH with subtract fee from amount
|
||||
txid = self.nodes[2].sendtoaddress(address, 100, "", "", True)
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
node_2_bal -= Decimal('100')
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), Decimal('200'), fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex']))
|
||||
@ -232,16 +226,14 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
# Sendmany 100 DASH
|
||||
txid = self.nodes[2].sendmany('', {address: 100}, 0, False, "", [])
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
node_0_bal += Decimal('100')
|
||||
node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('100'), fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex']))
|
||||
assert_equal(self.nodes[0].getbalance(), node_0_bal)
|
||||
|
||||
# Sendmany 100 DASH with subtract fee from amount
|
||||
txid = self.nodes[2].sendmany('', {address: 100}, 0, False, "", [address])
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
node_2_bal -= Decimal('100')
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('100'), fee_per_byte, count_bytes(self.nodes[2].gettransaction(txid)['hex']))
|
||||
@ -253,8 +245,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
# Test passing fee_rate as a string
|
||||
txid = self.nodes[2].sendmany(amounts={address: 10}, fee_rate=str(fee_rate_sat_vb))
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
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']))
|
||||
assert_equal(balance, node_2_bal)
|
||||
@ -264,8 +255,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
# Test passing fee_rate as an integer
|
||||
amount = Decimal("0.0001")
|
||||
txid = self.nodes[2].sendmany(amounts={address: amount}, fee_rate=fee_rate_sat_vb)
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
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']))
|
||||
assert_equal(balance, node_2_bal)
|
||||
@ -327,7 +317,6 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
self.sync_all()
|
||||
self.generate(self.nodes[1], 1) # mine a block
|
||||
self.sync_all()
|
||||
|
||||
unspent_txs = self.nodes[0].listunspent() # zero value tx must be in listunspents output
|
||||
found = False
|
||||
@ -349,14 +338,12 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
txid_not_broadcast = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 2)
|
||||
tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast)
|
||||
self.generate(self.nodes[1], 1) # mine a block, tx should not be in there
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) # mine a block, tx should not be in there
|
||||
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
|
||||
self.nodes[1].sendrawtransaction(tx_obj_not_broadcast['hex'])
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[1], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
node_2_bal += 2
|
||||
tx_obj_not_broadcast = self.nodes[0].gettransaction(txid_not_broadcast)
|
||||
assert_equal(self.nodes[2].getbalance(), node_2_bal)
|
||||
@ -374,8 +361,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
self.connect_nodes(0, 2)
|
||||
self.sync_blocks(self.nodes[0:3])
|
||||
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(self.nodes[0:3])
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:3]))
|
||||
node_2_bal += 2
|
||||
|
||||
# tx should be added to balance because after restarting the nodes tx should be broadcast
|
||||
@ -436,8 +422,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
# 1. Send some coins to generate new UTXO
|
||||
address_to_import = self.nodes[2].getnewaddress()
|
||||
txid = self.nodes[0].sendtoaddress(address_to_import, 1)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
|
||||
self.log.info("Test sendtoaddress with fee_rate param (explicit fee rate in duff/B)")
|
||||
prebalance = self.nodes[2].getbalance()
|
||||
@ -449,8 +434,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
# Test passing fee_rate as an integer
|
||||
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'])
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
postbalance = self.nodes[2].getbalance()
|
||||
fee = prebalance - postbalance - Decimal(amount)
|
||||
assert_fee_amount(fee, tx_size, Decimal(fee_rate_btc_kvb))
|
||||
@ -462,7 +446,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
# Test passing fee_rate as a string
|
||||
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'])
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
self.sync_all(self.nodes[0:3])
|
||||
postbalance = self.nodes[2].getbalance()
|
||||
fee = prebalance - postbalance - amount
|
||||
@ -526,17 +510,15 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
# Mine a block from node0 to an address from node1
|
||||
coinbase_addr = self.nodes[1].getnewaddress()
|
||||
block_hash = self.generatetoaddress(self.nodes[0], 1, coinbase_addr)[0]
|
||||
block_hash = self.generatetoaddress(self.nodes[0], 1, coinbase_addr, sync_fun=lambda: self.sync_all(self.nodes[0:3]))[0]
|
||||
coinbase_txid = self.nodes[0].getblock(block_hash)['tx'][0]
|
||||
self.sync_all(self.nodes[0:3])
|
||||
|
||||
# Check that the txid and balance is found by node1
|
||||
self.nodes[1].gettransaction(coinbase_txid)
|
||||
|
||||
# check if wallet or blockchain maintenance changes the balance
|
||||
self.sync_all(self.nodes[0:3])
|
||||
blocks = self.generate(self.nodes[0], 2)
|
||||
self.sync_all(self.nodes[0:3])
|
||||
blocks = self.generate(self.nodes[0], 2, sync_fun=lambda: self.sync_all(self.nodes[0:3]))
|
||||
balance_nodes = [self.nodes[i].getbalance() for i in range(3)]
|
||||
block_count = self.nodes[0].getblockcount()
|
||||
|
||||
@ -583,13 +565,13 @@ class WalletTest(BitcoinTestFramework):
|
||||
# Get all non-zero utxos together
|
||||
chain_addrs = [self.nodes[0].getnewaddress(), self.nodes[0].getnewaddress()]
|
||||
singletxid = self.nodes[0].sendtoaddress(chain_addrs[0], self.nodes[0].getbalance(), "", "", True)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
node0_balance = self.nodes[0].getbalance()
|
||||
# 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')})
|
||||
signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx)
|
||||
singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0)
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
|
||||
# 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
|
||||
@ -640,7 +622,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
assert not address_info["ischange"]
|
||||
|
||||
# Test getaddressinfo 'ischange' field on change address.
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
destination = self.nodes[1].getnewaddress()
|
||||
txid = self.nodes[0].sendtoaddress(destination, 0.123)
|
||||
tx = self.nodes[0].decoderawtransaction(self.nodes[0].gettransaction(txid)['hex'])
|
||||
|
@ -169,7 +169,6 @@ class ImportRescanTest(BitcoinTestFramework):
|
||||
self.generate(self.nodes[0], 1) # Generate one block for each send
|
||||
variant.confirmation_height = self.nodes[0].getblockcount()
|
||||
variant.timestamp = self.nodes[0].getblockheader(self.nodes[0].getbestblockhash())["time"]
|
||||
self.sync_all() # Conclude sync before calling setmocktime to avoid timeouts
|
||||
|
||||
# Generate a block further in the future (past the rescan window).
|
||||
assert_equal(self.nodes[0].getrawmempool(), [])
|
||||
|
@ -61,8 +61,8 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
def run_test(self):
|
||||
self.log.info("Mining blocks...")
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||
|
||||
node0_address1 = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
||||
@ -254,9 +254,9 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
# P2SH address
|
||||
multisig = get_multisig(self.nodes[0])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY)
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=self.no_op)
|
||||
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||
|
||||
self.log.info("Should import a p2sh")
|
||||
@ -274,9 +274,9 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
# P2SH + Redeem script
|
||||
multisig = get_multisig(self.nodes[0])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY)
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=self.no_op)
|
||||
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||
|
||||
self.log.info("Should import a p2sh with respective redeem script")
|
||||
@ -294,9 +294,9 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
# P2SH + Redeem script + Private Keys + !Watchonly
|
||||
multisig = get_multisig(self.nodes[0])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY)
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=self.no_op)
|
||||
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||
|
||||
self.log.info("Should import a p2sh with respective redeem script and private keys")
|
||||
@ -319,9 +319,9 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||
|
||||
# P2SH + Redeem script + Private Keys + Watchonly
|
||||
multisig = get_multisig(self.nodes[0])
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY)
|
||||
self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=self.no_op)
|
||||
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
timestamp = self.nodes[1].getblock(self.nodes[1].getbestblockhash())['mediantime']
|
||||
|
||||
self.log.info("Should import a p2sh with respective redeem script and private keys")
|
||||
|
@ -31,7 +31,6 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
# only one connection. (See fPreferredDownload in net_processing)
|
||||
self.connect_nodes(1, 2)
|
||||
self.generate(self.nodes[2], COINBASE_MATURITY + 1)
|
||||
self.sync_all()
|
||||
|
||||
self.test_no_blockhash()
|
||||
self.test_invalid_blockhash()
|
||||
@ -46,7 +45,6 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
txid = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||
blockhash, = self.generate(self.nodes[2], 1)
|
||||
blockheight = self.nodes[2].getblockheader(blockhash)['height']
|
||||
self.sync_all()
|
||||
|
||||
txs = self.nodes[0].listtransactions()
|
||||
assert_array_result(txs, {"txid": txid}, {
|
||||
@ -88,7 +86,6 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
self.log.info("Test target_confirmations")
|
||||
blockhash, = self.generate(self.nodes[2], 1)
|
||||
blockheight = self.nodes[2].getblockheader(blockhash)['height']
|
||||
self.sync_all()
|
||||
|
||||
assert_equal(
|
||||
self.nodes[0].getblockhash(0),
|
||||
@ -136,14 +133,11 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
senttx = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||
|
||||
# generate on both sides
|
||||
nodes1_last_blockhash = self.generate(self.nodes[1], 6)[-1]
|
||||
nodes2_first_blockhash = self.generate(self.nodes[2], 7)[0]
|
||||
nodes1_last_blockhash = self.generate(self.nodes[1], 6, sync_fun=lambda: self.sync_all(self.nodes[:2]))[-1]
|
||||
nodes2_first_blockhash = self.generate(self.nodes[2], 7, sync_fun=lambda: self.sync_all(self.nodes[2:]))[0]
|
||||
self.log.debug("nodes[1] last blockhash = {}".format(nodes1_last_blockhash))
|
||||
self.log.debug("nodes[2] first blockhash = {}".format(nodes2_first_blockhash))
|
||||
|
||||
self.sync_all(self.nodes[:2])
|
||||
self.sync_all(self.nodes[2:])
|
||||
|
||||
self.join_network()
|
||||
|
||||
# listsinceblock(nodes1_last_blockhash) should now include tx as seen from nodes[0]
|
||||
@ -192,7 +186,6 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
address = key_to_p2pkh(eckey.get_pubkey().get_bytes())
|
||||
self.nodes[2].sendtoaddress(address, 10)
|
||||
self.generate(self.nodes[2], 6)
|
||||
self.sync_all()
|
||||
self.nodes[2].importprivkey(privkey)
|
||||
utxos = self.nodes[2].listunspent()
|
||||
utxo = [u for u in utxos if u["address"] == address][0]
|
||||
@ -225,8 +218,8 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
self.nodes[2].createrawtransaction(utxo_dicts, recipient_dict2))['hex'])
|
||||
|
||||
# generate on both sides
|
||||
lastblockhash = self.generate(self.nodes[1], 3)[2]
|
||||
self.generate(self.nodes[2], 4)
|
||||
lastblockhash = self.generate(self.nodes[1], 3, sync_fun=self.no_op)[2]
|
||||
self.generate(self.nodes[2], 4, sync_fun=self.no_op)
|
||||
|
||||
self.join_network()
|
||||
|
||||
@ -297,7 +290,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
txid1 = self.nodes[1].sendrawtransaction(signedtx)
|
||||
|
||||
# generate bb1-bb2 on right side
|
||||
self.generate(self.nodes[2], 2)
|
||||
self.generate(self.nodes[2], 2, sync_fun=self.no_op)
|
||||
|
||||
# send from nodes[2]; this will end up in bb3
|
||||
txid2 = self.nodes[2].sendrawtransaction(signedtx)
|
||||
@ -305,8 +298,8 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
assert_equal(txid1, txid2)
|
||||
|
||||
# generate on both sides
|
||||
lastblockhash = self.generate(self.nodes[1], 3)[2]
|
||||
self.generate(self.nodes[2], 2)
|
||||
lastblockhash = self.generate(self.nodes[1], 3, sync_fun=self.no_op)[2]
|
||||
self.generate(self.nodes[2], 2, sync_fun=self.no_op)
|
||||
|
||||
self.join_network()
|
||||
|
||||
@ -360,7 +353,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
double_signedtx = spending_node.signrawtransactionwithwallet(double_rawtx)
|
||||
dbl_tx_id = double_spending_node.sendrawtransaction(double_signedtx["hex"])
|
||||
double_tx = double_spending_node.getrawtransaction(dbl_tx_id, 1)
|
||||
lastblockhash = self.generate(double_spending_node, 1)[0]
|
||||
lastblockhash = self.generate(double_spending_node, 1, sync_fun=self.no_op)[0]
|
||||
|
||||
self.reconnect_isolated_node(3, 2)
|
||||
self.sync_all()
|
||||
@ -379,7 +372,7 @@ class ListSinceBlockTest(BitcoinTestFramework):
|
||||
assert_equal(original_found, True)
|
||||
assert_equal(double_found, True)
|
||||
|
||||
lastblockhash = self.generate(spending_node, 1)[0]
|
||||
lastblockhash = self.generate(spending_node, 1, sync_fun=self.no_op)[0]
|
||||
|
||||
# check that neither transaction exists
|
||||
block_hash = spending_node.listsinceblock(lastblockhash)
|
||||
|
@ -34,7 +34,6 @@ class ListTransactionsTest(BitcoinTestFramework):
|
||||
self.log.info("Test confirmations change after mining a block")
|
||||
blockhash = self.generate(self.nodes[0], 1)[0]
|
||||
blockheight = self.nodes[0].getblockheader(blockhash)['height']
|
||||
self.sync_all()
|
||||
assert_array_result(self.nodes[0].listtransactions(),
|
||||
{"txid": txid},
|
||||
{"category": "send", "amount": Decimal("-0.1"), "confirmations": 1, "blockhash": blockhash, "blockheight": blockheight})
|
||||
|
@ -183,7 +183,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
self.nodes[0].createwallet("w5")
|
||||
assert_equal(set(node.listwallets()), {"w4", "w5"})
|
||||
w5 = wallet("w5")
|
||||
self.generatetoaddress(node, nblocks=1, address=w5.getnewaddress())
|
||||
self.generatetoaddress(node, nblocks=1, address=w5.getnewaddress(), sync_fun=self.no_op)
|
||||
|
||||
# now if wallets/ exists again, but the rootdir is specified as the walletdir, w4 and w5 should still be loaded
|
||||
os.rename(wallet_dir2, wallet_dir())
|
||||
@ -215,7 +215,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
wallet_bad = wallet("bad")
|
||||
|
||||
# check wallet names and balances
|
||||
self.generatetoaddress(node, nblocks=1, address=wallets[0].getnewaddress())
|
||||
self.generatetoaddress(node, nblocks=1, address=wallets[0].getnewaddress(), sync_fun=self.no_op)
|
||||
for wallet_name, wallet in zip(wallet_names, wallets):
|
||||
info = wallet.getwalletinfo()
|
||||
assert_equal(info['immature_balance'], 500 if wallet is wallets[0] else 0)
|
||||
@ -228,7 +228,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-19, "Wallet file not specified", node.getwalletinfo)
|
||||
|
||||
w1, w2, w3, w4, *_ = wallets
|
||||
self.generatetoaddress(node, nblocks=COINBASE_MATURITY + 1, address=w1.getnewaddress())
|
||||
self.generatetoaddress(node, nblocks=COINBASE_MATURITY + 1, address=w1.getnewaddress(), sync_fun=self.no_op)
|
||||
assert_equal(w1.getbalance(), 1000)
|
||||
assert_equal(w2.getbalance(), 0)
|
||||
assert_equal(w3.getbalance(), 0)
|
||||
@ -237,7 +237,7 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
w1.sendtoaddress(w2.getnewaddress(), 1)
|
||||
w1.sendtoaddress(w3.getnewaddress(), 2)
|
||||
w1.sendtoaddress(w4.getnewaddress(), 3)
|
||||
self.generatetoaddress(node, nblocks=1, address=w1.getnewaddress())
|
||||
self.generatetoaddress(node, nblocks=1, address=w1.getnewaddress(), sync_fun=self.no_op)
|
||||
assert_equal(w2.getbalance(), 1)
|
||||
assert_equal(w3.getbalance(), 2)
|
||||
assert_equal(w4.getbalance(), 3)
|
||||
|
@ -43,7 +43,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
# Send a tx to be unconfirmed later
|
||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), Decimal("10"))
|
||||
tx = self.nodes[0].gettransaction(txid)
|
||||
self.generate(self.nodes[0], 4)
|
||||
self.generate(self.nodes[0], 4, sync_fun=self.no_op)
|
||||
tx_before_reorg = self.nodes[0].gettransaction(txid)
|
||||
assert_equal(tx_before_reorg["confirmations"], 4)
|
||||
|
||||
@ -62,9 +62,9 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
conflicting = self.nodes[0].signrawtransactionwithwallet(self.nodes[0].createrawtransaction(inputs, outputs_2))
|
||||
|
||||
conflicted_txid = self.nodes[0].sendrawtransaction(conflicted["hex"])
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
||||
conflicting_txid = self.nodes[2].sendrawtransaction(conflicting["hex"])
|
||||
self.generate(self.nodes[2], 9)
|
||||
self.generate(self.nodes[2], 9, sync_fun=self.no_op)
|
||||
|
||||
# Reconnect node0 and node2 and check that conflicted_txid is effectively conflicted
|
||||
self.connect_nodes(0, 2)
|
||||
@ -78,11 +78,11 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
self.restart_node(0)
|
||||
|
||||
# The block chain re-orgs and the tx is included in a different block
|
||||
self.generate(self.nodes[1], 9)
|
||||
self.generate(self.nodes[1], 9, sync_fun=self.no_op)
|
||||
self.nodes[1].sendrawtransaction(tx["hex"])
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
self.nodes[1].sendrawtransaction(conflicted["hex"])
|
||||
self.generate(self.nodes[1], 1)
|
||||
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
|
||||
|
||||
# Node0 wallet file is loaded on longest sync'ed node1
|
||||
self.stop_node(1)
|
||||
|
@ -439,7 +439,6 @@ class WalletSendTest(BitcoinTestFramework):
|
||||
res = self.nodes[0].sendrawtransaction(hex)
|
||||
self.generate(self.nodes[0], 1)
|
||||
assert_equal(self.nodes[0].gettransaction(txid)["confirmations"], 1)
|
||||
self.sync_all()
|
||||
|
||||
self.log.info("Lock unspents...")
|
||||
utxo1 = w0.listunspent()[0]
|
||||
|
@ -77,8 +77,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
|
||||
# Have node0 mine a block, if requested:
|
||||
if (self.options.mine_block):
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(self.nodes[0:2])
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:2]))
|
||||
|
||||
tx1 = self.nodes[0].gettransaction(txid1)
|
||||
tx2 = self.nodes[0].gettransaction(txid2)
|
||||
@ -103,7 +102,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
self.nodes[2].sendrawtransaction(node0_tx1["hex"])
|
||||
txid1_clone = self.nodes[2].sendrawtransaction(tx1_clone["hex"])
|
||||
# ... mine a block...
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.generate(self.nodes[2], 1, sync_fun=self.no_op)
|
||||
|
||||
# Reconnect the split network, and sync chain:
|
||||
self.connect_nodes(1, 2)
|
||||
|
@ -82,8 +82,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
|
||||
# Have node0 mine a block:
|
||||
if (self.options.mine_block):
|
||||
self.generate(self.nodes[0], 1)
|
||||
self.sync_blocks(self.nodes[0:2])
|
||||
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(self.nodes[0:2]))
|
||||
|
||||
tx1 = self.nodes[0].gettransaction(txid1)
|
||||
tx2 = self.nodes[0].gettransaction(txid2)
|
||||
@ -111,7 +110,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
self.nodes[2].sendrawtransaction(fund_bar_tx["hex"])
|
||||
doublespend_txid = self.nodes[2].sendrawtransaction(doublespend["hex"])
|
||||
# ... mine a block...
|
||||
self.generate(self.nodes[2], 1)
|
||||
self.generate(self.nodes[2], 1, sync_fun=self.no_op)
|
||||
|
||||
# Reconnect the split network, and sync chain:
|
||||
self.connect_nodes(1, 2)
|
||||
|
@ -65,7 +65,7 @@ class WalletUpgradeToHDTest(BitcoinTestFramework):
|
||||
assert_equal(keypath, "m/44'/1'/0'/1/%d" % i)
|
||||
|
||||
self.bump_mocktime(1)
|
||||
self.generate(node, 1)
|
||||
self.generate(node, 1, sync_fun=self.no_op)
|
||||
|
||||
self.log.info("Should no longer be able to start it with HD disabled")
|
||||
self.stop_node(0)
|
||||
|
@ -96,8 +96,7 @@ class UpgradeWalletTest(BitcoinTestFramework):
|
||||
assert_equal(wallet.getwalletinfo()["walletversion"], previous_version)
|
||||
|
||||
def run_test(self):
|
||||
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY + 1, self.nodes[0].getnewaddress())
|
||||
self.dumb_sync_blocks()
|
||||
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY + 1, self.nodes[0].getnewaddress(), sync_fun=lambda: self.dumb_sync_blocks())
|
||||
# # Sanity check the test framework:
|
||||
res = self.nodes[0].getblockchaininfo()
|
||||
assert_equal(res['blocks'], COINBASE_MATURITY + 1)
|
||||
@ -108,8 +107,7 @@ class UpgradeWalletTest(BitcoinTestFramework):
|
||||
# Send coins to old wallets for later conversion checks.
|
||||
v18_2_wallet = v18_2_node.get_wallet_rpc(self.default_wallet_name)
|
||||
v18_2_address = v18_2_wallet.getnewaddress()
|
||||
self.generatetoaddress(node_master, COINBASE_MATURITY + 1, v18_2_address)
|
||||
self.dumb_sync_blocks()
|
||||
self.generatetoaddress(node_master, COINBASE_MATURITY + 1, v18_2_address, sync_fun=lambda: self.dumb_sync_blocks())
|
||||
v18_2_balance = v18_2_wallet.getbalance()
|
||||
|
||||
self.log.info("Test upgradewallet RPC...")
|
||||
|
Loading…
Reference in New Issue
Block a user