Introduce vpour to CTransaction.
Transactions of version 2 and above contain a `vpour` field which is a vector of `CPourTx` objects that embody our protocol. We introduce serialization primitives for boost::array (we intend for changing the amount of inputs and outputs in the circuit to be simple). SIGHASH_* operations hash this field like any other for now.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "streams.h"
|
||||
#include "hash.h"
|
||||
#include "test/test_bitcoin.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -15,6 +16,39 @@ using namespace std;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(serialize_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(boost_arrays)
|
||||
{
|
||||
boost::array<std::string, 2> test_case = {string("zub"), string("baz")};
|
||||
CDataStream ss(SER_DISK, 0);
|
||||
ss << test_case;
|
||||
|
||||
auto hash = Hash(ss.begin(), ss.end());
|
||||
|
||||
BOOST_CHECK_MESSAGE("037a75620362617a" == HexStr(ss.begin(), ss.end()), HexStr(ss.begin(), ss.end()));
|
||||
BOOST_CHECK_MESSAGE(hash == uint256S("13cb12b2dd098dced0064fe4897c97f907ba3ed36ae470c2e7fc2b1111eba35a"), "actually got: " << hash.ToString());
|
||||
|
||||
{
|
||||
// note: boost array of size 2 should serialize to be the same as a tuple
|
||||
std::pair<std::string, std::string> test_case_2 = {string("zub"), string("baz")};
|
||||
|
||||
CDataStream ss2(SER_DISK, 0);
|
||||
ss2 << test_case_2;
|
||||
|
||||
auto hash2 = Hash(ss2.begin(), ss2.end());
|
||||
|
||||
BOOST_CHECK(hash == hash2);
|
||||
}
|
||||
|
||||
boost::array<std::string, 2> decoded_test_case;
|
||||
ss >> decoded_test_case;
|
||||
|
||||
BOOST_CHECK(decoded_test_case == test_case);
|
||||
|
||||
boost::array<int32_t, 2> test = {100, 200};
|
||||
|
||||
BOOST_CHECK_EQUAL(GetSerializeSize(test, 0, 0), 8);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(sizes)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(sizeof(char), GetSerializeSize(char(0), 0));
|
||||
|
||||
Reference in New Issue
Block a user