Skip to content

add mock testing for lite client#72

Merged
liamsi merged 2 commits intocometbft:lite_impl_simple_merkle_mergedfrom
yihuang:mock_testing_lite_client
Nov 27, 2019
Merged

add mock testing for lite client#72
liamsi merged 2 commits intocometbft:lite_impl_simple_merkle_mergedfrom
yihuang:mock_testing_lite_client

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
Contributor

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
Contributor

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
Contributor

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 yihuang force-pushed the mock_testing_lite_client branch from a1a4d97 to 9e00e99 Compare November 26, 2019 03:42
@yihuang
Copy link
Contributor Author

yihuang commented Nov 26, 2019

Copy link
Contributor

@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
Contributor

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 cometbft: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