mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
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.
This commit is contained in:
parent
4a4289e2c9
commit
0dbce4b103
2 changed files with 7 additions and 9 deletions
|
@ -10,18 +10,21 @@
|
||||||
#include <test/fuzz/FuzzedDataProvider.h>
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <test/fuzz/util.h>
|
#include <test/fuzz/util.h>
|
||||||
|
#include <test/util/setup_common.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
const BasicTestingSetup* g_setup;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void initialize_script_sigcache()
|
void initialize_script_sigcache()
|
||||||
{
|
{
|
||||||
static const ECCVerifyHandle ecc_verify_handle;
|
static const auto testing_setup = MakeNoLogFileContext<>();
|
||||||
ECC_Start();
|
g_setup = testing_setup.get();
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
|
||||||
InitSignatureCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FUZZ_TARGET_INIT(script_sigcache, initialize_script_sigcache)
|
FUZZ_TARGET_INIT(script_sigcache, initialize_script_sigcache)
|
||||||
|
|
|
@ -161,11 +161,6 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, Dersig100Setup)
|
||||||
{
|
{
|
||||||
// Test that passing CheckInputScripts with one set of script flags doesn't imply
|
// Test that passing CheckInputScripts with one set of script flags doesn't imply
|
||||||
// that we would pass again with a different set of flags.
|
// that we would pass again with a different set of flags.
|
||||||
{
|
|
||||||
LOCK(cs_main);
|
|
||||||
InitScriptExecutionCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
CScript p2pk_scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
CScript p2pk_scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
||||||
CScript p2sh_scriptPubKey = GetScriptForDestination(ScriptHash(p2pk_scriptPubKey));
|
CScript p2sh_scriptPubKey = GetScriptForDestination(ScriptHash(p2pk_scriptPubKey));
|
||||||
CScript p2pkh_scriptPubKey = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));
|
CScript p2pkh_scriptPubKey = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));
|
||||||
|
|
Loading…
Add table
Reference in a new issue