-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Replaces MockInvokeContext by ThisInvokeContext in tests #20881
Replaces MockInvokeContext by ThisInvokeContext in tests #20881
Conversation
646c1fa
to
90ce4d4
Compare
e564ef5
to
6ae28d9
Compare
Codecov Report
@@ Coverage Diff @@
## master #20881 +/- ##
=======================================
Coverage 81.5% 81.5%
=======================================
Files 497 498 +1
Lines 140320 140238 -82
=======================================
- Hits 114440 114379 -61
+ Misses 25880 25859 -21 |
89d4aa2
to
3d92394
Compare
30f15bf
to
cf3ea97
Compare
cf3ea97
to
9c29e44
Compare
@@ -1,8 +1,8 @@ | |||
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))] | |||
#![allow(clippy::integer_arithmetic)] | |||
#![allow(clippy::integer_arithmetic)] // TODO: Remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still needs to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have another branch for a follow-up PR on this one, which is going to move everything from sdk::process_instruction
into the program-runtime-crate. And it will remove that clippy flag.
https://github.com/Lichtso/solana/tree/refactor/move_process_instruction_in_program_runtime
); | ||
|
||
// Case: Account not a program | ||
keyed_accounts[0].3.borrow_mut().set_executable(false); | ||
assert_eq!( | ||
Err(InstructionError::InvalidInstructionData), | ||
process_instruction(&loader_id, &[], &keyed_accounts), | ||
Err(InstructionError::IncorrectProgramId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice: The error code changed as it was previously testing:
process_instruction(&loader_id, &[], &[], &keyed_accounts)
which is incorrect and was changed to:
process_instruction(&loader_id, &[0], &[], &keyed_accounts)
This happened because it originally tested with &loader_id
instead of &program_key
which the other tests used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good, I don't see anything blaring but it's very hard to review when the PR is so large and includes so many unrelated changes.
It would have been helpful if the following had been broken out into separate PRs so that it is easier to identify functional changes:
- Wholesale changes from
new_rand()
tonew_unique()
- Switching to
new_ref()
- Renames and code changes unrelated to the problem description
- Moving files around and making large changes
Already trying, in fact this is already broken up from a much larger refactoring I have locally.
I agree, that should have been its own PR. I simply forgot that I changed it to have deterministic tests in order to compare that before and after are equal.
If you mean the moving of I do certainly realize how much happened in this PR and that it was hard to review. I am very grateful! |
…#20881) * Replaces MockInvokeContext by ThisInvokeContext in BpfLoader, SystemInstructionProcessor, CLIs, ConfigProcessor, StakeProcessor and VoteProcessor. * Finally, removes MockInvokeContext, MockComputeMeter and MockLogger. * Adjusts assert_instruction_count test. * Moves ThisInvokeContext to the program-runtime crate.
…ana-labs#20881)" This reverts commit 347ddd2.
Problem
MockInvokeContext
would need its own ABIv2 compatibility and still usesKeyedAccount
s.So going forward it is easier to just route all the tests to use
ThisInvokeContext
instead, so that ABIv2 and the inter-operation with the old ABI can both be tested in one structure / implementation.Summary of Changes
MockInvokeContext
byThisInvokeContext
.MockInvokeContext
,MockComputeMeter
andMockLogger
.ThisInvokeContext
to the program-runtime crate to avoid a cyclic dependency with the runtime crate in the program tests.Fixes #