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

[programmability] Add tests for struct_with_key_verifier #47

Merged
merged 1 commit into from
Dec 9, 2021
Merged

[programmability] Add tests for struct_with_key_verifier #47

merged 1 commit into from
Dec 9, 2021

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Dec 9, 2021

Add unit tests to cover all error/success cases for the struct_with_key_verifier.

cargo test

@lxfind lxfind requested a review from sblackshear December 9, 2021 21:24
}

#[test]
fn non_key_struct_without_fields() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will actually get rejected by the regular bytecode verifier--it insists that every struct has at least one field (otherwise, the struct isn't serializable). So we probably don't want this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that we have to handle this case in the verifier code and error out if it happens (since we run our verifier before move verifier). Since we verify it anyway, we might as well test it

Copy link
Collaborator

@sblackshear sblackshear left a comment

Choose a reason for hiding this comment

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

Nice!

One other useful test might be a correctly named/typed id field, but in the wrong position (e.g., it's the second field). I think a verifier that insists that the id field is the last one would pass the current test suite, but would not pass after adding this test.

@lxfind lxfind merged commit daf69fa into MystenLabs:main Dec 9, 2021
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