Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_p2sh_tests.cpp
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(norecurse) { | ||||
CScript p2sh = GetScriptForDestination(CScriptID(invalidAsScript)); | CScript p2sh = GetScriptForDestination(CScriptID(invalidAsScript)); | ||||
CScript scriptSig; | CScript scriptSig; | ||||
scriptSig << Serialize(invalidAsScript); | scriptSig << Serialize(invalidAsScript); | ||||
// Should not verify, because it will try to execute OP_INVALIDOPCODE | // Should not verify, because it will try to execute OP_INVALIDOPCODE | ||||
BOOST_CHECK(!Verify(scriptSig, p2sh, true, err)); | BOOST_CHECK(!Verify(scriptSig, p2sh, true, err)); | ||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_BAD_OPCODE, ScriptErrorString(err)); | BOOST_CHECK_MESSAGE(err == ScriptError::BAD_OPCODE, ScriptErrorString(err)); | ||||
// Try to recur, and verification should succeed because | // Try to recur, and verification should succeed because | ||||
// the inner HASH160 <> EQUAL should only check the hash: | // the inner HASH160 <> EQUAL should only check the hash: | ||||
CScript p2sh2 = GetScriptForDestination(CScriptID(p2sh)); | CScript p2sh2 = GetScriptForDestination(CScriptID(p2sh)); | ||||
CScript scriptSig2; | CScript scriptSig2; | ||||
scriptSig2 << Serialize(invalidAsScript) << Serialize(p2sh); | scriptSig2 << Serialize(invalidAsScript) << Serialize(p2sh); | ||||
BOOST_CHECK(Verify(scriptSig2, p2sh2, true, err)); | BOOST_CHECK(Verify(scriptSig2, p2sh2, true, err)); | ||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); | BOOST_CHECK_MESSAGE(err == ScriptError::OK, ScriptErrorString(err)); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(set) { | BOOST_AUTO_TEST_CASE(set) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// Test the CScript::Set* methods | // Test the CScript::Set* methods | ||||
CBasicKeyStore keystore; | CBasicKeyStore keystore; | ||||
CKey key[4]; | CKey key[4]; | ||||
std::vector<CPubKey> keys; | std::vector<CPubKey> keys; | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(switchover) { | ||||
notValid << OP_11 << OP_12 << OP_EQUALVERIFY; | notValid << OP_11 << OP_12 << OP_EQUALVERIFY; | ||||
CScript scriptSig; | CScript scriptSig; | ||||
scriptSig << Serialize(notValid); | scriptSig << Serialize(notValid); | ||||
CScript fund = GetScriptForDestination(CScriptID(notValid)); | CScript fund = GetScriptForDestination(CScriptID(notValid)); | ||||
// Validation should succeed under old rules (hash is correct): | // Validation should succeed under old rules (hash is correct): | ||||
BOOST_CHECK(Verify(scriptSig, fund, false, err)); | BOOST_CHECK(Verify(scriptSig, fund, false, err)); | ||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); | BOOST_CHECK_MESSAGE(err == ScriptError::OK, ScriptErrorString(err)); | ||||
// Fail under new: | // Fail under new: | ||||
BOOST_CHECK(!Verify(scriptSig, fund, true, err)); | BOOST_CHECK(!Verify(scriptSig, fund, true, err)); | ||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EQUALVERIFY, ScriptErrorString(err)); | BOOST_CHECK_MESSAGE(err == ScriptError::EQUALVERIFY, | ||||
ScriptErrorString(err)); | |||||
} | } | ||||
BOOST_AUTO_TEST_CASE(AreInputsStandard) { | BOOST_AUTO_TEST_CASE(AreInputsStandard) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CCoinsView coinsDummy; | CCoinsView coinsDummy; | ||||
CCoinsViewCache coins(&coinsDummy); | CCoinsViewCache coins(&coinsDummy); | ||||
CBasicKeyStore keystore; | CBasicKeyStore keystore; | ||||
CKey key[6]; | CKey key[6]; | ||||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |