Fixes for indentation and local variable names.

This commit is contained in:
Sean Bowe
2016-07-16 16:45:41 -06:00
parent 28173cd0de
commit 22de160219
11 changed files with 113 additions and 113 deletions

View File

@@ -217,78 +217,78 @@ BOOST_AUTO_TEST_CASE(anchors_flush_test)
}
}
BOOST_AUTO_TEST_CASE(chained_pours)
BOOST_AUTO_TEST_CASE(chained_joinsplits)
{
CCoinsViewTest base;
CCoinsViewCacheTest cache(&base);
ZCIncrementalMerkleTree tree;
JSDescription ptx1;
ptx1.anchor = tree.root();
ptx1.commitments[0] = appendRandomCommitment(tree);
ptx1.commitments[1] = appendRandomCommitment(tree);
JSDescription js1;
js1.anchor = tree.root();
js1.commitments[0] = appendRandomCommitment(tree);
js1.commitments[1] = appendRandomCommitment(tree);
// Although it's not possible given our assumptions, if
// two pours create the same treestate twice, we should
// two joinsplits create the same treestate twice, we should
// still be able to anchor to it.
JSDescription ptx1b;
ptx1b.anchor = tree.root();
ptx1b.commitments[0] = ptx1.commitments[0];
ptx1b.commitments[1] = ptx1.commitments[1];
JSDescription js1b;
js1b.anchor = tree.root();
js1b.commitments[0] = js1.commitments[0];
js1b.commitments[1] = js1.commitments[1];
JSDescription ptx2;
JSDescription ptx3;
JSDescription js2;
JSDescription js3;
ptx2.anchor = tree.root();
ptx3.anchor = tree.root();
js2.anchor = tree.root();
js3.anchor = tree.root();
ptx2.commitments[0] = appendRandomCommitment(tree);
ptx2.commitments[1] = appendRandomCommitment(tree);
js2.commitments[0] = appendRandomCommitment(tree);
js2.commitments[1] = appendRandomCommitment(tree);
ptx3.commitments[0] = appendRandomCommitment(tree);
ptx3.commitments[1] = appendRandomCommitment(tree);
js3.commitments[0] = appendRandomCommitment(tree);
js3.commitments[1] = appendRandomCommitment(tree);
{
CMutableTransaction mtx;
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(js2);
BOOST_CHECK(!cache.HaveJoinSplitRequirements(mtx));
}
{
// ptx2 is trying to anchor to ptx1 but ptx1
// js2 is trying to anchor to js1 but js1
// appears afterwards -- not a permitted ordering
CMutableTransaction mtx;
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(js2);
mtx.vjoinsplit.push_back(js1);
BOOST_CHECK(!cache.HaveJoinSplitRequirements(mtx));
}
{
CMutableTransaction mtx;
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(js1);
mtx.vjoinsplit.push_back(js2);
BOOST_CHECK(cache.HaveJoinSplitRequirements(mtx));
}
{
CMutableTransaction mtx;
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx3);
mtx.vjoinsplit.push_back(js1);
mtx.vjoinsplit.push_back(js2);
mtx.vjoinsplit.push_back(js3);
BOOST_CHECK(cache.HaveJoinSplitRequirements(mtx));
}
{
CMutableTransaction mtx;
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx1b);
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx3);
mtx.vjoinsplit.push_back(js1);
mtx.vjoinsplit.push_back(js1b);
mtx.vjoinsplit.push_back(js2);
mtx.vjoinsplit.push_back(js3);
BOOST_CHECK(cache.HaveJoinSplitRequirements(mtx));
}

View File

@@ -105,7 +105,7 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0;
int ins = (insecure_rand() % 4) + 1;
int outs = fSingle ? ins : (insecure_rand() % 4) + 1;
int pours = (insecure_rand() % 4);
int joinsplits = (insecure_rand() % 4);
for (int in = 0; in < ins; in++) {
tx.vin.push_back(CTxIn());
CTxIn &txin = tx.vin.back();
@@ -121,26 +121,26 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
RandomScript(txout.scriptPubKey);
}
if (tx.nVersion >= 2) {
for (int pour = 0; pour < pours; pour++) {
JSDescription pourtx;
for (int js = 0; js < joinsplits; js++) {
JSDescription jsdesc;
if (insecure_rand() % 2 == 0) {
pourtx.vpub_old = insecure_rand() % 100000000;
jsdesc.vpub_old = insecure_rand() % 100000000;
} else {
pourtx.vpub_new = insecure_rand() % 100000000;
jsdesc.vpub_new = insecure_rand() % 100000000;
}
pourtx.anchor = GetRandHash();
pourtx.nullifiers[0] = GetRandHash();
pourtx.nullifiers[1] = GetRandHash();
pourtx.ephemeralKey = GetRandHash();
pourtx.randomSeed = GetRandHash();
randombytes_buf(pourtx.ciphertexts[0].begin(), pourtx.ciphertexts[0].size());
randombytes_buf(pourtx.ciphertexts[1].begin(), pourtx.ciphertexts[1].size());
randombytes_buf(pourtx.proof.begin(), pourtx.proof.size());
pourtx.macs[0] = GetRandHash();
pourtx.macs[1] = GetRandHash();
jsdesc.anchor = GetRandHash();
jsdesc.nullifiers[0] = GetRandHash();
jsdesc.nullifiers[1] = GetRandHash();
jsdesc.ephemeralKey = GetRandHash();
jsdesc.randomSeed = GetRandHash();
randombytes_buf(jsdesc.ciphertexts[0].begin(), jsdesc.ciphertexts[0].size());
randombytes_buf(jsdesc.ciphertexts[1].begin(), jsdesc.ciphertexts[1].size());
randombytes_buf(jsdesc.proof.begin(), jsdesc.proof.size());
jsdesc.macs[0] = GetRandHash();
jsdesc.macs[1] = GetRandHash();
tx.vjoinsplit.push_back(pourtx);
tx.vjoinsplit.push_back(jsdesc);
}
unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES];