aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2011-09-08 16:50:58 -0400
committerLuke Dashjr <[email protected]>2011-12-01 15:48:20 -0500
commitd27be1f55777bd502beb6b89513f1a03ed988f1a (patch)
tree34ea670fc5e136a8b0f78be6f0a7ab6bcc58ebf1 /src/test
parentMake home and addressbook icon more consistent with other toolbar icons (make... (diff)
downloaddiscoin-d27be1f55777bd502beb6b89513f1a03ed988f1a.tar.xz
discoin-d27be1f55777bd502beb6b89513f1a03ed988f1a.zip
Moved checkpoints out of main, to prep for using them to help prevent DoS attacks
Diffstat (limited to 'src/test')
-rw-r--r--src/test/Checkpoints_tests.cpp34
-rw-r--r--src/test/DoS_tests.cpp1
-rw-r--r--src/test/test_bitcoin.cpp1
3 files changed, 35 insertions, 1 deletions
diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp
new file mode 100644
index 000000000..0d8a366d7
--- /dev/null
+++ b/src/test/Checkpoints_tests.cpp
@@ -0,0 +1,34 @@
+//
+// Unit tests for block-chain checkpoints
+//
+#include <boost/assign/list_of.hpp> // for 'map_list_of()'
+#include <boost/test/unit_test.hpp>
+#include <boost/foreach.hpp>
+
+#include "../checkpoints.h"
+#include "../util.h"
+
+using namespace std;
+
+BOOST_AUTO_TEST_SUITE(Checkpoints_tests)
+
+BOOST_AUTO_TEST_CASE(sanity)
+{
+ uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
+ uint256 p140700 = uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd");
+ BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111));
+ BOOST_CHECK(Checkpoints::CheckBlock(140700, p140700));
+
+
+ // Wrong hashes at checkpoints should fail:
+ BOOST_CHECK(!Checkpoints::CheckBlock(11111, p140700));
+ BOOST_CHECK(!Checkpoints::CheckBlock(140700, p11111));
+
+ // ... but any hash not at a checkpoint should succeed:
+ BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p140700));
+ BOOST_CHECK(Checkpoints::CheckBlock(140700+1, p11111));
+
+ BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 140700);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp
index e60bb742d..1093b73d8 100644
--- a/src/test/DoS_tests.cpp
+++ b/src/test/DoS_tests.cpp
@@ -64,5 +64,4 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
BOOST_CHECK(!CNode::IsBanned(addr.ip));
}
-
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index 8863aad47..39a7c88e1 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -13,6 +13,7 @@
#include "util_tests.cpp"
#include "base58_tests.cpp"
#include "miner_tests.cpp"
+#include "Checkpoints_tests.cpp"
CWallet* pwalletMain;