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 mock testing for lite client #72

Conversation

yihuang
Copy link
Contributor

@yihuang yihuang commented Nov 19, 2019

Add some mocking data to test lite client.

validator::Set::new(validators),
)
.expect("verify_trusting failed");
}
Copy link
Member

Choose a reason for hiding this comment

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

Very cool! Thanks. I'm wondering if we either should have simpler rust-only tests first. Or, simplify this (extract all json strings to vars/constants and have only the verification logic in the test). Also, there should be a comment explaining how the JSON was generated.

Furthermore, @Shivani912 is working on generating similar tests: https://github.com/Shivani912/tendermint/tree/shivani/language-agnostic-tests/types/lite-client/tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simply copy-pasted my local test node's json rpc response, only to test the basics work.
It's great to have more sophisticated test cases.

Copy link
Member

Choose a reason for hiding this comment

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

I think, these kind of tests currently tend to live in https://github.com/interchainio/tendermint-rs/tree/master/tendermint/tests as JSON files: https://github.com/interchainio/tendermint-rs/tree/master/tendermint/tests/support/rpc

I think it would increase the readability here if we'd extract the JSON into vars in the test (e.g. static VALID_HEADER: &str = r#"{ ...}"#

The test seems to fail on my machine btw.

"parts": {
"total": "0",
"hash": ""
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@yihuang yihuang Nov 25, 2019

Choose a reason for hiding this comment

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

This is a bug fixed in another PR, #66. block_id could be empty.

and correctly compute header hash when block id is empty.

Represent empty Hash with Option
@yihuang
Copy link
Contributor Author

yihuang commented Nov 26, 2019

Copy link
Member

@liamsi liamsi left a comment

Choose a reason for hiding this comment

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

It's a bit confusing that the changes from 8b1d3dc show up as changes here although #66 was already merged into lite_impl_simple_merkle_merged.

Thanks again @yihuang! LGTM!

@@ -0,0 +1,78 @@
{
"signed_header": {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for moving the test JSON here 👌

@liamsi liamsi merged commit 2c6a36b into informalsystems:lite_impl_simple_merkle_merged Nov 27, 2019
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