Skip to content

Commit

Permalink
GH-981 Change is_eos_vm_oc_whitelisted to take a n instead of suffix …
Browse files Browse the repository at this point in the history
…and call n.suffix() itself. Added additional tests.
  • Loading branch information
heifner committed Nov 6, 2024
1 parent 5e2d38f commit 569450c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/apply_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ action_name apply_context::get_sender() const {

bool apply_context::is_eos_vm_oc_whitelisted() const {
return receiver.prefix() == config::system_account_name || // "eosio"_n
control.is_eos_vm_oc_whitelisted(receiver.suffix());
control.is_eos_vm_oc_whitelisted(receiver);
}

// Context | OC?
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5702,8 +5702,8 @@ bool controller::is_profiling(account_name account) const {
return my->conf.profile_accounts.find(account) != my->conf.profile_accounts.end();
}

bool controller::is_eos_vm_oc_whitelisted(account_name suffix) const {
return my->conf.eos_vm_oc_whitelist_suffixes.count(suffix) > 0;
bool controller::is_eos_vm_oc_whitelisted(account_name n) const {
return my->conf.eos_vm_oc_whitelist_suffixes.count(n.suffix()) > 0;
}

chain_id_type controller::get_chain_id()const {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ namespace eosio::chain {

bool is_profiling(account_name name) const;

bool is_eos_vm_oc_whitelisted(account_name suffix) const;
bool is_eos_vm_oc_whitelisted(account_name n) const;

chain_id_type get_chain_id()const;

Expand Down
1 change: 1 addition & 0 deletions plugins/chain_plugin/test/plugin_config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ BOOST_AUTO_TEST_CASE(chain_plugin_eos_vm_oc_whitelist) {
BOOST_CHECK(app->initialize<eosio::chain_plugin>(args.size(), const_cast<char**>(args.data())));
auto& plugin = app->get_plugin<eosio::chain_plugin>();
BOOST_CHECK(plugin.chain().is_eos_vm_oc_whitelisted(eosio::chain::name{"hello"}));
BOOST_CHECK(plugin.chain().is_eos_vm_oc_whitelisted(eosio::chain::name{"xs.hello"}));
BOOST_CHECK(!plugin.chain().is_eos_vm_oc_whitelisted(eosio::chain::name{"xsat"}));
}
2 changes: 2 additions & 0 deletions unittests/misc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ BOOST_AUTO_TEST_CASE(name_suffix_additional_tests) {
BOOST_CHECK_EQUAL( name{"eosioacco.unj"}.suffix(), name{"unj"} );
BOOST_CHECK_EQUAL( name{"eosioaccou.nj"}.suffix(), name{"nj"} );
BOOST_CHECK_EQUAL( name{"eosioaccoun.j"}.suffix(), name{"j"} );
BOOST_CHECK_EQUAL( name{"eosioaccounja"}.suffix(), name{"eosioaccounja"} );
BOOST_CHECK_EQUAL( name{"eosioaccounj"}.suffix(), name{"eosioaccounj"} );

BOOST_CHECK_EQUAL( name{"e.o.s.i.o.a.c"}.suffix(), name{"c"} );
BOOST_CHECK_EQUAL( name{"eos.ioa.cco"}.suffix(), name{"cco"} );
Expand Down

0 comments on commit 569450c

Please sign in to comment.