-
Notifications
You must be signed in to change notification settings - Fork 141
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 exhaustive tests for fvm sdk api #1681
Conversation
feb3e46
to
177776d
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.
This is exactly what I'm looking for.
assert_eq!(res, Err(ErrorNumber::IllegalArgument)); | ||
|
||
// Test for invalid Cid pointer | ||
let res = sdk::sys::ipld::block_open("invalid ptr".as_ptr()); |
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.
This is still a valid pointer (i.e., valid memory). I'd cast a large integer to a pointer.
(also, now that you've checked this, I wouldn't bother checking for "out of bounds" pointers on every syscall as that could get tedious and we use the same code-paths)
let res = sdk::sys::ipld::block_open("invalid ptr".as_ptr()); | ||
assert_eq!(res, Err(ErrorNumber::IllegalArgument)); | ||
|
||
// TODO (fridrik): Test for very large cid |
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.
Yeah, this'll be a bit annoying as you'll have to manually construct it. Also not something that's super critical to test.
sdk::sys::ipld::block_create(DAG_CBOR, test_bytes.as_ptr(), test_bytes.len() as u32); | ||
assert_eq!(res, Err(ErrorNumber::LimitExceeded)); | ||
|
||
// TODO (fridrik): Test for TooManyBlock error requires INT32_MAX blocks |
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 wouldn't bother with this one, honestly. Given the current gas model, there's no way to hit this limit at the moment.
f84aaba
to
d76fff3
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1681 +/- ##
=======================================
Coverage 55.44% 55.44%
=======================================
Files 146 146
Lines 14031 14031
=======================================
Hits 7779 7779
Misses 6252 6252
|
3484ca1
to
7955d21
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.
❤️
std::panic::set_hook(Box::new(|info| { | ||
sdk::vm::abort( | ||
ExitCode::USR_ASSERTION_FAILED.value(), | ||
Some(&format!("{}", info)), | ||
) | ||
})); |
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: I recommend just calling sdk::initialize()
.
testing/integration/tests/main.rs
Outdated
panic!("non-zero exit code {}", res.msg_receipt.exit_code) | ||
} | ||
} | ||
|
||
assert_eq!(res.msg_receipt.exit_code, ExitCode::OK); |
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.
This is now redundant.
Feel free to merge when ready. |
…FVM and SDK This allows us to more easily assert on certain error conditions: Example (this failed before): let res = sdk::sys::ipld::block_open(buf.as_mut_ptr()); assert_eq!(res, Err(ErrorNumber::IllegalArgument));
This commit refactors the fil-create-actor actor, main differences are: - If test failed with user asserts, they are now printed in the test output (before they were ignored) - Tests now verify result for specific error numbers - Added more tests for resolve_address and get_actor_code_cid
When deleting an actor with 0 balance, then this sself::self_destruct will always return Ok() regardless of whether the actor has already been deleted, or the beneficiary address does not exist or is itself
c3c1e6b
to
cb0fa3b
Compare
Thank you! |
This PR adds multiple tests for our fvm sdk api to confirm they behave according to fvm sdk docs.
Fixes: #585
Note that there are still tests to be written for
actor::next_actor_address
andcrypto::verify_consensus_fault
.