|
| 1 | +--- |
| 2 | +title: Local Testing |
| 3 | +sidebar_position: 3 |
| 4 | +--- |
| 5 | + |
| 6 | +# LocalOsmosis |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +## What is LocalOsmosis? |
| 11 | + |
| 12 | +LocalOsmosis (a fork of LocalTerra) is a complete Osmosis testnet and ecosystem containerized with Docker and orchestrated with a simple `docker-compose` file. It simplifies the way smart-contract developers test their contracts in a sandbox before they deploy them on a testnet or mainnet. |
| 13 | + |
| 14 | +LocalOsmosis comes preconfigured with opinionated, sensible defaults for standard testing environments. If other projects mention testing on LocalOsmosis, they are referring to the settings defined in this repo. |
| 15 | + |
| 16 | +LocalOsmosis has the following advantages over a public testnet: |
| 17 | + |
| 18 | +- Easily modifiable world states |
| 19 | +- Quick to reset for rapid iterations |
| 20 | +- Simple simulations of different scenarios |
| 21 | +- Controllable validator behavior |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- [`Docker`](https://www.docker.com/) |
| 26 | +- [`docker-compose`](https://github.com/docker/compose) |
| 27 | +- [`Osmosisd`](https://get.osmosis.zone) |
| 28 | + * Select option 3 (localosmosis), the installer will configure everything for you. |
| 29 | + * The osmosisd dameon on your local computer is used to communicate with the localosmosis daemin running inside the Docker container. |
| 30 | +- Supported known architecture: x86_64 |
| 31 | +- 16+ GB of RAM is recommended |
| 32 | + |
| 33 | +## Get started |
| 34 | +## 1. LocalOsmosis - No Initial State |
| 35 | + |
| 36 | +The following commands must be executed from the root folder of the Osmosis repository. |
| 37 | + |
| 38 | +1. Make any change to the osmosis code that you want to test |
| 39 | + |
| 40 | +2. Initialize LocalOsmosis: |
| 41 | + |
| 42 | +```bash |
| 43 | +make localnet-init |
| 44 | +``` |
| 45 | + |
| 46 | +The command: |
| 47 | + |
| 48 | +- Builds a local docker image with the latest changes |
| 49 | +- Cleans the `$HOME/.osmosisd-local` folder |
| 50 | + |
| 51 | +3. Start LocalOsmosis: |
| 52 | + |
| 53 | +```bash |
| 54 | +make localnet-start |
| 55 | +``` |
| 56 | + |
| 57 | +> Note |
| 58 | +> |
| 59 | +> You can also start LocalOsmosis in detach mode with: |
| 60 | +> |
| 61 | +> `make localnet-startd` |
| 62 | +
|
| 63 | +4. (optional) Add your validator wallet and 9 other preloaded wallets automatically: |
| 64 | + |
| 65 | +```bash |
| 66 | +make localnet-keys |
| 67 | +``` |
| 68 | + |
| 69 | +- These keys are added to your `--keyring-backend test` |
| 70 | +- If the keys are already on your keyring, you will get an `"Error: aborted"` |
| 71 | +- Ensure you use the name of the account as listed in the table below, as well as ensure you append the `--keyring-backend test` to your txs |
| 72 | +- Example: `osmosisd tx bank send lo-test2 osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks --keyring-backend test --chain-id localosmosis` |
| 73 | + |
| 74 | +5. You can stop chain, keeping the state with |
| 75 | + |
| 76 | +```bash |
| 77 | +make localnet-stop |
| 78 | +``` |
| 79 | + |
| 80 | +6. When you are done you can clean up the environment with: |
| 81 | + |
| 82 | +```bash |
| 83 | +make localnet-clean |
| 84 | +``` |
| 85 | + |
| 86 | +## 2. LocalOsmosis - With Mainnet State |
| 87 | + |
| 88 | +Running an osmosis network with mainnet state is now as easy as setting up a stateless localnet. |
| 89 | + |
| 90 | +1. Set up a mainnet node and stop it at whatever height you want to fork the network at. |
| 91 | + |
| 92 | +2. There are now two options you can choose from: |
| 93 | + |
| 94 | + - **Mainnet is on version X, and you want to create a testnet on version X.** |
| 95 | + |
| 96 | + On version X, run: |
| 97 | + |
| 98 | + ```bash |
| 99 | + osmosisd in-place-testnet localosmosis osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj |
| 100 | + ``` |
| 101 | + |
| 102 | + Where the first input is the desired chain-id of the new network and the second input is the desired validator operator address (where you vote from). |
| 103 | + The address provided above is included in the localosmosis keyring under the name 'val'. |
| 104 | + |
| 105 | + You now have a network you own with the mainnet state on version X. |
| 106 | + |
| 107 | + - **Mainnet is on version X, and you want to create a testnet on version X+1.** |
| 108 | + |
| 109 | + On version X, run: |
| 110 | + |
| 111 | + ```bash |
| 112 | + osmosisd in-place-testnet localosmosis osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj --trigger-testnet-upgrade |
| 113 | + ``` |
| 114 | + |
| 115 | + Where the first input is the desired chain-id of the new network and the second input is the desired validator operator address (where you vote from). |
| 116 | + The address provided above is included in the localosmosis keyring under the name 'val'. |
| 117 | + |
| 118 | + The network will start and hit 10 blocks, at which point the upgrade will trigger and the network will halt. |
| 119 | + |
| 120 | + Then, on version X+1, run: |
| 121 | + |
| 122 | + ```bash |
| 123 | + osmosisd start |
| 124 | + ``` |
| 125 | + |
| 126 | +You now have a network you own with the mainnet state on version X+1. |
| 127 | + |
| 128 | +## Accounts |
| 129 | + |
| 130 | +LocalOsmosis is pre-configured with one validator and 9 accounts with ION and OSMO balances. You can also manually add these keys using `make localnet-keys` |
| 131 | + |
| 132 | +| Account | Address | Mnemonic | |
| 133 | +| --------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 134 | +| lo-val | `osmo1phaxpevm5wecex2jyaqty2a4v02qj7qmlmzk5a`<br/>`osmovaloper1phaxpevm5wecex2jyaqty2a4v02qj7qm9v24r6` | `satisfy adjust timber high purchase tuition stool faith fine install that you unaware feed domain license impose boss human eager hat rent enjoy dawn` | |
| 135 | +| lo-test1 | `osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks` | `notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius` | |
| 136 | +| lo-test2 | `osmo18s5lynnmx37hq4wlrw9gdn68sg2uxp5rgk26vv` | `quality vacuum heart guard buzz spike sight swarm shove special gym robust assume sudden deposit grid alcohol choice devote leader tilt noodle tide penalty` | |
| 137 | +| lo-test3 | `osmo1qwexv7c6sm95lwhzn9027vyu2ccneaqad4w8ka` | `symbol force gallery make bulk round subway violin worry mixture penalty kingdom boring survey tool fringe patrol sausage hard admit remember broken alien absorb` | |
| 138 | +| lo-test4 | `osmo14hcxlnwlqtq75ttaxf674vk6mafspg8xwgnn53` | `bounce success option birth apple portion aunt rural episode solution hockey pencil lend session cause hedgehog slender journey system canvas decorate razor catch empty` | |
| 139 | +| lo-test5 | `osmo12rr534cer5c0vj53eq4y32lcwguyy7nndt0u2t` | `second render cat sing soup reward cluster island bench diet lumber grocery repeat balcony perfect diesel stumble piano distance caught occur example ozone loyal` | |
| 140 | +| lo-test6 | `osmo1nt33cjd5auzh36syym6azgc8tve0jlvklnq7jq` | `spatial forest elevator battle also spoon fun skirt flight initial nasty transfer glory palm drama gossip remove fan joke shove label dune debate quick` | |
| 141 | +| lo-test7 | `osmo10qfrpash5g2vk3hppvu45x0g860czur8ff5yx0` | `noble width taxi input there patrol clown public spell aunt wish punch moment will misery eight excess arena pen turtle minimum grain vague inmate` | |
| 142 | +| lo-test8 | `osmo1f4tvsdukfwh6s9swrc24gkuz23tp8pd3e9r5fa` | `cream sport mango believe inhale text fish rely elegant below earth april wall rug ritual blossom cherry detail length blind digital proof identify ride` | |
| 143 | +| lo-test9 | `osmo1myv43sqgnj5sm4zl98ftl45af9cfzk7nhjxjqh` | `index light average senior silent limit usual local involve delay update rack cause inmate wall render magnet common feature laundry exact casual resource hundred` | |
| 144 | +| lo-test10 | `osmo14gs9zqh8m49yy9kscjqu9h72exyf295afg6kgk` | `prefer forget visit mistake mixture feel eyebrow autumn shop pair address airport diesel street pass vague innocent poem method awful require hurry unhappy shoulder` | |
0 commit comments