-
Notifications
You must be signed in to change notification settings - Fork 22
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
test(erc721): add unit tests #142
Conversation
✅ Deploy Preview for contracts-stylus canceled.
|
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.
Great job!
Erc721 tests are getting better!
contracts/src/token/erc721/mod.rs
Outdated
} | ||
|
||
#[motsu::test] | ||
fn error_when_reusing_token_id(contract: Erc721) { | ||
fn mint_error_when_reusing_token_id(contract: Erc721) { |
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 prefer more when those kind of tests looks like error_when_*
.
As I remember previous name have been like error_when_minting_twice
or smth but we changed it to what it is right now.
Wdt @alexfertel?
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, I agree that starting with error
or errors
is better.
I suggested reusing_token_id
because "minting twice" is not something bad, so the test name gets confusing.
Maybe error_when_minting_token_id_twice
?
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.
@bidzyyys let's also arrange other test names (e.g. transfer_from_error_when_transfer_to_invalid_receiver) like we discussed here
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 am renaming it rn @qalisander
/// | ||
/// May panic if fails to parse `ACCOUNT_CODEHASH` as a keccack hash. | ||
#[no_mangle] | ||
pub unsafe extern "C" fn account_codehash(_address: *const u8, dest: *mut u8) { |
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.
Hope we will make it work
✅ Deploy Preview for contracts-stylus canceled.
|
lib/motsu/src/shims.rs
Outdated
@@ -157,6 +157,10 @@ pub fn storage_flush_cache(_: bool) { | |||
/// Dummy msg sender set for tests. | |||
pub const MSG_SENDER: &[u8; 42] = b"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF"; | |||
|
|||
/// Account code hash for tests (only EOAs). |
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.
what do you mean with only EOA
s?
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.
Ah, this is keccak("")
. We should be more clear about this.
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.
pub const EOA_CODEHASH: &[u8; 66] =
b"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
lib/motsu/src/shims.rs
Outdated
/// [`RETURN_DATA_SIZE`]: https://www.evm.codes/#3d | ||
#[no_mangle] | ||
pub unsafe extern "C" fn return_data_size() -> usize { | ||
// Default value, we do not use this function in our unit-tests. |
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.
Note that this is not entirely accurate: we don't use them explicitly, but indeed the binary does include them, otherwise it wouldn't error when trying to compile.
I think it's fine to return zero here, but we should create a follow-up issue that tackles implementing the ones that make sense, like return_data_size
and read_return_data
.
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.
Created issue #156
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.
LGTM! 🚀 Great job!
Created an issue for having consistent naming convention for tests that check errors: #155 |
Created an issue for filling shims #156 |
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.
Good job!
Just added uint!(..) macro instead of U256::from(..).
I think we can merge it.
Resolves #69