Skip to content

Commit 269efa3

Browse files
committed
build: add quick consensus lib tests
They should be hooked up in other places as well, but this is a start.
1 parent cdd36c6 commit 269efa3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/script_tests.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include "script/sign.h"
1515
#include "util.h"
1616

17+
#if defined(HAVE_CONSENSUS_LIB)
18+
#include "script/bitcoinconsensus.h"
19+
#endif
20+
1721
#include <fstream>
1822
#include <stdint.h>
1923
#include <string>
@@ -94,8 +98,15 @@ CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMu
9498
void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, bool expect, const std::string& message)
9599
{
96100
ScriptError err;
97-
BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, SignatureChecker(BuildSpendingTransaction(scriptSig, BuildCreditingTransaction(scriptPubKey)), 0), &err) == expect, message);
101+
CMutableTransaction tx = BuildSpendingTransaction(scriptSig, BuildCreditingTransaction(scriptPubKey));
102+
CMutableTransaction tx2 = tx;
103+
BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, SignatureChecker(tx, 0), &err) == expect, message);
98104
BOOST_CHECK_MESSAGE(expect == (err == SCRIPT_ERR_OK), std::string(ScriptErrorString(err)) + ": " + message);
105+
#if defined(HAVE_CONSENSUS_LIB)
106+
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
107+
stream << tx2;
108+
BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message);
109+
#endif
99110
}
100111

101112
void static NegateSignatureS(std::vector<unsigned char>& vchSig) {

0 commit comments

Comments
 (0)