test: move EXPECTED_STDERR_NO_GOV{_PRUNE} and use it more

This commit is contained in:
Kittywhiskers Van Gogh 2024-09-20 12:28:38 +00:00
parent 77ce6af5c1
commit 4e621037c5
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
7 changed files with 20 additions and 11 deletions

View File

@ -9,6 +9,7 @@ from test_framework.util import (
assert_greater_than, assert_greater_than,
assert_raises_rpc_error, assert_raises_rpc_error,
) )
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE
class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
@ -42,7 +43,7 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getblockhash(2))['filter']), 0) assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getblockhash(2))['filter']), 0)
self.log.info("start node without blockfilterindex") self.log.info("start node without blockfilterindex")
self.restart_node(0, extra_args=["-fastprune", "-prune=1"], expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.restart_node(0, extra_args=["-fastprune", "-prune=1"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
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))
@ -51,17 +52,17 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework):
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)
assert_greater_than(pruneheight_new, pruneheight) assert_greater_than(pruneheight_new, pruneheight)
self.stop_node(0, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
self.log.info("make sure we get an init error when starting the node again with block filters") self.log.info("make sure we get an init error when starting the node again with block filters")
self.nodes[0].assert_start_raises_init_error( self.nodes[0].assert_start_raises_init_error(
extra_args=["-fastprune", "-prune=1", "-blockfilterindex=1"], extra_args=["-fastprune", "-prune=1", "-blockfilterindex=1"],
expected_msg="Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.\nError: basic block filter index best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)", expected_msg=f"{EXPECTED_STDERR_NO_GOV_PRUNE}\nError: basic block filter index best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)",
) )
self.log.info("make sure the node starts again with the -reindex arg") self.log.info("make sure the node starts again with the -reindex arg")
self.start_node(0, extra_args=["-fastprune", "-prune=1", "-blockfilterindex", "-reindex"]) self.start_node(0, extra_args=["-fastprune", "-prune=1", "-blockfilterindex", "-reindex"])
self.stop_nodes(expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.stop_nodes(expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -11,6 +11,10 @@ This test takes 30 mins or more (up to 2 hours)
import os import os
from test_framework.blocktools import create_coinbase from test_framework.blocktools import create_coinbase
from test_framework.governance import (
EXPECTED_STDERR_NO_GOV,
EXPECTED_STDERR_NO_GOV_PRUNE,
)
from test_framework.messages import CBlock from test_framework.messages import CBlock
from test_framework.script import ( from test_framework.script import (
CScript, CScript,
@ -29,9 +33,6 @@ from test_framework.util import (
# compatible with pruning based on key creation time. # compatible with pruning based on key creation time.
TIMESTAMP_WINDOW = 2 * 60 * 60 TIMESTAMP_WINDOW = 2 * 60 * 60
EXPECTED_STDERR_NO_GOV = "Warning: You are starting with governance validation disabled."
EXPECTED_STDERR_NO_GOV_PRUNE = EXPECTED_STDERR_NO_GOV + " This is expected because you are running a pruned node."
def mine_large_blocks(node, n): def mine_large_blocks(node, n):
# Make a large scriptPubKey for the coinbase transaction. This is OP_RETURN # Make a large scriptPubKey for the coinbase transaction. This is OP_RETURN
# followed by 950k of OP_NOP. This would be non-standard in a non-coinbase # followed by 950k of OP_NOP. This would be non-standard in a non-coinbase

View File

@ -14,6 +14,7 @@ try:
except ImportError: except ImportError:
pass pass
from test_framework.messages import COIN from test_framework.messages import COIN
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal from test_framework.util import assert_equal
from test_framework.wallet import MiniWallet from test_framework.wallet import MiniWallet
@ -402,7 +403,7 @@ class UTXOCacheTracepointTest(BitcoinTestFramework):
assert_equal(0, len(possible_cache_sizes)) assert_equal(0, len(possible_cache_sizes))
assert_equal(EXPECTED_HANDLE_FLUSH_SUCCESS, handle_flush_succeeds) assert_equal(EXPECTED_HANDLE_FLUSH_SUCCESS, handle_flush_succeeds)
self.stop_node(0, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
if __name__ == '__main__': if __name__ == '__main__':
UTXOCacheTracepointTest().main() UTXOCacheTracepointTest().main()

View File

@ -9,6 +9,7 @@ and that it responds to getdata requests for blocks correctly:
- send a block within 288 + 2 of the tip - send a block within 288 + 2 of the tip
- disconnect peers who request blocks older than that.""" - disconnect peers who request blocks older than that."""
from test_framework.messages import CInv, MSG_BLOCK, msg_getdata, NODE_BLOOM, NODE_NETWORK_LIMITED, NODE_HEADERS_COMPRESSED from test_framework.messages import CInv, MSG_BLOCK, msg_getdata, NODE_BLOOM, NODE_NETWORK_LIMITED, NODE_HEADERS_COMPRESSED
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE
from test_framework.p2p import P2PInterface from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal from test_framework.util import assert_equal
@ -95,7 +96,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework):
# sync must be possible, node 1 is no longer in IBD and should therefore connect to node 0 (NODE_NETWORK_LIMITED) # sync must be possible, node 1 is no longer in IBD and should therefore connect to node 0 (NODE_NETWORK_LIMITED)
self.sync_blocks([self.nodes[0], self.nodes[1]]) self.sync_blocks([self.nodes[0], self.nodes[1]])
self.stop_node(0, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -31,6 +31,7 @@ from test_framework.blocktools import (
create_coinbase, create_coinbase,
TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK,
) )
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE
from test_framework.messages import ( from test_framework.messages import (
CBlockHeader, CBlockHeader,
from_hex, from_hex,
@ -125,7 +126,7 @@ class BlockchainTest(BitcoinTestFramework):
assert res['pruned'] assert res['pruned']
assert not res['automatic_pruning'] assert not res['automatic_pruning']
self.restart_node(0, ['-stopatheight=207', '-txindex=0'], expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.restart_node(0, ['-stopatheight=207', '-txindex=0'], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
res = self.nodes[0].getblockchaininfo() res = self.nodes[0].getblockchaininfo()
# should have exact keys # should have exact keys
assert_equal(sorted(res.keys()), keys) assert_equal(sorted(res.keys()), keys)

View File

@ -6,6 +6,9 @@
import json import json
EXPECTED_STDERR_NO_GOV = "Warning: You are starting with governance validation disabled."
EXPECTED_STDERR_NO_GOV_PRUNE = f"{EXPECTED_STDERR_NO_GOV} This is expected because you are running a pruned node."
def prepare_object(node, object_type, parent_hash, creation_time, revision, name, amount, payment_address): def prepare_object(node, object_type, parent_hash, creation_time, revision, name, amount, payment_address):
proposal_rev = revision proposal_rev = revision
proposal_time = int(creation_time) proposal_time = int(creation_time)

View File

@ -20,6 +20,7 @@ happened previously.
""" """
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,
set_node_times, set_node_times,
@ -213,7 +214,7 @@ class ImportRescanTest(BitcoinTestFramework):
variant.check(variant.sent_txid, variant.sent_amount, variant.confirmation_height) variant.check(variant.sent_txid, variant.sent_amount, variant.confirmation_height)
for i, import_node in enumerate(IMPORT_NODES, 2): for i, import_node in enumerate(IMPORT_NODES, 2):
if import_node.prune: if import_node.prune:
self.stop_node(i, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') self.stop_node(i, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)