Implement tx_irrelevant_sig exception, fix assert_op_test
This commit is contained in:
parent
b429107dc0
commit
54103da9a8
5 changed files with 12 additions and 6 deletions
|
|
@ -73,7 +73,7 @@ namespace graphene { namespace chain {
|
|||
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( tx_irrelevant_sig, graphene::chain::transaction_exception, 3030004, "irrelevant signature included" )
|
||||
FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::chain::transaction_exception, 3030005,
|
||||
"committee account cannot directly approve transaction" )
|
||||
|
||||
|
|
|
|||
|
|
@ -227,7 +227,11 @@ void verify_authority( const vector<operation>& ops, const flat_set<public_key_t
|
|||
tx_missing_other_auth, "Missing Owner Authority ${id}", ("id",id)("auth",*get_owner(id)) );
|
||||
}
|
||||
|
||||
FC_ASSERT( !s.remove_unused_signatures(), "Unnecessary signatures detected" );
|
||||
GRAPHENE_ASSERT(
|
||||
!s.remove_unused_signatures(),
|
||||
tx_irrelevant_sig,
|
||||
"Unnecessary signature(s) detected"
|
||||
);
|
||||
} FC_CAPTURE_AND_RETHROW( (ops)(sigs) ) }
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1025,7 +1025,7 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture )
|
|||
trx.sign( alice_key );
|
||||
trx.sign( charlie_key );
|
||||
// Signed by third-party Charlie (irrelevant key, not in authority)
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception );
|
||||
GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, skip ), tx_irrelevant_sig );
|
||||
}
|
||||
FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/committee_member_object.hpp>
|
||||
|
|
@ -625,7 +626,7 @@ BOOST_FIXTURE_TEST_CASE( double_sign_check, database_fixture )
|
|||
BOOST_TEST_MESSAGE( "Verify that signing with an extra, unused key fails" );
|
||||
trx.signatures.pop_back();
|
||||
trx.sign(generate_private_key("bogus"));
|
||||
GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), fc::exception );
|
||||
GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), tx_irrelevant_sig );
|
||||
|
||||
BOOST_TEST_MESSAGE( "Verify that signing once with the proper key passes" );
|
||||
trx.signatures.pop_back();
|
||||
|
|
|
|||
|
|
@ -1029,8 +1029,9 @@ BOOST_AUTO_TEST_CASE( assert_op_test )
|
|||
PUSH_TX( db, trx );
|
||||
|
||||
// nathan checks that his public key is not equal to the given value (fail)
|
||||
op.predicates.back() = account_name_eq_lit_predicate{ nathan_id, "dan" };
|
||||
trx.operations.back() = op;
|
||||
trx.clear();
|
||||
op.predicates.emplace_back(account_name_eq_lit_predicate{ nathan_id, "dan" });
|
||||
trx.operations.push_back(op);
|
||||
trx.sign(nathan_private_key);
|
||||
GRAPHENE_CHECK_THROW( PUSH_TX( db, trx ), fc::exception );
|
||||
} FC_LOG_AND_RETHROW()
|
||||
|
|
|
|||
Loading…
Reference in a new issue