static void CheckCreateVch(const int64_t& num) { CBigNum bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); CBigNum bignum2(bignum.getvch()); CScriptNum scriptnum2(scriptnum.getvch(), false); BOOST_CHECK(verify(bignum2, scriptnum2)); CBigNum bignum3(scriptnum2.getvch()); CScriptNum scriptnum3(bignum2.getvch(), false); BOOST_CHECK(verify(bignum3, scriptnum3)); }
static void CheckCreateVch(const int64_t& num) { CScriptNum10 bignum(num); CScriptNum scriptnum(num); BOOST_CHECK(verify(bignum, scriptnum)); std::vector<unsigned char> vch = bignum.getvch(); CScriptNum10 bignum2(bignum.getvch(), false); vch = scriptnum.getvch(); CScriptNum scriptnum2(scriptnum.getvch(), false); BOOST_CHECK(verify(bignum2, scriptnum2)); CScriptNum10 bignum3(scriptnum2.getvch(), false); CScriptNum scriptnum3(bignum2.getvch(), false); BOOST_CHECK(verify(bignum3, scriptnum3)); }
static void CheckAdd(const int64_t& num1, const int64_t& num2) { const CBigNum bignum1(num1); const CBigNum bignum2(num2); const CScriptNum scriptnum1(num1); const CScriptNum scriptnum2(num2); CBigNum bignum3(num1); CBigNum bignum4(num1); CScriptNum scriptnum3(num1); CScriptNum scriptnum4(num1); // int64_t overflow is undefined. bool invalid = (((num2 > 0) && (num1 > (std::numeric_limits<int64_t>::max() - num2))) || ((num2 < 0) && (num1 < (std::numeric_limits<int64_t>::min() - num2)))); if (!invalid) { BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + scriptnum2)); BOOST_CHECK(verify(bignum1 + bignum2, scriptnum1 + num2)); BOOST_CHECK(verify(bignum1 + bignum2, scriptnum2 + num1)); } }