-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basic supernode stakes unit tests #322
Open
mbg033
wants to merge
8
commits into
develop
Choose a base branch
from
feature/rta-tests
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
632559c
core_tests: introducing rta tests for stake transactions
mbg033 dcf8f3d
get_block_reward: pre-mine works for every hf version (for core_tests)
mbg033 039e6d6
cryptonote::core: return StakeTransactionProcessor for tests
mbg033 fbc58a4
StakeTransactionProcessor: set_active_from_height method added
mbg033 76571ca
add: construct_stake_tx_* functions
mbg033 6d3ff94
simple supernode stake tests
mbg033 67cb74a
renamed unlock_height to be consistent with the existing terminology
mbg033 aba7fd1
[WIP] generating many stake txes
mbg033 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# How to use 'core-tests' framework | ||
|
||
## Steps needed to create another test case; | ||
|
||
1. create a struct as a subclass `test_chain_unit_base` class, implement it in "my_test.h|cpp" files, | ||
e.g.: | ||
|
||
``` | ||
struct gen_rta_tests : public test_chain_unit_base | ||
{ | ||
gen_rta_tests(); | ||
|
||
// test generator method: here we define the test sequence | ||
bool generate(std::vector<test_event_entry>& events) const; | ||
|
||
|
||
bool check1(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& events); | ||
bool check_stake_registered(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& events); | ||
}; | ||
``` | ||
|
||
|
||
1.1. implement test sequence in `bool generate(std::vector<test_event_entry>& events) const;` method; | ||
|
||
1.2. "check" functions should follow the interface: | ||
``` | ||
bool check_function(cryptonote::core& c, size_t ev_index, const std::vector<test_event_entry>& events); | ||
``` | ||
|
||
1.3. register "check" functions with `REGISTER_CALLBACK_METHOD` macro invoked in constructor: | ||
``` | ||
REGISTER_CALLBACK_METHOD(gen_rta_tests, check_function); | ||
``` | ||
|
||
|
||
2. add | ||
|
||
``` | ||
#include "your_test.h" to the "chaingen_test_list.h" | ||
``` | ||
|
||
3. add | ||
|
||
``` | ||
GENERATE_AND_PLAY(gen_rta_tests); | ||
``` | ||
|
||
to the `chaingen_main.cpp` inside | ||
|
||
``` | ||
else if (command_line::get_arg(vm, arg_generate_and_play_test_data)) | ||
{ | ||
``` | ||
|
||
block | ||
|
||
|
||
4. (optional) define a `gen_test_options` struct representing testing hardfork table, which will be passed to cryptonote::core instance, e.g.: | ||
|
||
``` | ||
template<> | ||
struct get_test_options<gen_rta_tests> { | ||
const std::pair<uint8_t, uint64_t> hard_forks[4] = {std::make_pair(1, 0), std::make_pair(13, 14), std::make_pair(14, 73)}; | ||
const cryptonote::test_options test_options = { | ||
hard_forks | ||
}; | ||
}; | ||
``` | ||
|
||
|
||
5. implement `bool generate(std::vector<test_event_entry>& events) const;` method where you place your test flow. Your job is to generate blocks and transactions which will be played through 'cryptonote::core' instance; | ||
Blocks and transactions to be added to the `events` vector. Normally it added by macros so you don't have to add it manually. | ||
|
||
5.1. use `MAKE_GENESIS_BLOCK` macro to make a genesis block and add it the chain | ||
5.2. use `MAKE_NEXT_BLOCK` macro to create and add block to the chain | ||
5.3. use `construct_tx_with_fee` function to create transaction | ||
5.4. use `MAKE_NEXT_BLOCK_TX1` macro to add transaction to a block and add block to the chain | ||
|
||
6. schedule a "check" function call at the specific blockchain state inside `generate` method | ||
``` | ||
DO_CALLBACK(events, "check_function"); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think unlock_height should be unlock_time, which is what is used everywhere else