v2.1: Fix - SVM account_loader tests (backport of #3448) #3520
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Some tests in svm/src/account_loader.rs currently do test situations which are impossible to construct in production and do miss cases which are. The issue is a slightly incorrect setup of the program accounts involved. The tests assume that the program cache of the program cache is protocol relevant, which it is not, instead the SVM program loader is.
Otherwise these tests (introduced in #3045) are pretty good, so shout-out to Hana for writing them!
Summary of Changes
Fixes
test_load_transaction_accounts_program_account_executable_bypass
:Now constructs a loader-v2 tombstone, instead of an impossible program cache entry (a closed built-in) which would not be produced by the SVM program loader. This also changes the expected owner of the loaded program account from the
native_loader
tobpf_loader
and thus insertsbpf_loader
in the list of loaded accounts.Fixes
test_load_transaction_accounts_data_sizes
:Now initializes the loader-v3 program with a valid
UpgradeableLoaderState::Program
pointing to a programdata account containingUpgradeableLoaderState::ProgramData
and an ELF. Before the test simply forced in an impossible program cache entry (a closed built-in) which would not be produced by the SVM program loader. Also, uses the correctly initialized program cache for all tests now. Before it had some with an empty cache, which again can't happen in production because the cache is replenished before the account loader runs. Furthermore, adds two test cases for write lock demotion of loader-v3.Removes
test_load_transaction_accounts_program_account_not_found_but_loaded
:The test constructs a scenario in which the program cache contains an entry even tough the accounts database has no account at the given key. This is not possible because the program cache only has entries for accounts owned by the loaders. A non existent account can not be owned by a loader.
Fixes #
This is an automatic backport of pull request #3448 done by [Mergify](https://mergify.com).