Quick mock SNS deployment for 3rd party integration

I’m writing tests for a feature that will integrate with SNSes right now, and would like to build out some integration tests.

Is there a script/command to 1-step deploy a mock SNS to my local dfx environment?

For example, it would be great if dfx came bundled with a dummy SNS, that had completed a mock SNS sale, and had at least one type of SNS canister (root, dapp, archive, etc.).

Then upon calling the nns-sns-wasm canister would return info about that SNS.

It would also set things up identical to production (i.e. controllers are all set up correctly w.r.t. SNS Root, NNS Root, etc.).

This would save developers (and me :sweat_smile:) a lot of time when building ecosystem tooling that connects with and supports the SNS ecosystem. Having this in dfx (as opposed to just a PocketIC test runner) is helpful because it makes the frontend QA pieces so much easier.

Bonus points - this would be great if this existed for PocketIC as well!

2 Likes

I just got a dummy state with a launched SNS in a state for pocket ic!!! I can send it to you! Maybe I’ll put it up on github.

4 Likes

I learned yesterday about the existence of dfx extension install sns --version 0.4.3. While I ultimately did not use it, I think I spotted various commands, including something like deploying a toy SNS. I did not try it and I’m not sure, but if you’re interested, I thought I’d share.

PS: Maybe important to note, given that I ultimately did not use it, I tried to remove the extension but dfx extension uninstall sns messed up the entire DFX, and I had to force delete its entire cache manually using sudo rm -r .cache to “resolve” the issue.

See below.

1 Like

The dfx sns extension is a tool for (1) working with an existing SNS instance and (2) launching an SNS test flight instance (to mainnet / local replica). (Launching an SNS via proposals is an experimental feature of dfx sns; as of today, projects preparing for an SNS launch should use GitHub - dfinity/sns-testing: Testing SNS in local testing environment)

However, maybe a test flight SNS is what you want if you are developing something that is intended to interact with existing SNSes rather than SNSes during the swap.

Using a Pocket-IC snapshot is another excellent option.

2 Likes

Here is a repo with a state that has NNS using dfx nns install and then a launched SNS using the sns_testing default_scenario.sh. You should be able to get controllers and owners of the SNS via that. It may be a mess to pass procedures as I haven’t investigated the following structure yet, but perhaps you can configure it so that all the 100 or so participants follow a dev neruon? If someone wants figure that out I’ll update the state with the DFX commands:

2 Likes

In the meantime, I fixes some dependency bugs and created a PR for the dfx nns extension to support launching an SNS. This can be used already as follows:

  1. git clone https://github.com/dfinity/dfx-extensions.git && cd dfx-extensions
  2. Run dfx-extensions/e2e/launch-simple-sns.sh at c88b9e52045174bbdb5cc879e4a08370e975fb5d · dfinity/dfx-extensions · GitHub

This should launch an SNS inside a local DFX replica instance with an NNS installed.

Let me know if you have any questions.

1 Like

Does this launch a passed sns with token holders?

No, this just shows how to open the swap using dfx commands.

One could extend this script. But that requires deciding, e.g., how many participants (and of what size) will there be.

It would be nice to have a mvd with the minimum number of participants all following a dev neuron to easily test deploying dao dapp canisters and testing generic dao function calls.

Note that not all (valid) SNS init configurations result in swaps that can be completed with exactly the minimum required number of direct participants. So solving this problem in general is a bit fiddly.

Here’s the first step towards a general solution: