Skip to content

Commit 0dbce4b

Browse files
committed
tests: Reduce calls to InitS*Cache()
In src/test/fuzz/script_sigcache.cpp, we should really be setting up a full working BasicTestingSetup. The initialize_ function is only run once anyway. In src/test/txvalidationcache_tests.cpp, the Dersig100Setup inherits from BasicTestingSetup, which should have already set up a global script execution cache without the need to explicitly call InitScriptExecutionCache.
1 parent 4a4289e commit 0dbce4b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/test/fuzz/script_sigcache.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
#include <test/fuzz/FuzzedDataProvider.h>
1111
#include <test/fuzz/fuzz.h>
1212
#include <test/fuzz/util.h>
13+
#include <test/util/setup_common.h>
1314

1415
#include <cstdint>
1516
#include <optional>
1617
#include <string>
1718
#include <vector>
1819

20+
namespace {
21+
const BasicTestingSetup* g_setup;
22+
} // namespace
23+
1924
void initialize_script_sigcache()
2025
{
21-
static const ECCVerifyHandle ecc_verify_handle;
22-
ECC_Start();
23-
SelectParams(CBaseChainParams::REGTEST);
24-
InitSignatureCache();
26+
static const auto testing_setup = MakeNoLogFileContext<>();
27+
g_setup = testing_setup.get();
2528
}
2629

2730
FUZZ_TARGET_INIT(script_sigcache, initialize_script_sigcache)

src/test/txvalidationcache_tests.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
161161
{
162162
// Test that passing CheckInputScripts with one set of script flags doesn't imply
163163
// that we would pass again with a different set of flags.
164-
{
165-
LOCK(cs_main);
166-
InitScriptExecutionCache();
167-
}
168-
169164
CScript p2pk_scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
170165
CScript p2sh_scriptPubKey = GetScriptForDestination(ScriptHash(p2pk_scriptPubKey));
171166
CScript p2pkh_scriptPubKey = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));

0 commit comments

Comments
 (0)