Skip to content

test(sns): Porting sns-testing to the ICP mono repo, Part II - #4548

Merged
aterga merged 28 commits into
masterfrom
serokell/sns-testing
Apr 1, 2025
Merged

aterga merged 28 commits into
masterfrom
serokell/sns-testing

Conversation

@aterga

@aterga aterga commented Mar 27, 2025 •

Copy link
Copy Markdown
Contributor

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: #4067

< Previous PR | Next PR >

rvem added 22 commits March 27, 2025 09:13
We want to be able to reuse some of these helpers outside of PocketIC
environment using `ic-agent` as a backend. So we're porting some of the
helpers for NNS/SNS to use 'ic_nervous_agent' instead of 'pocket_ic'.
Note that at the moment these helpers still provide 'pocket_ic'-based
interface and they will be abstracted out later.
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.
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.
@aterga
aterga marked this pull request as ready for review March 27, 2025 08:57
@aterga
aterga requested a review from a team as a code owner March 27, 2025 08:57
@github-actions github-actions Bot added the test label Mar 27, 2025

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this pull request affects the behavior of any canister owned by
the Governance team, remember to update the corresponding
unreleased_changes.md file(s).

To acknowldge this reminder (and unblock the PR), dismiss this
code review by going to the bottom of the pull request page, and
supply one of the following reasons:

  1. Done.

  2. No canister behavior changes.

Comment thread rs/sns/testing/src/utils.rs Resolved
Comment thread rs/sns/testing/src/nns_dapp.rs Resolved
Comment thread rs/sns/testing/src/main.rs Resolved
Comment thread rs/sns/testing/src/main.rs Resolved
Comment thread rs/sns/testing/src/utils.rs Resolved
Comment thread rs/sns/testing/src/utils.rs Resolved
Comment thread rs/sns/testing/src/sns.rs Resolved
@aterga
aterga requested a review from max-dfinity March 31, 2025 09:27
@aterga
aterga added this pull request to the merge queue Apr 1, 2025
Merged via the queue into master with commit 10e1480 Apr 1, 2025
@aterga
aterga deleted the serokell/sns-testing branch April 1, 2025 10:27
sasa-tomic pushed a commit that referenced this pull request Apr 7, 2025
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]>
github-merge-queue Bot pushed a commit that referenced this pull request Apr 17, 2025
This is the third PR for implementing the next-gen
[sns-testing](https://github.com/dfinity/sns-testing) tool.

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.

< [Previous PR](#4548) |

---------

Co-authored-by: Roman Melnikov <[email protected]>
Co-authored-by: Roman Melnikov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants