-
Notifications
You must be signed in to change notification settings - Fork 355
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
Responses validation in multi-test #373
Conversation
b3c59f5
to
c2fb2e5
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.
Looks good.
I would remove the events echo in reply and add some trim spaces to the length checks. Then good to merge
@@ -720,6 +724,43 @@ where | |||
let storage = ReadonlyPrefixedStorage::multilevel(storage, &[NAMESPACE_WASM, &namespace]); | |||
Box::new(storage) | |||
} | |||
|
|||
fn verify_attributes(attributes: &[Attribute]) -> Result<(), String> { |
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.
Looks good
@@ -268,6 +268,10 @@ where | |||
funds, | |||
label, | |||
} => { | |||
if label.is_empty() { |
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.
👍
}), | ||
.. | ||
} = msg | ||
{ | ||
Ok(Response::new().set_data(data)) | ||
Ok(Response::new().set_data(data).add_events(events)) |
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 would actually not add these to the reply
call. These should be appended by the runtime when there is a SubMsg executed without the reply blob doing anything
packages/multi-test/src/wasm.rs
Outdated
|
||
fn verify_attributes(attributes: &[Attribute]) -> Result<(), String> { | ||
for attr in attributes { | ||
if attr.key.is_empty() { |
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 in the real wasmd implementation, we trim off whitespace from the ends before checking empty, so " " is also invalid.
The relevant Go code changes are are https://github.com/CosmWasm/wasmd/pull/562/files maybe you can use them as reference
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.
Missed it, corrected.
packages/multi-test/src/wasm.rs
Outdated
|
||
for event in &response.events { | ||
Self::verify_attributes(&event.attributes)?; | ||
if event.ty.len() < 2 { |
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.
Same thing, I think we trim whitespace before checking length
c2fb2e5
to
4fbb283
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.
lgtm
closes #341
I don't like checking the errors in test by comparing strings - I would really prefer to switch to proper error types (we have
thiserror
anyway), and if needed converting them to string at the end. If for simplicity we want to unify error types, then we could just go with handling them withanyhow
so if needed, error types can be retrieved by downcasting.