aboutsummaryrefslogtreecommitdiff
path: root/tests/core_tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-06-15 23:37:13 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-08-28 21:28:37 +0100
commitdc4aad7eb5fffa450d4c5eb094cf962e45b2f43a (patch)
treee8fc99783d63582ff026adee2584478b0e799933 /tests/core_tests
parentdb_lmdb: update reset for recent db changes (diff)
downloadmonero-dc4aad7eb5fffa450d4c5eb094cf962e45b2f43a.tar.xz
add rct to the protocol
It is not yet constrained to a fork, so don't use on the real network or you'll be orphaned or rejected.
Diffstat (limited to 'tests/core_tests')
-rw-r--r--tests/core_tests/block_validation.cpp4
-rw-r--r--tests/core_tests/chaingen.cpp4
-rw-r--r--tests/core_tests/double_spend.inl2
-rw-r--r--tests/core_tests/integer_overflow.cpp2
-rw-r--r--tests/core_tests/transaction_tests.cpp25
-rw-r--r--tests/core_tests/tx_validation.cpp12
-rw-r--r--tests/core_tests/v2_tests.cpp10
7 files changed, 25 insertions, 34 deletions
diff --git a/tests/core_tests/block_validation.cpp b/tests/core_tests/block_validation.cpp
index bce0980bf..3989a71c9 100644
--- a/tests/core_tests/block_validation.cpp
+++ b/tests/core_tests/block_validation.cpp
@@ -335,7 +335,7 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
tx_source_entry se;
se.amount = blk_0.miner_tx.vout[0].amount;
- se.outputs.push_back(std::make_pair(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key));
+ se.push_output(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(blk_0.miner_tx);
se.real_output_in_tx_index = 0;
@@ -377,7 +377,7 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
tx_source_entry se;
se.amount = blk_1.miner_tx.vout[0].amount;
- se.outputs.push_back(std::make_pair(0, boost::get<txout_to_key>(blk_1.miner_tx.vout[0].target).key));
+ se.push_output(0, boost::get<txout_to_key>(blk_1.miner_tx.vout[0].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(blk_1.miner_tx);
se.real_output_in_tx_index = 0;
diff --git a/tests/core_tests/chaingen.cpp b/tests/core_tests/chaingen.cpp
index efd0bf1ea..a181c1d16 100644
--- a/tests/core_tests/chaingen.cpp
+++ b/tests/core_tests/chaingen.cpp
@@ -412,7 +412,7 @@ bool fill_output_entries(std::vector<output_index>& out_indices, size_t sender_o
if (append)
{
const txout_to_key& otk = boost::get<txout_to_key>(oi.out);
- output_entries.push_back(tx_source_entry::output_entry(oi.idx, otk.key));
+ output_entries.push_back(tx_source_entry::output_entry(oi.idx, rct::ctkey({rct::pk2rct(otk.key), rct::identity()})));
}
}
@@ -544,7 +544,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
out.target = txout_to_key(out_eph_public_key);
tx.vout.push_back(out);
- tx.version = CURRENT_TRANSACTION_VERSION;
+ tx.version = 1;
tx.unlock_time = height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
return true;
diff --git a/tests/core_tests/double_spend.inl b/tests/core_tests/double_spend.inl
index 55e5f4ec9..e9ec1c2cd 100644
--- a/tests/core_tests/double_spend.inl
+++ b/tests/core_tests/double_spend.inl
@@ -128,7 +128,7 @@ bool gen_double_spend_in_tx<txs_keeped_by_block>::generate(std::vector<test_even
std::vector<cryptonote::tx_source_entry> sources;
cryptonote::tx_source_entry se;
se.amount = tx_0.vout[0].amount;
- se.outputs.push_back(std::make_pair(0, boost::get<cryptonote::txout_to_key>(tx_0.vout[0].target).key));
+ se.push_output(0, boost::get<cryptonote::txout_to_key>(tx_0.vout[0].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(tx_0);
se.real_output_in_tx_index = 0;
diff --git a/tests/core_tests/integer_overflow.cpp b/tests/core_tests/integer_overflow.cpp
index 55a55b7d8..aad377d6d 100644
--- a/tests/core_tests/integer_overflow.cpp
+++ b/tests/core_tests/integer_overflow.cpp
@@ -61,7 +61,7 @@ namespace
{
cryptonote::tx_source_entry se;
se.amount = tx.vout[out_idx].amount;
- se.outputs.push_back(std::make_pair(0, boost::get<cryptonote::txout_to_key>(tx.vout[out_idx].target).key));
+ se.push_output(0, boost::get<cryptonote::txout_to_key>(tx.vout[out_idx].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(tx);
se.real_output_in_tx_index = out_idx;
diff --git a/tests/core_tests/transaction_tests.cpp b/tests/core_tests/transaction_tests.cpp
index 5c866b618..8a1638c1d 100644
--- a/tests/core_tests/transaction_tests.cpp
+++ b/tests/core_tests/transaction_tests.cpp
@@ -82,29 +82,18 @@ bool test_transaction_generation_and_ring_signature()
src.amount = 70368744177663;
{
tx_output_entry oe;
- oe.first = 0;
- oe.second = boost::get<txout_to_key>(tx_mine_1.vout[0].target).key;
- src.outputs.push_back(oe);
- oe.first = 1;
- oe.second = boost::get<txout_to_key>(tx_mine_2.vout[0].target).key;
- src.outputs.push_back(oe);
+ src.push_output(0, boost::get<txout_to_key>(tx_mine_1.vout[0].target).key, src.amount);
- oe.first = 2;
- oe.second = boost::get<txout_to_key>(tx_mine_3.vout[0].target).key;
- src.outputs.push_back(oe);
+ src.push_output(1, boost::get<txout_to_key>(tx_mine_2.vout[0].target).key, src.amount);
- oe.first = 3;
- oe.second = boost::get<txout_to_key>(tx_mine_4.vout[0].target).key;
- src.outputs.push_back(oe);
+ src.push_output(2, boost::get<txout_to_key>(tx_mine_3.vout[0].target).key, src.amount);
- oe.first = 4;
- oe.second = boost::get<txout_to_key>(tx_mine_5.vout[0].target).key;
- src.outputs.push_back(oe);
+ src.push_output(3, boost::get<txout_to_key>(tx_mine_4.vout[0].target).key, src.amount);
- oe.first = 5;
- oe.second = boost::get<txout_to_key>(tx_mine_6.vout[0].target).key;
- src.outputs.push_back(oe);
+ src.push_output(4, boost::get<txout_to_key>(tx_mine_5.vout[0].target).key, src.amount);
+
+ src.push_output(5, boost::get<txout_to_key>(tx_mine_6.vout[0].target).key, src.amount);
src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(tx_mine_2);
src.real_output = 1;
diff --git a/tests/core_tests/tx_validation.cpp b/tests/core_tests/tx_validation.cpp
index f72c906e5..cf018c8e2 100644
--- a/tests/core_tests/tx_validation.cpp
+++ b/tests/core_tests/tx_validation.cpp
@@ -39,7 +39,7 @@ namespace
{
struct tx_builder
{
- void step1_init(size_t version = CURRENT_TRANSACTION_VERSION, uint64_t unlock_time = 0)
+ void step1_init(size_t version = 1, uint64_t unlock_time = 0)
{
m_tx.vin.clear();
m_tx.vout.clear();
@@ -108,9 +108,13 @@ namespace
BOOST_FOREACH(const tx_source_entry& src_entr, sources)
{
std::vector<const crypto::public_key*> keys_ptrs;
+ std::vector<crypto::public_key> keys(src_entr.outputs.size());
+ size_t j = 0;
BOOST_FOREACH(const tx_source_entry::output_entry& o, src_entr.outputs)
{
- keys_ptrs.push_back(&o.second);
+ keys[j] = rct::rct2pk(o.second.dest);
+ keys_ptrs.push_back(&keys[j]);
+ ++j;
}
m_tx.signatures.push_back(std::vector<crypto::signature>());
@@ -136,7 +140,7 @@ namespace
fill_tx_sources_and_destinations(events, blk_head, from, to, amount, TESTS_DEFAULT_FEE, 0, sources, destinations);
tx_builder builder;
- builder.step1_init(CURRENT_TRANSACTION_VERSION, unlock_time);
+ builder.step1_init(1, unlock_time);
builder.step2_fill_inputs(from.get_keys(), sources);
builder.step3_fill_outputs(destinations);
builder.step4_calc_hash();
@@ -177,7 +181,7 @@ bool gen_tx_big_version::generate(std::vector<test_event_entry>& events) const
fill_tx_sources_and_destinations(events, blk_0, miner_account, miner_account, MK_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
tx_builder builder;
- builder.step1_init(CURRENT_TRANSACTION_VERSION + 1, 0);
+ builder.step1_init(1 + 1, 0);
builder.step2_fill_inputs(miner_account.get_keys(), sources);
builder.step3_fill_outputs(destinations);
builder.step4_calc_hash();
diff --git a/tests/core_tests/v2_tests.cpp b/tests/core_tests/v2_tests.cpp
index fe6b8b279..d9328d13a 100644
--- a/tests/core_tests/v2_tests.cpp
+++ b/tests/core_tests/v2_tests.cpp
@@ -79,7 +79,6 @@ bool gen_v2_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
}
// create a tx with the Nth outputs of miner's block reward
- typedef tx_source_entry::output_entry tx_output_entry;
std::vector<tx_source_entry> sources;
for (size_t out_idx_idx = 0; out_idx[out_idx_idx] >= 0; ++out_idx_idx) {
sources.resize(sources.size()+1);
@@ -88,13 +87,12 @@ bool gen_v2_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
src.amount = blocks[0].miner_tx.vout[out_idx[out_idx_idx]].amount;
std::cout << "using " << print_money(src.amount) << " output at index " << out_idx[out_idx_idx] << std::endl;
for (int m = 0; m <= mixin; ++m) {
- tx_output_entry oe;
+ int idx;
if (is_valid_decomposed_amount(src.amount))
- oe.first = m+1; // one out of that size per miner tx, including genesis
+ idx = m+1; // one out of that size per miner tx, including genesis
else
- oe.first = 0; // dusty, no other output of that size
- oe.second = boost::get<txout_to_key>(blocks[m].miner_tx.vout[out_idx[out_idx_idx]].target).key;
- src.outputs.push_back(oe);
+ idx = 0; // dusty, no other output of that size
+ src.push_output(idx, boost::get<txout_to_key>(blocks[m].miner_tx.vout[out_idx[out_idx_idx]].target).key, src.amount);
}
src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(blocks[0].miner_tx);
src.real_output = 0;