46 const std::function<
bool(std::vector<tx_source_entry> &sources, std::vector<tx_destination_entry> &destinations,
size_t tx_idx)> &pre_tx,
47 const std::function<
bool(
transaction &tx,
size_t tx_idx)> &post_tx)
const 58 for (
size_t n = 0; n < 12; ++n) {
64 false,
"Failed to generate block");
65 events.push_back(
blocks[n]);
80 false,
"Failed to generate block");
81 events.push_back(
blocks[12+i]);
88 std::vector<transaction> rct_txes;
90 std::vector<crypto::hash> starting_rct_tx_hashes;
91 static const uint64_t input_amounts_available[] = {5000000000000, 30000000000000, 100000000000, 80000000000};
92 for (
size_t n = 0; n < n_txes; ++n)
94 std::vector<tx_source_entry> sources;
99 const uint64_t needed_amount = input_amounts_available[n];
100 src.
amount = input_amounts_available[n];
101 size_t real_index_in_tx = 0;
102 for (
size_t m = 0; m <= mixin; ++m) {
103 size_t index_in_tx = 0;
104 for (
size_t i = 0; i <
blocks[m].miner_tx.vout.size(); ++i)
105 if (
blocks[m].miner_tx.vout[i].amount == needed_amount)
110 real_index_in_tx = index_in_tx;
121 std::vector<tx_destination_entry> destinations;
122 for (
int o = 0; amounts_paid[o] != (
uint64_t)-1; ++o)
124 td.
amount = amounts_paid[o];
125 destinations.push_back(td);
128 if (pre_tx && !pre_tx(sources, destinations, n))
130 MDEBUG(
"pre_tx returned failure");
135 std::vector<crypto::secret_key> additional_tx_keys;
136 std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
138 rct_txes.resize(rct_txes.size() + 1);
139 bool r =
construct_tx_and_get_tx_key(miner_accounts[n].get_keys(), subaddresses, sources, destinations,
cryptonote::account_public_address{}, std::vector<uint8_t>(), rct_txes.back(), 0, tx_key, additional_tx_keys,
true, rct_config[n]);
142 if (post_tx && !post_tx(rct_txes.back(), n))
144 MDEBUG(
"post_tx returned failure");
152 for (
int o = 0; amounts_paid[o] != (
uint64_t)-1; ++o)
160 const uint8_t type = rct_txes.back().rct_signatures.type;
167 while (amounts_paid[0] != (
size_t)-1)
173 events.push_back(rct_txes);
179 false,
"Failed to generate block");
182 events.push_back(blk_txes);
193 size_t n_sizes = 0, n_amounts = 0;
194 for (
size_t n = 0; n < tx_idx; ++n)
196 while (sizes[0] != (
size_t)-1)
200 while (sizes[n_sizes] != (
size_t)-1)
201 n_amounts += sizes[n_sizes++];
204 for (
size_t n = 0; n < n_sizes; ++n)
211 const size_t mixin = 10;
213 const size_t bp_sizes[] = {1, (size_t)-1};
215 return generate_with(events, mixin, 1, amounts_paid,
true, rct_config, NULL, [&](
const cryptonote::transaction &tx,
size_t tx_idx){
return check_bp(tx, tx_idx, bp_sizes,
"gen_bp_tx_valid_1"); });
220 const size_t mixin = 10;
223 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, NULL);
228 const size_t mixin = 10;
230 const size_t bp_sizes[] = {2, (size_t)-1};
232 return generate_with(events, mixin, 1, amounts_paid,
true, rct_config, NULL, [&](
const cryptonote::transaction &tx,
size_t tx_idx){
return check_bp(tx, tx_idx, bp_sizes,
"gen_bp_tx_valid_2"); });
237 const size_t mixin = 10;
239 const size_t bp_sizes[] = {4, (size_t)-1};
241 return generate_with(events, mixin, 1, amounts_paid,
true, rct_config, NULL, [&](
const cryptonote::transaction &tx,
size_t tx_idx){
return check_bp(tx, tx_idx, bp_sizes,
"gen_bp_tx_valid_3"); });
246 const size_t mixin = 10;
247 const uint64_t amounts_paid[] = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, (
uint64_t)-1};
248 const size_t bp_sizes[] = {16, (size_t)-1};
250 return generate_with(events, mixin, 1, amounts_paid,
true, rct_config, NULL, [&](
const cryptonote::transaction &tx,
size_t tx_idx){
return check_bp(tx, tx_idx, bp_sizes,
"gen_bp_tx_valid_16"); });
255 const size_t mixin = 10;
256 const uint64_t amounts_paid[] = {1000, 1000, 1000, 1000, 1000, 1000, 1000, (
uint64_t)-1};
258 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, NULL);
263 const size_t mixin = 10;
264 const uint64_t amounts_paid[] = {1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, (
uint64_t)-1};
266 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, NULL);
271 const size_t mixin = 10;
272 const uint64_t amounts_paid[] = {1000, 1000, (size_t)-1, 1000, 1000, (
uint64_t)-1};
273 const size_t bp_sizes[] = {2, (size_t)-1, 2, (
size_t)-1};
275 return generate_with(events, mixin, 2, amounts_paid,
true, rct_config, NULL, [&](
const cryptonote::transaction &tx,
size_t tx_idx){
return check_bp(tx, tx_idx, bp_sizes,
"gen_bp_txs_valid_2_and_2"); });
280 const size_t mixin = 10;
281 const uint64_t amounts_paid[] = {1000, 1000, (
uint64_t)-1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, (
uint64_t)-1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, (
uint64_t)-1};
283 return generate_with(events, mixin, 3, amounts_paid,
false, rct_config, NULL, NULL);
288 const size_t mixin = 10;
289 const uint64_t amounts_paid[] = {11111115000, 11111115000, (
uint64_t)-1, 11111115000, 11111115000, 11111115001, (
uint64_t)-1, 11111115000, 11111115002, (
uint64_t)-1, 11111115000, 11111115000, 11111115000, 11111115003, (
uint64_t)-1};
291 const size_t bp_sizes[] = {2, (size_t)-1, 4, (
size_t)-1, 2, (size_t)-1, 4, (
size_t)-1};
292 return generate_with(events, mixin, 4, amounts_paid,
true, rct_config, NULL, [&](
const cryptonote::transaction &tx,
size_t tx_idx) {
return check_bp(tx, tx_idx, bp_sizes,
"gen_bp_txs_valid_2_and_3_and_2_and_4"); });
298 const size_t mixin = 10;
301 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, [&](
cryptonote::transaction &tx,
size_t idx){
313 const size_t mixin = 10;
316 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, [&](
cryptonote::transaction &tx,
size_t idx){
326 const size_t mixin = 10;
329 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, [&](
cryptonote::transaction &tx,
size_t idx){
340 const size_t mixin = 10;
343 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, [&](
cryptonote::transaction &tx,
size_t idx){
354 const size_t mixin = 10;
357 return generate_with(events, mixin, 1, amounts_paid,
false, rct_config, NULL, [&](
cryptonote::transaction &tx,
size_t tx_idx){
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
size_t n_bulletproof_max_amounts(const Bulletproof &proof)
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
crypto::public_key real_out_tx_key
bool generate(std::vector< test_event_entry > &events) const
bool generate_with(std::vector< test_event_entry > &events, size_t mixin, size_t n_txes, const uint64_t *amounts_paid, bool valid, const rct::RCTConfig *rct_config, const std::function< bool(std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, size_t)> &pre_tx, const std::function< bool(cryptonote::transaction &tx, size_t)> &post_tx) const
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
crypto::secret_key generate(const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false, bool two_random=false)
etn_amount decodeRct(const rctSig &rv, const key &sk, unsigned int i, key &mask, hw::device &hwdev)
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
bool generate(std::vector< test_event_entry > &events) const
#define CHECK_TEST_CONDITION(cond)
const account_keys & get_keys() const
bool is_rct_bulletproof(int type)
Holds cryptonote related classes and helpers.
bool generate(std::vector< test_event_entry > &events) const
crypto::public_key m_spend_public_key
rct::rctSig rct_signatures
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
device & get_device(const std::string &device_descriptor)
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
std::string obj_to_json_str(T &obj)
unsigned __int64 uint64_t
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
void push_output(uint64_t idx, const crypto::public_key &k, uint64_t amount)
account_public_address addr
account_public_address m_account_address
size_t real_output_in_tx_index
crypto::hash get_transaction_hash(const transaction &t)
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN
#define GENERATE_ACCOUNT(account)
bool generate(std::vector< test_event_entry > &events) const
bool generate(std::vector< test_event_entry > &events) const
#define DEFINE_TESTS_ERROR_CONTEXT(text)
bool construct_tx_and_get_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, const uint32_t account_major_offset, const cryptonote::network_type nettype)
bool generate(std::vector< test_event_entry > &events) const
bool check_bp(const cryptonote::transaction &tx, size_t tx_idx, const size_t *sizes, const char *context) const
std::vector< Bulletproof > bulletproofs
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
bool generate(std::vector< test_event_entry > &events) const
etn_amount decodeRctSimple(const rctSig &rv, const key &sk, unsigned int i, key &mask, hw::device &hwdev)
Bulletproof bulletproof_PROVE(const rct::key &v, const rct::key &gamma)