Repository navigation
Conversation
aterga
left a comment
There was a problem hiding this comment.
I made a pass over rs/nervous_system/agent and
rs/nervous_system/integration_tests/src/nervous_system_agent_helpers.rs
Look very promising!
Some high-level suggestions:
- Code organization. Let's have a clear separation between code that's test-only vs. production-ready code. How to best do that? Ideally, we'd have the separation on the level of crates. So there could be rs/nervous_system/helpers for the production-ready helpers (e.g., submitting a proposal makes sense to put there) while testing-related helpers could go to rs/nervous_system/integration_tests/helpers.
- Safety Since any code that's production-ready can be used (at least in theory) from a system that's supposed to be fault tolerant, such code must not panic. Conversely, it's fine to panic in test-only code, unless handing or propagating the errors has clear advantages.
- Restrict which types are exposed in the agent API. Clients who want to call a canister endpoint already need to know the basics, e.g., what is a principal, a canister ID, or a subaccount. But currently, calling agent function also requires them to import (and know about) some more specialized types, often only used in as a single function's request or response payload. We should aim to handle specialized types in the agent's implementation, while keeping the function signatures with basic types whenever possible. This is not necessarily a general rule, as sometimes avoiding too many parameters is worth keeping an argument of a specialized type (e.g.,
TransferArgs). But we do have an opportunity to prettify some canister APIs this way, which could simplify the client code and dependency graph.
8082975 to
72347e0
Compare
8b2a285 to
bad90ea
Compare
Agree to both suggestions. The code from the
I don't think it's a good idea always to avoid exposing internal APIs in agent helpers since internal API types may be quite nontrivial (e.g. OTOH, for internal API types like So I think the overall approach should be the following: if the internal API type is simple enough (i.e. wraps a couple "primitive" types whose purpose is straightforward), then we should avoid exposing the internal API, otherwise, it's better to depend on it. What do you think? |
0493412 to
ea79fec
Compare
3c8c66a to
ee3a1fd
Compare
We want to reuse some of the helpers from 'pocket_ic_helpers' module in non PocketIC-specific environment. To achieve this, these helpers were abtracted out to use generic 'CallCanisters' interface to interact with the network. 'pocket_ic_helpers' interface remains the same and uses 'nervous_agent_helpers' implementation for those helpers that we re-implemented.
We want to be able SNS-specific parts of sns-testing scenario on the network provided either via PocketIC or via 'ic-agent' clients. The following parts of sns-testing scenario were reimplemented to use nervous-agent-based implementation: * NNS proposal creation and adoption to create the new SNS. * SNS swap completion. * SNS proposal creation and adoption to upgrade the test canister.
Currently the CLI from sns-testing runs the basic scenario using PocketIC API. However, we'd like to be able to run the scenario on artibrary network available via ic-agent-compatible HTTP endpoint. To achieve this, the CLI was split into two subcommands: * 'nns-init' This subcommand bootstraps the NNS on a fresh PocketIC instance using PocketIC API. * 'run-basic-scenario' This subcommand runs the basic scenario (create and adopt the new SNS via NNS proposal, complete SNS swap, upgrade SNS-controlled canister via SNS proposal) on a network provided by HTTP endpoint using 'ic-agent' as a backend.
…ning the basic scenario If the network setup is invalid or the target canister doesn't have the correct state (e.g. doesn't have the NNS Root canister as a controller), the scenario may fail during the execution throwing potentially confusing errors from NNS/SNS canisters and leaving the SNS in 'failed' state. Moreover, these errors may not be thrown instantly and the user may have to wait before actually knowing that something is off. Add steps to validate the target IC network and the target test canister. Network validation checks the following: 1) All "backend" NNS canisters are installed. 2) The network has SNS subnet. 3) The SNS WASM canister has SNS canisters' WASM modules. Test canister validation checks the following: 1) Canister was created and installed. 2) The NNS Root canister is controller of the canister.
…ore running the basic scenario
…ore running the basic scenario
…ore running the basic scenario
…ore running the basic scenario
Using user-provided identity as ICP treasury is error-prone since the user may accidentally provide wrong identity name as an argument. Use hardcoded identity instead. Since it's deterministically generated, it's guaranteed to always be the same over 'sns-testing' invocations.
PocketIC now exposes a dedicated method to determine whether the instance is running in 'auto_progress' mode.
4368c53 to
03add34
Compare
|
This branch has been copied over, and the PR was reopened here: #4548 |
This is the second PR for implementing the next-gen [sns-testing](https://github.com/dfinity/sns-testing) tool. It can now be written in Rust and continuously tested against the latest SNS features. At the core of this tool lies the [PocketIC framework](https://crates.io/crates/pocket-ic/6.0.0), the testing framework capable of creating a fully deterministic environment for testing complex ICP dapp scenarios. This PR is authored by Serokell and reviewed by the DFINITY Foundation. Please refer to the reviews here: #4067 < [Previous PR](#3979) | --------- Co-authored-by: Roman Melnikov <[email protected]>
This is the second PR for implementing the next-gen [sns-testing](https://github.com/dfinity/sns-testing) tool. It can now be written in Rust and continuously tested against the latest SNS features. At the core of this tool lies the [PocketIC framework](https://crates.io/crates/pocket-ic/6.0.0), the testing framework capable of creating a fully deterministic environment for testing complex ICP dapp scenarios. This PR is authored by Serokell and reviewed by the DFINITY Foundation. Please refer to the reviews here: #4067 < [Previous PR](#3979) | --------- Co-authored-by: Roman Melnikov <[email protected]>
This is the second PR for implementing the next-gen sns-testing tool. It can now be written in Rust and continuously tested against the latest SNS features.
At the core of this tool lies the PocketIC framework, the testing framework capable of creating a fully deterministic environment for testing complex ICP dapp scenarios.
This PR is authored by Serokell and reviewed by the DFINITY Foundation. Please refer to the reviews here: #3654
< Previous PR |