Remove scriptPubKey/scriptSig from CPourTx, and add randomSeed.

This commit is contained in:
Sean Bowe
2016-05-04 18:26:19 -06:00
parent 5a2db9e283
commit 2140639309
9 changed files with 544 additions and 565 deletions

File diff suppressed because one or more lines are too long

View File

@@ -124,12 +124,12 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
} else {
pourtx.vpub_new = insecure_rand() % 100000000;
}
RandomScript(pourtx.scriptPubKey);
RandomScript(pourtx.scriptSig);
pourtx.anchor = GetRandHash();
pourtx.serials[0] = GetRandHash();
pourtx.serials[1] = GetRandHash();
pourtx.ephemeralKey = GetRandHash();
pourtx.randomSeed = GetRandHash();
pourtx.ciphertexts[0] = {insecure_rand() % 100, insecure_rand() % 100};
pourtx.ciphertexts[1] = {insecure_rand() % 100, insecure_rand() % 100};
pourtx.macs[0] = GetRandHash();

View File

@@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification)
auto path = witness.path();
// create CPourTx
CScript scriptPubKey;
uint256 pubKeyHash;
boost::array<PourInput, ZC_NUM_JS_INPUTS> inputs = {
PourInput(coin, addr, path),
PourInput(INCREMENTAL_MERKLE_TREE_DEPTH) // dummy input of zero value
@@ -346,8 +346,8 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification)
};
{
CPourTx pourtx(p, scriptPubKey, uint256(rt), inputs, outputs, 0, 0);
BOOST_CHECK(pourtx.Verify(p));
CPourTx pourtx(p, pubKeyHash, uint256(rt), inputs, outputs, 0, 0);
BOOST_CHECK(pourtx.Verify(p, pubKeyHash));
CDataStream ss(SER_DISK, CLIENT_VERSION);
ss << pourtx;
@@ -356,20 +356,20 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification)
ss >> pourtx_deserialized;
BOOST_CHECK(pourtx_deserialized == pourtx);
BOOST_CHECK(pourtx_deserialized.Verify(p));
BOOST_CHECK(pourtx_deserialized.Verify(p, pubKeyHash));
}
{
// Ensure that the balance equation is working.
BOOST_CHECK_THROW(CPourTx(p, scriptPubKey, uint256(rt), inputs, outputs, 10, 0), std::invalid_argument);
BOOST_CHECK_THROW(CPourTx(p, scriptPubKey, uint256(rt), inputs, outputs, 0, 10), std::invalid_argument);
BOOST_CHECK_THROW(CPourTx(p, pubKeyHash, uint256(rt), inputs, outputs, 10, 0), std::invalid_argument);
BOOST_CHECK_THROW(CPourTx(p, pubKeyHash, uint256(rt), inputs, outputs, 0, 10), std::invalid_argument);
}
{
// Ensure that it won't verify if the root is changed.
auto test = CPourTx(p, scriptPubKey, uint256(rt), inputs, outputs, 0, 0);
auto test = CPourTx(p, pubKeyHash, uint256(rt), inputs, outputs, 0, 0);
test.anchor = GetRandHash();
BOOST_CHECK(!test.Verify(p));
BOOST_CHECK(!test.Verify(p, pubKeyHash));
}
}