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

add tests to invalid dynamic jumps #145

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

alk0x1
Copy link

@alk0x1 alk0x1 commented Jul 18, 2024

Add tests for two cases of dynamic jumps that should return a ExecutionError::Trap

crates/polkavm/src/tests.rs Outdated Show resolved Hide resolved
crates/polkavm/src/tests.rs Outdated Show resolved Hide resolved
crates/polkavm/src/tests.rs Outdated Show resolved Hide resolved
crates/polkavm/src/tests.rs Outdated Show resolved Hide resolved
crates/polkavm/src/tests.rs Outdated Show resolved Hide resolved
alk0x1 and others added 5 commits July 22, 2024 10:02
add early return in the failing test
inlined the code in the test and deleted the helper functions
match result {
Ok(()) => panic!("Expected ExecutionError::Trap, but got Ok"),
Err(e) => assert!(matches!(e, ExecutionError::Trap(_)), "Expected ExecutionError::Trap, but got {:?}", e),
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

More idiomatic Rust:

if let Err(e) == instance.call(state_args, CallArgs::new(&mut (), ext_main)) {
    assert!(matches!(e, ExecutionError::Trap(_)), "Expected ExecutionError::Trap, but got {:?}", e);
} else {
    panic!("Expected ExecutionError::Trap, but got Ok");
}

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