Skip to content

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

Closed
aterga wants to merge 23 commits into
masterfrom
serokell/sns-testing
Closed

aterga wants to merge 23 commits into
masterfrom
serokell/sns-testing

Conversation

@aterga

@aterga aterga commented Apr 7, 2025 •

Copy link
Copy Markdown
Contributor

This is the third PR for implementing the next-gen sns-testing tool.

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

< Previous PR |

@aterga
aterga marked this pull request as ready for review April 7, 2025 21:09
@aterga
aterga requested a review from a team as a code owner April 7, 2025 21:09
@github-actions github-actions Bot added the test label Apr 7, 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.

@aterga

aterga commented Apr 8, 2025

Copy link
Copy Markdown
Contributor Author

Review takes place here: #4705

rvem and others added 21 commits April 14, 2025 11:22
Currently, 'sns-testing' is only capable of deploying hardcoded SNS with
the provided SNS-controlled canister. This makes it impossible to tweak
SNS settings without recompiling 'sns-testing'.

The suggested way to create SNSes is to use 'dfx sns propose' command.
To support the workflow to deploy SNSes using this command,
'sns-testing' CLI was extended with the subcommand to complete the swap
for the created SNS.

'sns-testing run swap-complete' will wait for swap to be open, generate
required number of participation with sufficient amount of tokens to
complete the swap, and wait for swap to be completed.

Also extract NNS init part into a dedicated binary to simplify the interface.
Users may create SNS proposals that are not automatically accepted.

To allow simulating SNS proposal adoption, 'sns-proposal-upvote' subcommand
is added to the 'sns-testing'. This command will upvote a given SNS proposal
using the same identity neurons that were used in the 'swap-complete'
subcommand to complete the SNS swap previously.

'sns-proposal-upvote' will attempt to vote on behalf of all
'Swap.minimum_participants' deterministic identities participated in the
swap omitting those that do not have neurons that are eligible for SNS voting.
Users may require ICP tokens to test actions like swap participation using
their own identities.

To support getting ICP tokens, the new 'transfer-icp' subcommand was added.
It uses hardcoded treasury identity that has a large ICP deposit from
which tokens are transferred to the provided recipient.
Currently, the identity that transfer ICPs to the swap participants or
the user provided account is hardcoded. Which limits the usage of the
'sns-testing' to the network created by 'sns-testing-init'.

This commit adds an optional argument to choose the dfx identity to be
used as an ICP treasury to 'sns-testing-init' binary and
'swap-complete' and 'transfer-icp' subcommands of 'sns-testing'.
…anisters'

'is_canister_stopped' is currently used by PocketIc and ic-agent
implementations. However, the 'CallCanisters' trait requires
implementing this function. As a result, some trait implementations have
dummy implementation for this method which panics in runtime.

To avoid runtime panic, this method is extracted into a dedicated
'CallCanistersWithStoppedCanisterError' trait that inherits
'CallCanisters'. This trait is only implemented for PocketIc and ic-agent's.
An attempt to use 'is_canister_stopped_error' for other implementation
will cause compilation error instead of runtime panic.
Currently the ID of the NNS neuron that is used to submit proposals is
hardcoded which is potentially error-prone.

To fix this, 'sns-testing-init' and 'sns-testing run-basic scenario'
were made to consider neuron ID instead of using the hardcoded ID from
a separate crate.
Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
Currently, IC network HTTP endpoint port launched by 'sns-testing-init'
is hardcoded to 8080.

This commit adds an additional command line option to 'sns-testing-init'
binary to make the port configurable.
'run-basic-scenario' subcommand is updated to take the WASM module and
Candid argument used for the canister upgrade as arguments instead of
hardcoding them. This allows users to run this "basic scenario" on
arbitrary canisters.
Currently, README requires running binaries using 'bazel run' which
bloats usage instructions. Additionally, in the future, we'd like to
distribute all these binaries without 'bazel'.

This commit adds a bash script that builds all required binaries using
'bazel', copies them to the local directory and updates PATH.
README now implies the usage of this script to populate PATH and
explains how to use binaries without 'bazel run' wrapper (for all
binaries except 'sns-testing-init').
Currently, 'sns-testing-init' requires specifying the path to the
PocketIC directory explicitly. This introduces the necessity to clean up
the directory before re-running this binary (if the same value for the
option is used).

This commit makes '--state-dir' argument optional. If it's not provided,
a new temporary directory will be created. This directory will remain
even after 'pocket-ic-server' process has finished. This temporary
directory will be cleaned up on the next system reboot.
@aterga
aterga force-pushed the serokell/sns-testing branch from 8e80e66 to 1cc556b Compare April 17, 2025 12:28
@aterga
aterga marked this pull request as ready for review April 17, 2025 12:28
@aterga
aterga enabled auto-merge April 17, 2025 12:29
@aterga
aterga dismissed github-actions[bot]’s stale review April 17, 2025 12:29

No canister changes

github-merge-queue Bot pushed a commit that referenced this pull request Apr 17, 2025
This is a preliminary PR for discussing the changes that will be ported
to #4697

Context: Serokell sns-testing milestone III

---------

Co-authored-by: Roman Melnikov <[email protected]>
Co-authored-by: Roman Melnikov <[email protected]>
@aterga

aterga commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

This PR was in the end redundant, as we were able to merge #4705

@aterga aterga closed this Apr 17, 2025
auto-merge was automatically disabled April 17, 2025 15:27

Pull request was closed

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.

2 participants