add hardfork guards

This commit is contained in:
Alfredo Garcia 2019-09-21 12:19:57 -03:00
parent 6efbf84339
commit 0a5d694568
3 changed files with 22 additions and 3 deletions

View file

@ -140,6 +140,18 @@ struct proposal_operation_hardfork_visitor
FC_ASSERT( vbco.balance_type == vesting_balance_type::unspecified, "balance_type in vesting create not allowed yet!" );
}
void operator()(const son_create_operation &v) const {
FC_ASSERT( block_time >= HARDFORK_SON_TIME, "son_create_operation not allowed yet!" );
}
void operator()(const son_update_operation &v) const {
FC_ASSERT( block_time >= HARDFORK_SON_TIME, "son_update_operation not allowed yet!" );
}
void operator()(const son_delete_operation &v) const {
FC_ASSERT( block_time >= HARDFORK_SON_TIME, "son_delete_operation not allowed yet!" );
}
// loop and self visit in proposals
void operator()(const proposal_create_operation &v) const {
for (const op_wrapper &op : v.proposed_ops)

View file

@ -2,11 +2,13 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/son_object.hpp>
#include <graphene/chain/hardfork.hpp>
namespace graphene { namespace chain {
void_result create_son_evaluator::do_evaluate(const son_create_operation& op)
{ try{
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
FC_ASSERT(db().get(op.owner_account).is_lifetime_member(), "Only Lifetime members may register a SON.");
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }
@ -28,6 +30,7 @@ object_id_type create_son_evaluator::do_apply(const son_create_operation& op)
void_result update_son_evaluator::do_evaluate(const son_update_operation& op)
{ try {
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass
const auto& idx = db().get_index_type<son_member_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_id) != idx.end() );
return void_result();
@ -48,6 +51,7 @@ object_id_type update_son_evaluator::do_apply(const son_update_operation& op)
void_result delete_son_evaluator::do_evaluate(const son_delete_operation& op)
{ try {
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON_HARDFORK"); // can be removed after HF date pass
const auto& idx = db().get_index_type<son_member_index>().indices().get<by_id>();
FC_ASSERT( idx.find(op.son_id) != idx.end() );
return void_result();

View file

@ -41,6 +41,11 @@ public:
BOOST_FIXTURE_TEST_SUITE( son_operation_tests, database_fixture )
BOOST_AUTO_TEST_CASE( create_son_test ) {
generate_blocks( HARDFORK_SON_TIME );
while( db.head_block_time() <= HARDFORK_SON_TIME )
{
generate_block();
}
std::string test_url = "https://create_son_test";
test_create_son_member_evaluator test_eval( db );
son_create_operation op;
@ -60,9 +65,7 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
}
BOOST_AUTO_TEST_CASE( update_son_test ){
INVOKE(create_son_test);
std::string new_url = "https://anewurl.com";
test_update_son_member_evaluator test_eval( db );
son_update_operation op;