aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-04-05 15:50:17 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-04-05 15:50:17 +0200
commit009b503792737ab03aeb6e15060bc4f499500a96 (patch)
treed7d59a46cce9d1769a8a7d71dd5de24dfd739274 /src
parent76da7613517d05aca31c2cee42b5ebf3d5c54974 (diff)
Get rid of expect in script_tests as it's implied by scripterror
Diffstat (limited to 'src')
-rw-r--r--src/test/script_tests.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 006d8aa644..6340af2081 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -145,13 +145,14 @@ CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMu
return txSpend;
}
-void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, bool expect, const std::string& message, int scriptError)
+void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, const std::string& message, int scriptError)
{
+ bool expect = (scriptError == SCRIPT_ERR_OK);
ScriptError err;
CMutableTransaction tx = BuildSpendingTransaction(scriptSig, BuildCreditingTransaction(scriptPubKey));
CMutableTransaction tx2 = tx;
BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, MutableTransactionSignatureChecker(&tx, 0), &err) == expect, message);
- BOOST_CHECK_MESSAGE(scriptError == -1 || err == scriptError, std::string(FormatScriptError(err)) + " where " + std::string(FormatScriptError((ScriptError_t)scriptError)) + " expected: " + message);
+ BOOST_CHECK_MESSAGE(err == scriptError, std::string(FormatScriptError(err)) + " where " + std::string(FormatScriptError((ScriptError_t)scriptError)) + " expected: " + message);
#if defined(HAVE_CONSENSUS_LIB)
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << tx2;
@@ -349,11 +350,11 @@ public:
return *this;
}
- TestBuilder& Test(bool expect)
+ TestBuilder& Test()
{
TestBuilder copy = *this; // Make a copy so we can rollback the push.
DoPush();
- DoTest(creditTx.vout[0].scriptPubKey, spendTx.vin[0].scriptSig, flags, expect, comment, expect ? SCRIPT_ERR_OK : scriptError);
+ DoTest(creditTx.vout[0].scriptPubKey, spendTx.vin[0].scriptSig, flags, comment, scriptError);
*this = copy;
return *this;
}
@@ -680,7 +681,7 @@ BOOST_AUTO_TEST_CASE(script_build)
std::string strBad;
BOOST_FOREACH(TestBuilder& test, good) {
- test.Test(true);
+ test.Test();
std::string str = JSONPrettyPrint(test.GetJSON());
#ifndef UPDATE_JSON_TESTS
if (tests_good.count(str) == 0) {
@@ -690,7 +691,7 @@ BOOST_AUTO_TEST_CASE(script_build)
strGood += str + ",\n";
}
BOOST_FOREACH(TestBuilder& test, bad) {
- test.Test(false);
+ test.Test();
std::string str = JSONPrettyPrint(test.GetJSON());
#ifndef UPDATE_JSON_TESTS
if (tests_bad.count(str) == 0) {
@@ -736,7 +737,7 @@ BOOST_AUTO_TEST_CASE(script_valid)
unsigned int scriptflags = ParseScriptFlags(test[2].get_str());
BOOST_CHECK_EQUAL(test[3].get_str(), "OK");
- DoTest(scriptPubKey, scriptSig, scriptflags, true, strTest, SCRIPT_ERR_OK);
+ DoTest(scriptPubKey, scriptSig, scriptflags, strTest, SCRIPT_ERR_OK);
}
}
@@ -761,7 +762,7 @@ BOOST_AUTO_TEST_CASE(script_invalid)
unsigned int scriptflags = ParseScriptFlags(test[2].get_str());
int scriptError = ParseScriptError(test[3].get_str());
- DoTest(scriptPubKey, scriptSig, scriptflags, false, strTest, scriptError);
+ DoTest(scriptPubKey, scriptSig, scriptflags, strTest, scriptError);
}
}