aboutsummaryrefslogtreecommitdiff
path: root/src/test/script_tests.cpp
diff options
context:
space:
mode:
authorVegard Nossum <vegard.nossum@gmail.com>2011-07-31 20:01:31 +0200
committerGavin Andresen <gavinandresen@gmail.com>2011-08-08 14:31:08 -0400
commita8330e0049868eb3e2d1505719f3dba175711e74 (patch)
tree39030f4f16ce4148d40d63431eb7f5c2a296065b /src/test/script_tests.cpp
parent5f6a654d3eb01cd1d324df4cbe2c7fe51dc3e752 (diff)
Add a file for script tests
Diffstat (limited to 'src/test/script_tests.cpp')
-rw-r--r--src/test/script_tests.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
new file mode 100644
index 0000000000..5e74648c4b
--- /dev/null
+++ b/src/test/script_tests.cpp
@@ -0,0 +1,37 @@
+#include <vector>
+#include <boost/test/unit_test.hpp>
+#include <boost/foreach.hpp>
+
+#include "../main.h"
+#include "../wallet.h"
+
+using namespace std;
+
+BOOST_AUTO_TEST_SUITE(script_tests)
+
+BOOST_AUTO_TEST_CASE(script_PushData)
+{
+ // Check that PUSHDATA1, PUSHDATA2, and PUSHDATA4 create the same value on
+ // the stack as the 1-75 opcodes do.
+ static const unsigned char direct[] = { 1, 0x5a };
+ static const unsigned char pushdata1[] = { OP_PUSHDATA1, 1, 0x5a };
+ static const unsigned char pushdata2[] = { OP_PUSHDATA2, 1, 0, 0x5a };
+ static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a };
+
+ vector<vector<unsigned char> > directStack;
+ BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, 0));
+
+ vector<vector<unsigned char> > pushdata1Stack;
+ BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, 0));
+ BOOST_CHECK(pushdata1Stack == directStack);
+
+ vector<vector<unsigned char> > pushdata2Stack;
+ BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, 0));
+ BOOST_CHECK(pushdata2Stack == directStack);
+
+ vector<vector<unsigned char> > pushdata4Stack;
+ BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, 0));
+ BOOST_CHECK(pushdata4Stack == directStack);
+}
+
+BOOST_AUTO_TEST_SUITE_END()