# Quick mock SNS deployment for 3rd party integration

**URL:** <https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040>\
**Category:** Developers\
**Tags:** sns\
**Created:** [July 11, 2024, 3:17am UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040 "2024-07-11T03:17:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [July 11, 2024, 3:17am UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/1 "2024-07-11T03:17:31Z")

</div>

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 😅) 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!

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [July 11, 2024, 3:58am UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/2 "2024-07-11T03:58:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [July 12, 2024, 9:29am UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/3 "2024-07-12T09:29:23Z")

</div>

~~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.

---

<div class="post-metadata">

**Author:** ![aterga](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/aterga/32/4143_2.png) [@aterga](https://forum.dfinity.org/u/aterga)\
**Post date:** [July 12, 2024, 9:42am UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/4 "2024-07-12T09:42:07Z")

</div>

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](https://github.com/dfinity/sns-testing))

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.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [July 12, 2024, 1:52pm UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/5 "2024-07-12T13:52:58Z")

</div>

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:

> **[GitHub - icdevsorg/pic\_js\_sns\_state](https://github.com/icdevsorg/pic_js_sns_state)**
>
> Contribute to icdevsorg/pic\_js\_sns\_state development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![aterga](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/aterga/32/4143_2.png) [@aterga](https://forum.dfinity.org/u/aterga)\
**Post date:** [July 12, 2024, 7:51pm UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/6 "2024-07-12T19:51:28Z")

</div>

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](https://github.com/dfinity/dfx-extensions/blob/c88b9e52045174bbdb5cc879e4a08370e975fb5d/e2e/launch-simple-sns.sh)

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

Let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [July 12, 2024, 10:42pm UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/7 "2024-07-12T22:42:50Z")

</div>

Does this launch a passed sns with token holders?

---

<div class="post-metadata">

**Author:** ![aterga](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/aterga/32/4143_2.png) [@aterga](https://forum.dfinity.org/u/aterga)\
**Post date:** [July 13, 2024, 9:52am UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/8 "2024-07-13T09:52:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [July 13, 2024, 12:32pm UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/9 "2024-07-13T12:32:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aterga](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/aterga/32/4143_2.png) [@aterga](https://forum.dfinity.org/u/aterga)\
**Post date:** [July 16, 2024, 4:38pm UTC](https://forum.dfinity.org/t/quick-mock-sns-deployment-for-3rd-party-integration/33040/10 "2024-07-16T16:38:34Z")

</div>

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:

> [@Automatically modeling swap participation](https://forum.dfinity.org/t/automatically-modeling-swap-participation/33278):
>
> While thinking about how to generate optimal testing scenarios for SNS swaps, I wrote a little SMT model that seems to work quite well with the Z3 SMT solver. It allows automatically generating participations that satisfy a bunch of constraints. Sharing the model in case it might be useful for others. Questions and suggestion are welcome!
