-
Notifications
You must be signed in to change notification settings - Fork 924
Zombienet-SDK test for the happy path of the new staking-async flow #8317
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
base: master
Are you sure you want to change the base?
Conversation
substrate/zombienet-sdk/tests/lib.rs
Outdated
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod staking_next; |
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.
Why have you chosen to have these tests to be in ./substrate
vs in ./substrate/frame/staking-async
?
Also noting the new name is staking-async, not next.
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.
It's a common pattern to have all zombienet tests in polkadot/zombiened-sdk-tests
, substrate/zombienet-sdk-tests
, etc.
But I've got no strong preference on this. If you want, I'll move them to to ./substrate/frame/staking-async
.
I'll fix the name.
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.
Both are fixed.
|
||
mod tests; | ||
|
||
/// Sets `ValidatorCount` in staking pallet to 500. |
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.
/// Sets `ValidatorCount` in staking pallet to 500. | |
/// Sets `ValidatorCount` in staking pallet to `validator_count`. |
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.
Also worth adding a comment that this is due to some mysterious bug, otherwise it should not be used/needed.
Has there been any updates on that? do we have any new leads as to why it is needed?
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've added the comment. I still haven't investigated why the value from the chainspec doesn't get set to the storage item.
) -> Result<(), anyhow::Error> { | ||
let set_validator_count = dynamic::tx("Staking", "set_validator_count", vec![validator_count]); | ||
let sudo = dynamic::tx("Sudo", "sudo", vec![set_validator_count.into_value()]); | ||
let alice = dev::alice(); |
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.
This will work fine, but to be more correct you should query Sudo::key
here, see who it is, and if it is one of the dev accounts (alice, bob etc.), sign and send it, and if not fail.
In other words, you are assuming alice is sudo, which may or may not be.
}) | ||
.with_parachain(|p| { | ||
p.with_id(1100) | ||
.with_chain_spec_path("parachain.json") // TODO: how to autogenerate this? |
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.
esp if you move it to ./substrate/frame/staking-next
, I think it is okay for now to say in the README.md:
please first run build-and-run-zn.sh compile
, and tweak this bash script to have an option to just prepare the two chain-specs, and not run ZN.
|
||
// Events generated by rc_client. Event here doesn't necessary mean 'event in the substrate | ||
// context'. It can be anything representing a point of interest for the tests. | ||
enum RcClientEvent { |
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 think subxt has a cli which allows you to generate a metadata from the wasm file, and within that you have access to the subxt-compliant version of all of the runtime types, including the concrete event types. So you could, instead of this, assert that some events are emitted.
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.
That's true but in this case this event is not a runtime event.
It's an 'event' such as 'something happened in the test which we want to handle and probably change state. In this test there is 100% match between runtime event in test event but in general this might not be the case.
I should pick a better name since this causes confusion.
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.
Would be ideal to simplify the manual-data parsing here, before we extend it to more test scenarios.
Strongly in favor of moving this to staking-async
crate, under a new sub-crate over there to keep it more isolated.
The static interface is problematic for CI since we don't want to commit the metadata and at the same time we need it generated somehow. To avoid complicated build scripts I am sticking with the dynamic subxt interface but with some advise from @jsdw I reworked the parsing. I think it's way better now.
I've also moved the test in |
In case it helps, Subxt does this by spinning up a Substrate node in a build.rs file, downloading metadata from it and then providing an instance of the generated interface from it here: https://github.com/paritytech/subxt/blob/master/testing/test-runtime/build.rs (If the node is already spun up at the time the tests start running, you can also generate an interface given a URL to an RPC node ie like this: https://docs.rs/subxt/latest/subxt/attr.subxt.html#connecting-to-a-node-to-download-metadata-via-runtime_metadata_insecure_url--) But yeah, I appreciate that this adds a little complexity. The static interface def makes life easier though :) |
pallet-bags-list = { workspace = true, default-features = true } | ||
pallet-balances = { workspace = true, default-features = true } | ||
rand_chacha = { workspace = true, default-features = true } | ||
sp-npos-elections = { workspace = true, default-features = true } | ||
sp-tracing = { workspace = true, default-features = true } | ||
substrate-test-utils = { workspace = true } | ||
subxt = { workspace = true } |
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.
Let's move them to a separate crate staking-async/zn-test
to not increase the compile time of the rust unit tests?
All GitHub workflows were cancelled due to failure one of the required jobs. |
Adds a zombienet test for the happy case of new staking flow where staking-async pallet is deployed on AH.
The test uses test/fake runtimes for RC and AH-Next. It covers the following scenario:
The test takes quite a lot of time (~11 minutes) to execute and requires the chainspecs for fake RC and AH-Next to be prebuilt in the root directory of the test module.