# Rust-based SNS-testing

**URL:** <https://forum.dfinity.org/t/rust-based-sns-testing/44321>\
**Category:** Showcase\
**Created:** [April 22, 2025, 10:33am UTC](https://forum.dfinity.org/t/rust-based-sns-testing/44321 "2025-04-22T10:33:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serokell](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/serokell/32/26624_2.png) [@Serokell](https://forum.dfinity.org/u/Serokell)\
**Post date:** [April 22, 2025, 10:33am UTC](https://forum.dfinity.org/t/rust-based-sns-testing/44321/1 "2025-04-22T10:33:48Z")

</div>

# **Project highlights**

This project is dedicated to porting the [old sns-testing](https://github.com/dfinity/sns-testing) to the ICP monorepo.

The new implementation is written in Rust to ensure the code is always tested to be compatible with the latest SNS feature.

It uses [PocketIC](https://crates.io/crates/pocket-ic) to launch the local IC network on which users can test their SNSes.

# **Features**

`sns-testing` allows users to easily bootstrap the local PocketIC-based IC network with pre-installed NNS-related canisters, including NNS dapp and Internet Identity.

Users can interact with canisters that expose a web UI through their browsers.

The local network is compatible with existing IC tooling, such as `dfx` and `quill`.

Community-driven activities (such as NNS voting to create the new SNS, SNS swap completion, and SNS voting) can be automated via the `sns-testing` CLI.

# **How to install**

Clone the ICP monorepo and follow the [sns-testing README](https://github.com/dfinity/ic/tree/master/rs/sns/testing#prerequisites).

# **Usage Example**

The [sns-testing README](https://github.com/dfinity/ic/tree/master/rs/sns/testing#interact-with-sns-lifecycle) provides a more detailed step-by-step guide on how to deploy a user-defined SNS and interact with it during its lifecycle.

## Set up the environment

1. Create a dedicated `dfx` identity that will be used with `sns-testing`:

2. Add all required binaries to `PATH`

## Bootstrap the local IC network

1. Launch `pocket-ic-server` instance. The binary will remain running in the foregound, so this step has to be run in a separate terminal session.

2. Bootstrap the IC network

These steps will launch the local IC network with a `dfx`-compatible HTTP endpoint exposed at `http://127.0.0.1:8080`.

The NNS on this network will have a neuron with ID `1` that has the majority of the voting power and is controlled by the `sns-testing` identity principal.

## Get ICP tokens

Go to [http://qoctq-giaaa-aaaaa-aaaea-cai.localhost:8080/tokens/](http://qoctq-giaaa-aaaaa-aaaea-cai.localhost:8080/tokens/) and click “Sign in with Internet Identity”. Follow the instructions to create the new identity (typically with ID 10000).

Click the “Receive” button on the NNS dapp web UI to get the ICP Address you can receive tokens to.

 ![](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/1/4/14cc5bbe49b6a2fb642a5f94a76f075a44c15af3.jpeg)

To receive tokens:

```bash
sns-testing --network http://127.0.0.1:8080 transfer-icp --amount 1000 \
	--to <ICP Address>

```

Received ICP tokens can be used to create an NNS neuron or to participate in the SNS swap.

## Create the new SNS

The suggested way to create proposals to launch the new SNS is to use `sns propose` command from the [`sns` CLI](https://github.com/dfinity/ic/tree/master/rs/sns/cli).

Note that to be able to make the SNS swap start directly after SNS creation, you’ll need to set `start_time: null` in the swap parameters in the SNS YAML config.

```bash
sns propose --network http://127.0.0.1:8080 --neuron-id 1 sns_init.yaml

```

Note that we’re using the same NNS neuron ID as in the `sns-testing-init` invocation above.

The NNS dapp web UI will show that the proposal to create the new SNS was adopted and executed:

 ![](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/7/1/710b45317f0668445b85f963577f3b3bda1afe9a.jpeg)

## Complete SNS swap

Open the NNS dapp launchpad ([http://qoctq-giaaa-aaaaa-aaaea-cai.localhost:8080/launchpad/](http://qoctq-giaaa-aaaaa-aaaea-cai.localhost:8080/launchpad/)) to check the SNS swap state.

 ![](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/6/7/6780cf1397a97d066ef4f3bc2d88d26d9b513eb1.jpeg)

You can now participate in the swap using your identity (NNS dapp web UI or `quill`).

To complete the SNS swap by providing the maximum direct ICP commitment run:

```bash
sns-testing --network http://127.0.0.1:8080 swap-complete --sns-name "Daniel"

```

Identities that participated in the swap will increase their dissolve delay to participate in the SNS voting in the future.

Check the swap state in the NNS dapp once again to ensure that it was completed.

 ![](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/0/7/07e4d4f60c201837a11c5efcaabad17a1dfcd8c3.jpeg)

## Perform SNS-controlled canister upgrade

The suggested way to submit SNS proposals is to use [`quill`](https://github.com/dfinity/quill/). For more info, please refer to the [official documentation](https://internetcomputer.org/docs/building-apps/governing-apps/managing/making-proposals/).

Once the SNS proposal is created, you can upvote it using the identities that participated in the SNS swap previously within `sns-testing swap-complete` command:

```bash
sns-testing --network http://127.0.0.1:8080 sns-proposal-upvote --sns-name "Daniel" --proposal-id "1" --wait

```

Check the NNS dapp to see the state of the SNS proposal.

 ![](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/3X/4/5/45e0dafbc9727980f6c9674f7eebee58384b4ef6.jpeg)

# **Documentation**

Please refer to the [sns-testing README](https://github.com/dfinity/ic/tree/master/rs/sns/testing).

# **Future Plans**

One possible improvement step is to remove the runtime dependency on `bazel` for `sns-testing-init`. This will allow the distribution of SNS testing binaries separately through a CDN.

Another direction is to provide PocketIC-based Rust helpers to develop and run testing scenarios in CI using the deterministic mode of PocketIC.
