Electroneum
Loading...
Searching...
No Matches
gen_ring_signature_big Class Reference

#include <ring_signature_1.h>

Inheritance diagram for gen_ring_signature_big:
Collaboration diagram for gen_ring_signature_big:

Public Member Functions

 gen_ring_signature_big ()
bool generate (std::vector< test_event_entry > &events) const
bool check_balances_1 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_balances_2 (cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
Public Member Functions inherited from test_chain_unit_base
void register_callback (const std::string &cb_name, verify_callback cb)
bool verify (const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
bool check_tx_verification_context_array (const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)

Additional Inherited Members

Public Types inherited from test_chain_unit_base
typedef boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
typedef std::map< std::string, verify_callbackcallbacks_map

Detailed Description

Definition at line 76 of file ring_signature_1.h.

Constructor & Destructor Documentation

◆ gen_ring_signature_big()

gen_ring_signature_big::gen_ring_signature_big ( )

Definition at line 222 of file ring_signature_1.cpp.

223 : m_test_size(100)
224 , m_tx_amount(MK_COINS(29))
225{
228}
#define REGISTER_CALLBACK(CB_NAME, CLBACK)
Definition chaingen.h:827
#define MK_COINS(amount)
Definition chaingen.h:1060
bool check_balances_2(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
bool check_balances_1(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
Here is the call graph for this function:

Member Function Documentation

◆ check_balances_1()

bool gen_ring_signature_big::check_balances_1 ( cryptonote::core & c,
size_t ev_index,
const std::vector< test_event_entry > & events )

Definition at line 289 of file ring_signature_1.cpp.

290{
291 DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_big::check_balances_1");
292
293 m_bob_account = boost::get<account_base>(events[1]);
294 m_alice_account = boost::get<account_base>(events[1 + m_test_size]);
295
296 std::vector<block> blocks;
297 bool r = c.get_blocks(0, 2 * m_test_size + CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, blocks);
299
300 std::vector<cryptonote::block> chain;
301 map_hash2tx_t mtx;
302 r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
304 CHECK_EQ(m_tx_amount + TESTS_DEFAULT_FEE, get_balance(m_bob_account, chain, mtx));
305 CHECK_EQ(0, get_balance(m_alice_account, chain, mtx));
306
307 for (size_t i = 2; i < 1 + m_test_size; ++i)
308 {
309 const account_base& an_account = boost::get<account_base>(events[i]);
310 uint64_t balance = m_tx_amount + TESTS_DEFAULT_FEE * i;
311 CHECK_EQ(balance, get_balance(an_account, chain, mtx));
312 }
313
314 return true;
315}
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition chaingen.cpp:940
#define DEFINE_TESTS_ERROR_CONTEXT(text)
Definition chaingen.h:1056
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition chaingen.h:163
#define CHECK_TEST_CONDITION(cond)
Definition chaingen.h:1057
#define TESTS_DEFAULT_FEE
Definition chaingen.h:1061
#define CHECK_EQ(v1, v2)
Definition chaingen.h:1058
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block > > &blocks, std::vector< cryptonote::blobdata > &txs) const
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
crypto::hash get_block_hash(uint64_t height)
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_balances_2()

bool gen_ring_signature_big::check_balances_2 ( cryptonote::core & c,
size_t ev_index,
const std::vector< test_event_entry > & events )

Definition at line 317 of file ring_signature_1.cpp.

318{
319 DEFINE_TESTS_ERROR_CONTEXT("gen_ring_signature_big::check_balances_2");
320
321 std::vector<block> blocks;
322 bool r = c.get_blocks(0, 2 * m_test_size + CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW, blocks);
324
325 std::vector<cryptonote::block> chain;
326 map_hash2tx_t mtx;
327 r = find_block_chain(events, chain, mtx, get_block_hash(blocks.back()));
329 CHECK_EQ(0, get_balance(m_bob_account, chain, mtx));
330 CHECK_EQ(m_tx_amount, get_balance(m_alice_account, chain, mtx));
331
332 for (size_t i = 2; i < 1 + m_test_size; ++i)
333 {
334 const account_base& an_account = boost::get<account_base>(events[i]);
335 uint64_t balance = m_tx_amount + TESTS_DEFAULT_FEE * i;
336 CHECK_EQ(balance, get_balance(an_account, chain, mtx));
337 }
338
339 std::vector<size_t> tx_outs;
340 uint64_t transfered;
341 const transaction& tx = boost::get<transaction>(events[events.size() - 3]);
342 lookup_acc_outs(m_alice_account.get_keys(), boost::get<transaction>(events[events.size() - 3]), get_tx_pub_key_from_extra(tx), get_additional_tx_pub_keys_from_extra(tx), tx_outs, transfered);
343 CHECK_EQ(m_tx_amount, transfered);
344
345 return true;
346}
std::vector< crypto::public_key > get_additional_tx_pub_keys_from_extra(const std::vector< uint8_t > &tx_extra)
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
bool lookup_acc_outs(const account_keys &acc, const transaction &tx, std::vector< size_t > &outs, uint64_t &etn_transfered)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate()

bool gen_ring_signature_big::generate ( std::vector< test_event_entry > & events) const

Check ring signature with m_test_size-1 sources.

  • Create 100 accounts.
  • Create 100 blocks, each block contains transaction from the miner to account[i].
  • Create transaction with ring signature from account[99] to Alice with nmix = 99.
  • Check balances.

Definition at line 237 of file ring_signature_1.cpp.

238{
239 std::vector<account_base> accounts(m_test_size);
240 std::vector<block> blocks;
241 blocks.reserve(m_test_size + CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW);
242
243 uint64_t ts_start = 1338224400;
244 GENERATE_ACCOUNT(miner_account);
245
246 MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start);
247
248 for (size_t i = 0; i < m_test_size; ++i)
249 {
250 MAKE_ACCOUNT(events, an_account);
251 accounts[i] = an_account;
252 }
253 MAKE_ACCOUNT(events, alice_account);
254
255 size_t blk_0r_idx = events.size();
256 REWIND_BLOCKS(events, blk_0r, blk_0, miner_account);
257 blocks.push_back(blk_0);
258 for (size_t i = blk_0r_idx; i < events.size(); ++i)
259 {
260 blocks.push_back(boost::get<block>(events[i]));
261 }
262
263 for (size_t i = 0; i < m_test_size; ++i)
264 {
265 block blk_with_unlocked_out = blocks[blocks.size() - 1 - CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW];
266 MAKE_TX_LIST_START(events, txs_blk_i, miner_account, accounts[i], m_tx_amount, blk_with_unlocked_out);
267 for (size_t j = 0; j <= i; ++j)
268 {
269 MAKE_TX_LIST(events, txs_blk_i, miner_account, accounts[i], TESTS_DEFAULT_FEE, blk_with_unlocked_out);
270 }
271 MAKE_NEXT_BLOCK_TX_LIST(events, blk_i, blocks.back(), miner_account, txs_blk_i);
272 blocks.push_back(blk_i);
273
274 std::vector<cryptonote::block> chain;
275 map_hash2tx_t mtx;
276 bool r = find_block_chain(events, chain, mtx, get_block_hash(blk_i));
277 CHECK_AND_NO_ASSERT_MES(r, false, "failed to call find_block_chain");
278 std::cout << i << ": " << get_balance(accounts[i], chain, mtx) << std::endl;
279 }
280
281 DO_CALLBACK(events, "check_balances_1");
282 MAKE_TX_MIX(events, tx_0, accounts[0], alice_account, m_tx_amount, m_test_size - 1, blocks.back());
283 MAKE_NEXT_BLOCK_TX1(events, blk_1, blocks.back(), miner_account, tx_0);
284 DO_CALLBACK(events, "check_balances_2");
285
286 return true;
287}
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition chaingen.h:890
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition chaingen.h:935
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
Definition chaingen.h:833
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
Definition chaingen.h:867
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
Definition chaingen.h:820
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
Definition chaingen.h:933
#define MAKE_ACCOUNT(VEC_EVENTS, account)
Definition chaingen.h:815
#define GENERATE_ACCOUNT(account)
Definition chaingen.h:801
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
Definition chaingen.h:893
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
Definition chaingen.h:849
#define CHECK_AND_NO_ASSERT_MES(expr, fail_ret_val, message)
Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/core_tests/ring_signature_1.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/tests/core_tests/ring_signature_1.cpp