Changeset View
Changeset View
Standalone View
Standalone View
src/test/txvalidationcache_tests.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | for (int i = 0; i < 2; i++) { | ||||
vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); | vchSig.push_back(uint8_t(SIGHASH_ALL | SIGHASH_FORKID)); | ||||
spends[i].vin[0].scriptSig << vchSig; | spends[i].vin[0].scriptSig << vchSig; | ||||
} | } | ||||
CBlock block; | CBlock block; | ||||
// Test 1: block with both of those transactions should be rejected. | // Test 1: block with both of those transactions should be rejected. | ||||
block = CreateAndProcessBlock(spends, scriptPubKey); | block = CreateAndProcessBlock(spends, scriptPubKey); | ||||
LOCK(cs_main); | |||||
BOOST_CHECK(chainActive.Tip()->GetBlockHash() != block.GetHash()); | BOOST_CHECK(chainActive.Tip()->GetBlockHash() != block.GetHash()); | ||||
// Test 2: ... and should be rejected if spend1 is in the memory pool | // Test 2: ... and should be rejected if spend1 is in the memory pool | ||||
BOOST_CHECK(ToMemPool(spends[0])); | BOOST_CHECK(ToMemPool(spends[0])); | ||||
block = CreateAndProcessBlock(spends, scriptPubKey); | block = CreateAndProcessBlock(spends, scriptPubKey); | ||||
BOOST_CHECK(chainActive.Tip()->GetBlockHash() != block.GetHash()); | BOOST_CHECK(chainActive.Tip()->GetBlockHash() != block.GetHash()); | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | for (uint32_t test_flags = 0; test_flags < (1U << 17); test_flags += 1) { | ||||
BOOST_CHECK_EQUAL(scriptchecks.size(), tx.vin.size()); | BOOST_CHECK_EQUAL(scriptchecks.size(), tx.vin.size()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup) { | BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup) { | ||||
// Test that passing CheckInputs with one set of script flags doesn't imply | // Test that passing CheckInputs 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(); | InitScriptExecutionCache(); | ||||
} | |||||
CScript p2pk_scriptPubKey = | CScript p2pk_scriptPubKey = | ||||
CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG; | CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG; | ||||
CScript p2sh_scriptPubKey = | CScript p2sh_scriptPubKey = | ||||
GetScriptForDestination(CScriptID(p2pk_scriptPubKey)); | GetScriptForDestination(CScriptID(p2pk_scriptPubKey)); | ||||
CScript p2pkh_scriptPubKey = | CScript p2pkh_scriptPubKey = | ||||
GetScriptForDestination(coinbaseKey.GetPubKey().GetID()); | GetScriptForDestination(coinbaseKey.GetPubKey().GetID()); | ||||
▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines |