aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-02-25 16:25:43 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-02-25 16:25:52 +0100
commit12f5787d4545aa4ea8b7b58dc21319d574023b1f (patch)
treeb0220a6a0e04acf1066b5a74e0cab4588c0ad18c
parent319860429311b4ed96356aea877dd056a18fb80e (diff)
parente6c6bc92f468b3eeffe1bd5ebc7b6c617bd31714 (diff)
Merge pull request #3559
e6c6bc9 Adds additional zero checks for setCompact These encoded values should all decode to zero (Noel Tiernan)
-rw-r--r--src/test/bignum_tests.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/bignum_tests.cpp b/src/test/bignum_tests.cpp
index 9d67324c76..205b15adcf 100644
--- a/src/test/bignum_tests.cpp
+++ b/src/test/bignum_tests.cpp
@@ -135,6 +135,42 @@ BOOST_AUTO_TEST_CASE(bignum_SetCompact)
BOOST_CHECK_EQUAL(num.GetHex(), "0");
BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+ num.SetCompact(0x01003456);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x02000056);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x03000000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x04000000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x00923456);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x01803456);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x02800056);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x03800000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x04800000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
num.SetCompact(0x01123456);
BOOST_CHECK_EQUAL(num.GetHex(), "12");
BOOST_CHECK_EQUAL(num.GetCompact(), 0x01120000U);