diff --git a/libraries/chain/chain_controller.cpp b/libraries/chain/chain_controller.cpp index 23bfa1f5a31..0c915275334 100644 --- a/libraries/chain/chain_controller.cpp +++ b/libraries/chain/chain_controller.cpp @@ -555,7 +555,7 @@ void chain_controller::validate_uniqueness( const SignedTransaction& trx )const if( !should_check_for_duplicate_transactions() ) return; auto transaction = _db.find(trx.id()); - EOS_ASSERT(transaction == nullptr, transaction_exception, "Transaction is not unique"); + EOS_ASSERT(transaction == nullptr, tx_duplicate, "Transaction is not unique"); } void chain_controller::validate_tapos(const SignedTransaction& trx)const { diff --git a/libraries/chain/include/eos/chain/exceptions.hpp b/libraries/chain/include/eos/chain/exceptions.hpp index d9acb6f49f1..095a05298fa 100644 --- a/libraries/chain/include/eos/chain/exceptions.hpp +++ b/libraries/chain/include/eos/chain/exceptions.hpp @@ -52,6 +52,7 @@ namespace eos { namespace chain { FC_DECLARE_DERIVED_EXCEPTION( tx_missing_scope, eos::chain::transaction_exception, 3030008, "missing required scope" ) FC_DECLARE_DERIVED_EXCEPTION( tx_missing_recipient, eos::chain::transaction_exception, 3030009, "missing required recipient" ) FC_DECLARE_DERIVED_EXCEPTION( checktime_exceeded, eos::chain::transaction_exception, 3030010, "allotted processing time was exceeded" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate, eos::chain::transaction_exception, 3030011, "duplicate transaction" ) FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, eos::chain::utility_exception, 3060001, "invalid pts address" ) FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, eos::chain::chain_exception, 37006, "insufficient feeds" ) diff --git a/libraries/native_contract/eos_contract.cpp b/libraries/native_contract/eos_contract.cpp index 7366c4bfeec..73f5a22e0ed 100644 --- a/libraries/native_contract/eos_contract.cpp +++ b/libraries/native_contract/eos_contract.cpp @@ -377,15 +377,17 @@ void apply_eos_updateauth(apply_context& context) { context.require_authorization(update.account); db.get(update.account); - auto& parent = db.get(boost::make_tuple(update.account, update.parent)); for (auto accountPermission : update.authority.accounts) { db.get(accountPermission.permission.account); db.get(boost::make_tuple(accountPermission.permission.account, accountPermission.permission.permission)); } - const auto& permission = db.find(boost::make_tuple(update.account, update.permission)); + auto permission = db.find(boost::make_tuple(update.account, update.permission)); + auto& parent = db.get(boost::make_tuple(update.account, update.parent)); if (permission) { + EOS_ASSERT(parent.id == permission->parent, message_precondition_exception, + "Changing parent authority is not currently supported"); db.modify(*permission, [&update, parent = parent.id](permission_object& po) { po.auth = update.authority; po.parent = parent; diff --git a/tests/tests/native_contract_tests.cpp b/tests/tests/native_contract_tests.cpp index 7b5ce6c166c..69d35ea492b 100644 --- a/tests/tests/native_contract_tests.cpp +++ b/tests/tests/native_contract_tests.cpp @@ -390,12 +390,26 @@ BOOST_FIXTURE_TEST_CASE(auth_tests, testing_fixture) { Make_Account(chain, alice); chain.produce_blocks(); + BOOST_CHECK_THROW(Delete_Authority(chain, alice, "active"), message_validate_exception); + BOOST_CHECK_THROW(Delete_Authority(chain, alice, "owner"), message_validate_exception); + Make_Key(k1); Set_Authority(chain, alice, "spending", "active", Key_Authority(k1_public_key)); BOOST_CHECK_THROW(Set_Authority(chain, alice, "spending", "spending", Key_Authority(k1_public_key)), message_validate_exception); - Set_Authority(chain, alice, "spending", "owner", Key_Authority(k1_public_key)); + BOOST_CHECK_THROW(Set_Authority(chain, alice, "spending", "owner", Key_Authority(k1_public_key)), + message_precondition_exception); + Delete_Authority(chain, alice, "spending"); + + chain.produce_blocks(); + + Set_Authority(chain, alice, "trading", "active", Key_Authority(k1_public_key)); + Set_Authority(chain, alice, "spending", "trading", Key_Authority(k1_public_key)); + BOOST_CHECK_THROW(Delete_Authority(chain, alice, "trading"), message_precondition_exception); + BOOST_CHECK_THROW(Set_Authority(chain, alice, "trading", "spending", Key_Authority(k1_public_key)), + message_precondition_exception); Delete_Authority(chain, alice, "spending"); + Delete_Authority(chain, alice, "trading"); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END()