-
Notifications
You must be signed in to change notification settings - Fork 228
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
Improve testing across dependencies #381
Comments
Hi! I am already working on this; take a look at: https://github.com/informalsystems/tendermint-rs/blob/andrey/mbt-utils/mbt-utils/src/tendermint-produce.rs The idea is that we will be able to produce the Tendermint datastructures for testing from minimal input, like a validator from a string identifier. These datastructures can be then instantiated both from the CLI, e.g.:
and from the Rust code, e.g.:
This is already close to being finished; sorry for not creating an issue for it beforehand... |
And the real Tendermint datastructures are then produced in Rust from the above as follows:
|
also, to answer your original question, and for a bit of motivation: implementing |
As far as I'm concerned (for cross-testing) purposes, this is beautiful. I suppose it would be a more "standardized" approach to build on the trait Default rather than Produce, that's why I suggested it. Note that the implementation of |
Glad you like it! I hope the API is sufficiently simple (at least I've designed it with this intention)... and thanks for creating the issue:) Currently this is implemented for model-based testing of the |
@andrey-kuprianov can you please open an issue describing the work at a high level so we can better track |
I think we can close this now that the testgen is merged and supports generating these types. Let me know if not! |
One difficulty we're facing in
ibc-rs
with regards to testing is that we need to instantiate certain types that belong to an external dependency create, namely totendermint-rs
.An example: we want to test
ClientState
. This data type includes a member of typeHeader
which in turn includes a member of typetendermint::block::signed_header::SignedHeader
including both aHeader
and aCommit
.To instantiate a
ClientState
we need to instantiate all these dependencies, which is very tricky because there are tens of them. Just aHeader
has 14 fields, and correct instantiation of theHeader
is not exactly relevant for testingClientState
.As I understand it, an alternative to instantiating this whole chain of dependencies, is for some of these types to implement the trait
Default
. Then we could saylet sh = Default::default()
to get a basic (valid) signed header we could use in testingClientState
. In general, adopting this strategy should simplify testing of cross-dependent data types. There are already many types implementing Default so we should derive it for free quite often. At the moment, I counted 20 types intendermint-rs
that deriveDefault
.I can't think of any cons, except that there may be perhaps more code to maintain. But the burden should not be big, since tests already include these default values (example).
The text was updated successfully, but these errors were encountered: