Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Add is_code_cached and use in tests to verify #607

Merged
merged 3 commits into from
Jan 9, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Dec 30, 2022

Adds new is_code_cached method to wasm_interface for use by tests to check if the code for a given account has been cached.

Resolves #260

@heifner heifner requested a review from linh2931 December 30, 2022 18:16
@heifner heifner added the OCI Work exclusive to OCI team label Dec 30, 2022
cmadh pushed a commit to cmadh/leap that referenced this pull request Jan 2, 2023
…-head-of-abieos

[3.2] mandel: rebase abieos to the head of abieos submodule (fixing compile warnings)
@@ -63,6 +63,9 @@ namespace eosio { namespace chain {
//Immediately exits currently running wasm. UB is called when no wasm running
void exit();

//Returns true if the code is cached
size_t is_code_cached(const digest_type& code_hash, const uint8_t& vm_type, const uint8_t& vm_version) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant for the return value to be bool?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks. Fixed.

bool base_tester::is_code_cached( eosio::chain::account_name name ) const {
const auto& db = control->db();
const account_metadata_object* receiver_account = &db.template get<account_metadata_object,by_name>( name );
if ( receiver_account->code_hash == digest_type() ) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check receiver_account != nullptr first? If the account doesn't exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get() throws unknown key if not found.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops yeah I was looking at find()

@heifner heifner merged commit 2c12c72 into main Jan 9, 2023
@heifner heifner deleted the GH-260-code-cache-test branch January 9, 2023 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use github issue instead of #warning directives in api_tests.cpp
3 participants