Electroneum
Loading...
Searching...
No Matches
gen_tx_check_input_unlock_time Struct Reference

#include <tx_validation.h>

Inheritance diagram for gen_tx_check_input_unlock_time:
Collaboration diagram for gen_tx_check_input_unlock_time:

Public Member Functions

bool generate (std::vector< test_event_entry > &events) const
Public Member Functions inherited from get_tx_validation_base
 get_tx_validation_base ()
bool check_tx_verification_context (const cryptonote::tx_verification_context &tvc, bool tx_added, size_t event_idx, const cryptonote::transaction &)
bool check_block_verification_context (const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
bool mark_invalid_block (cryptonote::core &, size_t ev_index, const std::vector< test_event_entry > &)
bool mark_invalid_tx (cryptonote::core &, size_t ev_index, const std::vector< test_event_entry > &)
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 143 of file tx_validation.h.

Member Function Documentation

◆ generate()

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

Definition at line 574 of file tx_validation.cpp.

575{
576 static const size_t tests_count = 6;
577
578 uint64_t ts_start = 1338224400;
579
580 GENERATE_ACCOUNT(miner_account);
581 MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start);
582 REWIND_BLOCKS_N(events, blk_1, blk_0, miner_account, tests_count - 1);
583 REWIND_BLOCKS(events, blk_1r, blk_1, miner_account);
584
585 std::array<account_base, tests_count> accounts;
586 for (size_t i = 0; i < tests_count; ++i)
587 {
588 MAKE_ACCOUNT(events, acc);
589 accounts[i] = acc;
590 }
591
592 std::list<transaction> txs_0;
593 auto make_tx_to_acc = [&](size_t acc_idx, uint64_t unlock_time)
594 {
595 txs_0.push_back(make_simple_tx_with_unlock_time(events, blk_1, miner_account, accounts[acc_idx],
596 MK_COINS(1) + TESTS_DEFAULT_FEE, unlock_time));
597 events.push_back(txs_0.back());
598 };
599
600 uint64_t blk_3_height = get_block_height(blk_1r) + 2;
601 make_tx_to_acc(0, 0);
602 make_tx_to_acc(1, blk_3_height - 1);
603 make_tx_to_acc(2, blk_3_height);
604 make_tx_to_acc(3, blk_3_height + 1);
605 make_tx_to_acc(4, time(0) - 1);
606 make_tx_to_acc(5, time(0) + 60 * 60);
607 MAKE_NEXT_BLOCK_TX_LIST(events, blk_2, blk_1r, miner_account, txs_0);
608
609 std::list<transaction> txs_1;
610 auto make_tx_from_acc = [&](size_t acc_idx, bool invalid)
611 {
612 transaction tx = make_simple_tx_with_unlock_time(events, blk_2, accounts[acc_idx], miner_account, MK_COINS(1), 0);
613 if (invalid)
614 {
615 DO_CALLBACK(events, "mark_invalid_tx");
616 }
617 else
618 {
619 txs_1.push_back(tx);
620 }
621 events.push_back(tx);
622 };
623
624 make_tx_from_acc(0, false);
625 make_tx_from_acc(1, false);
626 make_tx_from_acc(2, false);
627 make_tx_from_acc(3, true);
628 make_tx_from_acc(4, false);
629 make_tx_from_acc(5, true);
630 MAKE_NEXT_BLOCK_TX_LIST(events, blk_3, blk_2, miner_account, txs_1);
631
632 return true;
633}
time_t time
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
Definition chaingen.h:890
#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 REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT)
Definition chaingen.h:889
#define MK_COINS(amount)
Definition chaingen.h:1060
#define TESTS_DEFAULT_FEE
Definition chaingen.h:1061
#define MAKE_ACCOUNT(VEC_EVENTS, account)
Definition chaingen.h:815
#define GENERATE_ACCOUNT(account)
Definition chaingen.h:801
uint64_t get_block_height(const block &b)
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

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