aboutsummaryrefslogtreecommitdiff
path: root/src/test/transaction_tests.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2013-09-10 15:18:09 -0400
committerCory Fields <cory-nospam-@coryfields.com>2013-09-16 12:53:11 -0400
commit152e51c7af2624831cc4796e06bf3b72787cc85f (patch)
treed943cbc4159b2e88f0ee68907edf51b9f673d6a8 /src/test/transaction_tests.cpp
parent08081e393b6d3249c19395f91537a7d824ec7333 (diff)
downloadbitcoin-152e51c7af2624831cc4796e06bf3b72787cc85f.tar.xz
included-tests: generate binary data from test files for inclusion into test binaries
This change moves test data into the binaries rather than reading them from the disk at runtime. Advantages: - Tests become distributable - Cross-compile friendly. Build on one machine and execute in an arbitrary location on another. - Easier testing for backports. Users can verify that tests pass without having to track down corresponding test data. - More trustworthy test results and easier quality assurance as tests make fewer assumptions about their environment. - Tests could theoretically run at client/daemon startup and exit on failure. Disadvantages: - Required 'hexdump' build-dependency. This is a standard bsd tool that should be usable everywhere. It is likely already installed on all build-machines. - Tests can no longer be fudged after build by altering test-data.
Diffstat (limited to 'src/test/transaction_tests.cpp')
-rw-r--r--src/test/transaction_tests.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 0c7475b4f2..416b93ab33 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -5,12 +5,14 @@
#include "main.h"
#include "wallet.h"
+#include "data/tx_invalid.json.h"
+#include "data/tx_valid.json.h"
using namespace std;
using namespace json_spirit;
// In script_tests.cpp
-extern Array read_json(const std::string& filename);
+extern Array read_json(const std::string& jsondata);
extern CScript ParseScript(string s);
BOOST_AUTO_TEST_SUITE(transaction_tests)
@@ -22,7 +24,7 @@ BOOST_AUTO_TEST_CASE(tx_valid)
// Inner arrays are either [ "comment" ]
// or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, enforceP2SH
// ... where all scripts are stringified scripts.
- Array tests = read_json("tx_valid.json");
+ Array tests = read_json(std::string(json_tests::tx_valid, json_tests::tx_valid + sizeof(json_tests::tx_valid)));
BOOST_FOREACH(Value& tv, tests)
{
@@ -91,7 +93,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
// Inner arrays are either [ "comment" ]
// or [[[prevout hash, prevout index, prevout scriptPubKey], [input 2], ...],"], serializedTransaction, enforceP2SH
// ... where all scripts are stringified scripts.
- Array tests = read_json("tx_invalid.json");
+ Array tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
BOOST_FOREACH(Value& tv, tests)
{