exceptions: Implement missing_auth exceptions
This commit is contained in:
parent
8ff25b813f
commit
d4e4854eb6
3 changed files with 24 additions and 6 deletions
|
|
@ -17,7 +17,9 @@
|
|||
*/
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/evaluator.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
#include <graphene/chain/transaction_evaluation_state.hpp>
|
||||
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/delegate_object.hpp>
|
||||
|
|
@ -90,14 +92,24 @@ database& generic_evaluator::db()const { return trx_state->db(); }
|
|||
operation_get_required_authorities( op, other_auths );
|
||||
|
||||
for( auto id : active_auths )
|
||||
FC_ASSERT(verify_authority(id(db()), authority::active) ||
|
||||
verify_authority(id(db()), authority::owner), "", ("id", id));
|
||||
GRAPHENE_ASSERT(
|
||||
verify_authority(id(db()), authority::active) ||
|
||||
verify_authority(id(db()), authority::owner),
|
||||
tx_missing_active_auth,
|
||||
"missing required active authority ${id}", ("id", id));
|
||||
|
||||
for( auto id : owner_auths )
|
||||
FC_ASSERT(verify_authority(id(db()), authority::owner), "", ("id", id));
|
||||
GRAPHENE_ASSERT(
|
||||
verify_authority(id(db()), authority::owner),
|
||||
tx_missing_owner_auth,
|
||||
"missing required owner authority ${id}", ("id", id));
|
||||
|
||||
for( const auto& auth : other_auths )
|
||||
FC_ASSERT(trx_state->check_authority(auth), "invalid authority", ("auth",auth)("sigs",trx_state->_sigs));
|
||||
GRAPHENE_ASSERT(
|
||||
trx_state->check_authority(auth),
|
||||
tx_missing_other_auth,
|
||||
"missing required authority ${auth}",
|
||||
("auth",auth)("sigs",trx_state->_sigs));
|
||||
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ namespace graphene { namespace chain {
|
|||
FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, graphene::chain::chain_exception, 3050000, "operation evaluation exception" )
|
||||
FC_DECLARE_DERIVED_EXCEPTION( utility_exception, graphene::chain::chain_exception, 3060000, "utility method exception" )
|
||||
|
||||
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::chain::transaction_exception, 3030001, "missing required active authority" )
|
||||
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::chain::transaction_exception, 3030002, "missing required owner authority" )
|
||||
FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::chain::transaction_exception, 3030003, "missing required other authority" )
|
||||
//FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_authority, graphene::chain::transaction_exception, 3030004, "irrelevant authority" )
|
||||
|
||||
FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, graphene::chain::utility_exception, 3060001, "invalid pts address" )
|
||||
FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::chain_exception, 37006, "insufficient feeds" )
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
#include <graphene/chain/operations.hpp>
|
||||
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
|
|
@ -84,10 +85,10 @@ BOOST_AUTO_TEST_CASE( override_transfer_test )
|
|||
trx.operations.push_back(otrans);
|
||||
|
||||
BOOST_TEST_MESSAGE( "Require throwing without signature" );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), fc::exception);
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), tx_missing_active_auth );
|
||||
BOOST_TEST_MESSAGE( "Require throwing with dan's signature" );
|
||||
trx.sign( dan_private_key );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), fc::exception);
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, 0 ), tx_missing_active_auth );
|
||||
BOOST_TEST_MESSAGE( "Pass with issuer's signature" );
|
||||
trx.signatures.clear();
|
||||
trx.sign( sam_private_key );
|
||||
|
|
|
|||
Loading…
Reference in a new issue