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

EVM: Code tests #1181

Merged
merged 4 commits into from
Feb 8, 2023
Merged

EVM: Code tests #1181

merged 4 commits into from
Feb 8, 2023

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Feb 8, 2023

Closes filecoin-project/ref-fvm#1552

  • CODESIZE
  • CODECOPY
  • EXTCODESIZE
  • EXTCODECOPY
  • EXTCODEHASH

@vyzo vyzo requested a review from Stebalien February 8, 2023 13:11
@vyzo vyzo mentioned this pull request Feb 8, 2023
5 tasks
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

LGTM but it would be nice to test a few more edge cases.

let result = m.step();
assert!(result.is_ok(), "execution step failed");
assert_eq!(m.state.stack.len(), 0);
assert_eq!(m.state.memory[0..3], m.bytecode[1..4]);
Copy link
Member

Choose a reason for hiding this comment

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

Can we test that that last byte is zero?

}

#[test]
fn test_codecopy_oob() {
Copy link
Member

Choose a reason for hiding this comment

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

Can we test fully OOB? I.e., start OOB, start at the end, etc.?

}

#[test]
fn test_codecopy_partial() {
Copy link
Member

Choose a reason for hiding this comment

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

Copy nothing?

}

#[test]
fn test_extcodecopy_partial() {
Copy link
Member

Choose a reason for hiding this comment

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

ditto above. Copy nothing should work.

}

#[test]
fn test_extcodecopy_oob() {
Copy link
Member

Choose a reason for hiding this comment

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

Ditto above. Try starting past the end.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Eh, we need to test memory access directly. @vyzo is right, this is good to go.

@Stebalien Stebalien merged commit 1dd0bb0 into next Feb 8, 2023
@Stebalien Stebalien deleted the next-unit-tests-1552 branch February 8, 2023 18:28
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.

2 participants