-
Notifications
You must be signed in to change notification settings - Fork 53
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
Update FPI tests #957
Update FPI tests #957
Conversation
736165e
to
8dcbb7f
Compare
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.
Looks good to me!
Seems like a good approach to test the memory layout using the TransactionContext
and test the account loading and the procedure index map using TransactionExecutor
.
Left some optional comments.
assert_eq!( | ||
try_read_root_mem_value(&process, NATIVE_ACCOUNT_DATA_PTR + ACCOUNT_DATA_LENGTH as u32 * 2), | ||
None, | ||
"Memory starting from 6144 should stay uninitialized" | ||
); |
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.
Just for my understanding: If this was initialized it would mean we would've loaded the foreign account a second time and thus we would have three accounts loaded in total (1 native account, 2 foreign accounts)?
Perhaps you can add a short comment to this assertion to explain this context.
#[test] | ||
fn test_load_foreign_account_twice() { | ||
fn test_fpi_basic() { |
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.
fn test_fpi_basic() { | |
fn test_fpi_load_foreign_account_code() { |
Nit: Suggestion for a more specific name for the test, but totally optional.
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 totally agree that the name of this test should be updated to be more specific, but I'm not sure about the name. In fact this is an integration test, which checks the correctness of the foreign procedure execution on every stage: we load the foreign account code, provide the mast forest to the executor, construct the account procedure maps and execute the foreign procedure to obtain the data from the foreign account's storage slot. So I think that test_fpi_load_foreign_account_code
is not the best option, because it reflects only one of the execution stages. May be something like test_fpi_execute_foreign_procedure
? So the logic is that the execution of the foreign procedure is the result achieved by the all previous stages, so it's kind of illustrating the accomplished work
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.
Sure, your suggestion sounds better to reflect the overall test better although it is somewhat generic, but still fits here. Together with a doc comment it's totally fine imo.
// GET ITEM | ||
// -------------------------------------------------------------------------------------------- | ||
let storage_slot = AccountStorage::mock_item_0().slot; | ||
fn test_fpi_memory() { |
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.
Nit: Same here - would be great if you could add a short doc comment explaining the two phases of the test.
101a5bd
to
a058b91
Compare
a058b91
to
0565492
Compare
During the rebase I noticed another issue, related to the FPI: in case a user wants to access the map storage slot, the internals of this map should be preliminarily loaded to the advice provider. |
0565492
to
6678418
Compare
Also I noticed two more "structural" problems:
|
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.
Looks good! Thank you! Not a very deep review from me - but I left one question inline.
Also, we should probably merge this after #969 as I think we'll need to do some minor rebasing after this.
let tx_context = mock_chain | ||
.build_tx_context(native_account.id(), &[], &[]) | ||
.advice_inputs(advice_inputs.clone()) | ||
// .foreign_account_codes(vec![foreign_account.code().clone()]) |
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.
Should this be deleted? Or could it be uncommented and then you could use TransactionContext::execute()
unless I missed something
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 left this line because I wanted to come to some decision about what I described in the second point of my comment. Because I think we can optimize the way we provide the foreign account code, so we will be able to use only foreign_account_codes
function.
9efea6c
to
d654bb0
Compare
d654bb0
to
2f35f36
Compare
@phklive need this PR to be merged for his Oracle task, so I'll merge the current state into |
This PR updates the existing FPI tests and adds one additional.
Closes: #917