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

Refactor test_vm::utils in terms of an abstract VM trait #1269

Merged
merged 12 commits into from
Apr 6, 2023

Conversation

alexytsu
Copy link
Contributor

@alexytsu alexytsu commented Apr 5, 2023

Next step of #1236

Moves enough of the functionality of the current TestVM into the VM trait such that the all the utils can be factored in terms of the trait.

Some functionality has shifted to immutable patterns (e.g. with_epoch -> set_epoch). The trait assumes non-mutable borrows so mutability is achieved with RefCell when needed. The tests will be refactored in terms of the trait in a followup PR.

There's some duplication at the moment between concrete behaviour of TestVM and behaviours in the VM trait but these will be easier to remove in a follow-up (when the tests themselves are refactored in terms of the VM trait

@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2023

Codecov Report

Merging #1269 (8fea3f2) into master (f393b91) will decrease coverage by 0.20%.
The diff coverage is 92.16%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1269      +/-   ##
==========================================
- Coverage   90.88%   90.68%   -0.20%     
==========================================
  Files         133      133              
  Lines       26755    26880     +125     
==========================================
+ Hits        24316    24377      +61     
- Misses       2439     2503      +64     
Impacted Files Coverage Δ
actors/power/src/lib.rs 83.01% <ø> (-0.58%) ⬇️
test_vm/src/util.rs 98.84% <91.33%> (-1.08%) ⬇️
test_vm/src/lib.rs 84.09% <93.33%> (+0.93%) ⬆️

... and 16 files with indirect coverage changes

Comment on lines +163 to +165
impl<'bs, BS> VM<BS> for TestVM<'bs, BS>
where
BS: Blockstore,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually will move TestVM to a separate submodule, but I've left it in this file so the diff is clear

) -> Result<MessageResult, TestVMError>;

/// Sets the epoch to the specified value
fn set_epoch(&self, epoch: ChainEpoch);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This replaces with_epoch. However, all usages of with_epoch in the current tests were

let v = v.with_epoch(200);

so the non-mutability/cloneability wasn't being used

@alexytsu alexytsu marked this pull request as ready for review April 5, 2023 07:10
@alexytsu alexytsu requested a review from anorth April 5, 2023 07:11
@alexytsu alexytsu enabled auto-merge April 6, 2023 00:58
@alexytsu alexytsu added this pull request to the merge queue Apr 6, 2023
Merged via the queue into master with commit c41968f Apr 6, 2023
@alexytsu alexytsu deleted the alex/1236-refactored-utils branch April 6, 2023 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants