Skip to content
Unverified Commit 3460ec1c authored by Özgün Özerk's avatar Özgün Özerk Committed by GitHub
Browse files

Zombienet Improve DevX with new methods (#261)

Revamped version of #252, didn't overwrite that PR in case you guys want
to compare both solutions.

Fixes #251 


TL;DR -> here is the suggestion:
```rust
let network_config = NetworkConfigBuilder::with_nodes_and_chain(
    vec!["alice".to_string(), "bob".to_string()],
    "rococo-local",
)
.with_collators_and_parachain_id(vec!["collator1".to_string(), "collator2".to_string()], 100)
.build()
.unwrap();
```

I found an even better way than creating a wrapper. Here is the summary:

- I want to protect the safety measures provided by the original crate
as we discussed.
- At the same time, I don't want to opt-out of the high-degree of
configurability that `configuration` crate offers. Even though the aim
is to grant better DevX to the community, it should still preserve the
configuration options.
- “advanced users can still use the `configuration` crate if they wanted
to” is not a good argument imo. Here is the reason:
- although there are many common settings amongst the projects in the
ecosystem, probably most of the projects only tinkers with a specific
setting w.r.t their needs, and this specific setting is most likely
changing across projects. So, if we do not expose the tinkering options
to people with this wrapper approach, most of the projects won’t use
this wrapper. Then what is the point?
- The aim should be providing the default options with a better DevX,
whilst still providing a way to configure niche details somehow within
the same API.
- As first trial, I completed simple to use wrapper builders with the
default settings. However, to expose the niche configurations, I had to
copy-paste nearly every other function/method in the `configuration`
crate.
- And also, in order to comply with the `configuration` crate’s type
state pattern, I had to export nearly all the states from
`configuration` crate for the builder types in the `lib.rs`. The whole
thing was quickly becoming ugly.
- The difference between my wrapper and the `configuration` crate was,
basically the extra methods that granted better DevX (for initializing
the structs with default settings).
- So I thought, instead of creating a new wrapper with tremendous amount
of duplications, I can simply put these new methods into the
`configuration` crate itself!

Notes:

- there are 2 new methods: (edited after last commit)
    - `with_nodes_and_chain`
    - `with_collators_and_parachain_id`
- I also expanded the tests for these new methods.
- I want to signal to the developers that these new methods are easier
and faster to use compared to their equivalents, since they are
utilizing the default settings, and should be much less intimidating to
newcomers
- So, I tried to name the methods accordingly, but they turned out to be
a bit long. Don't know whether we can do better, I'm open to all
suggestions.

Hope it makes sense!
parent bd51865f
Pipeline #499796 failed with stage
in 17 minutes and 12 seconds