aboutsummaryrefslogtreecommitdiff
path: root/src/test/script_op_eval_tests.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-11-08 13:20:29 -0500
committerGavin Andresen <gavinandresen@gmail.com>2011-12-19 13:24:48 -0500
commit2a45a494b0bec6a0f1fc6ab7f26c260b85e7ff3e (patch)
treea6c8ad492ea81d6f1c2b8694351a7b7bfa785ae6 /src/test/script_op_eval_tests.cpp
parenta0871afb2b1d6d358c833fd08bca2f13c840fd4d (diff)
Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript
so it takes a flag for how to interpret OP_EVAL. Also increased IsStandard size of scriptSigs to 500 bytes, so a 3-of-3 multisig transaction IsStandard.
Diffstat (limited to 'src/test/script_op_eval_tests.cpp')
-rw-r--r--src/test/script_op_eval_tests.cpp39
1 files changed, 11 insertions, 28 deletions
diff --git a/src/test/script_op_eval_tests.cpp b/src/test/script_op_eval_tests.cpp
index 6c683b5729..c44642c6e9 100644
--- a/src/test/script_op_eval_tests.cpp
+++ b/src/test/script_op_eval_tests.cpp
@@ -13,24 +13,10 @@ using namespace std;
// Test routines internal to script.cpp:
extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
-extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int& nSigOps, int nHashType);
+extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int& nSigOps,
+ int nHashType, bool fStrictOpEval);
-static const int64 nEvalSwitchover = 1328054400;
-
-struct CEvalFixture {
- CEvalFixture()
- {
- // Set mock time to AFTER OP_EVAL deployed
- SetMockTime(nEvalSwitchover+1);
- }
- ~CEvalFixture()
- {
- // Reset back to use-real-time
- SetMockTime(0);
- }
-};
-
-BOOST_FIXTURE_TEST_SUITE(script_op_eval_tests, CEvalFixture)
+BOOST_AUTO_TEST_SUITE(script_op_eval_tests)
BOOST_AUTO_TEST_CASE(script_op_eval1)
{
@@ -130,8 +116,8 @@ BOOST_AUTO_TEST_CASE(script_op_eval2)
txTo.vout[0].nValue = 1;
int nUnused = 0;
- BOOST_CHECK(!VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0));
- BOOST_CHECK(!VerifySignature(txFrom, txTo, 0, nUnused));
+ BOOST_CHECK(!VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0, true));
+ BOOST_CHECK(!VerifySignature(txFrom, txTo, 0, nUnused, true));
}
BOOST_AUTO_TEST_CASE(script_op_eval3)
@@ -212,13 +198,13 @@ BOOST_AUTO_TEST_CASE(script_op_eval_backcompat1)
txTo.vout[0].nValue = 1;
int nUnused = 0;
- BOOST_CHECK(!VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0));
- BOOST_CHECK(!VerifySignature(txFrom, txTo, 0, nUnused));
+ BOOST_CHECK(!VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0, true));
+ BOOST_CHECK(!VerifySignature(txFrom, txTo, 0, nUnused, true));
}
BOOST_AUTO_TEST_CASE(script_op_eval_switchover)
{
- // Use SetMockTime to test OP_EVAL switchover code
+ // Test OP_EVAL switchover code
CScript notValid;
notValid << OP_11 << OP_12 << OP_EQUALVERIFY;
@@ -238,14 +224,11 @@ BOOST_AUTO_TEST_CASE(script_op_eval_switchover)
txTo.vin[0].scriptSig = CScript() << static_cast<std::vector<unsigned char> >(notValid);
txTo.vout[0].nValue = 1;
- SetMockTime(nEvalSwitchover-1);
-
int nUnused = 0;
- BOOST_CHECK(VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0));
+ BOOST_CHECK(VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0, false));
- // After eval switchover time, it should validate:
- SetMockTime(nEvalSwitchover);
- BOOST_CHECK(!VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0));
+ // Under strict op_eval switchover, it should be considered invalid:
+ BOOST_CHECK(!VerifyScript(txTo.vin[0].scriptSig, txFrom.vout[0].scriptPubKey, txTo, 0, nUnused, 0, true));
}
BOOST_AUTO_TEST_SUITE_END()