github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/docs/test-setup.md (about)

     1  # Setting up a test environment with two LIT nodes
     2  This tutorial will help you set up a test environment with two LIT nodes and a Bitcoin regtest on your computer.
     3  
     4  ## Step 1: Install Bitcoin Core in Regtest mode
     5  The first step is to download Bitcoin Core, and run it in regtest mode. This allows for easy (simulated) mining of new blocks, and does not make you dependant on obtaining official testnet coins.
     6  
     7  [Download Bitcoin Core](https://bitcoin.org/en/download) and install it. Before running it, make a file called bitcoin.conf with the following contents:
     8  
     9  ```
    10  regtest=1
    11  dnsseed=0
    12  upnp=0
    13  port=18444
    14  server=1
    15  txindex=1
    16  ```
    17  
    18  and place it in the correct location depending on your operating system:
    19  
    20  | Platform | Location |
    21  |----|----|
    22  | Linux   | `$HOME/.bitcoin/` |
    23  | Windows | `%APPDATA%\Bitcoin` |
    24  | MacOS   | `$HOME/Library/Application Support/Bitcoin/` |
    25  
    26  Then, startup Bitcoin Core. 
    27  
    28  ## Step 2: Generate the first blocks
    29  
    30  Bitcoin Core will start in regtest mode (you can see this in the window title). It will show you a progress indicator like this:
    31  
    32  ![](screen01.png) 
    33  
    34  Since this is an empty blockchain right now, you need to generate some blocks to get it going. So go to `Help` > `Debug Window`, and then click the `Console` tab. Then type the command `generate 200` and press enter:
    35  
    36  ![](screen02.png)
    37  
    38  If you go back to the main window, the progress indicator will be gone and we have 5000 BTC on our own regtest blockchain to spend. 
    39  
    40  ## Step 3: Install the LIT nodes
    41  
    42  Now the blockchain is up, we can install the LIT nodes. Download the latest binaries for your platform from [here](https://github.com/mit-dci/lit/releases) and unpack them in a new folder. Create two subfolders in that folder too, called `lit1` and `lit2`. Create a file called `lit.conf` with the following contents:
    43  
    44  ```
    45  reg=localhost
    46  rpchost=0.0.0.0
    47  rpcport=8001
    48  tracker=http://hubris.media.mit.edu:46580
    49  autoListenPort=2448
    50  autoReconnect=true
    51  autoReconnectInterval=5
    52  ```
    53  
    54  Copy the file to both folders (`lit1` and `lit2`). Open the copy in the `lit2` folder and change the `autoListenPort` to `:2449`, and `rpcport` to `8002`.
    55  
    56  ## Step 4: Starting the LIT nodes
    57  
    58  Open two terminal or command-line windows (`cmd.exe` on Windows, `xterm` on Linux, `Terminal` on MacOS) and `cd` to the directory where you put the LIT assemblies. In the first window, type this command to start up the first LIT node:
    59  
    60  (On Unix / MacOS:)
    61  ```./lit --dir=/path/to/lit1``` 
    62  
    63  (On Windows:)
    64  ```lit.exe --dir=/path/to/lit1```
    65  
    66  When starting up LIT will ask you for a passphrase to protect your wallet. You _can_ leave it empty in development/test scenarios but in general it's recommended to set a password.
    67  
    68  Then, similarly for the first node, use the second terminal window to start the second node:
    69  
    70  (On Unix / MacOS:)
    71  ```./lit --dir=/path/to/lit2``` 
    72  
    73  (On Windows:)
    74  ```lit.exe --dir=/path/to/lit2```
    75  
    76  ## Step 5: Fund the LIT wallets
    77  
    78  Now that the nodes are up, we should fund the wallets. Open another command line window, and go to the directory where you downloaded the binaries. We use the command line client `lit-af`. You can connect to the LIT nodes using the following commands:
    79  
    80  (On Unix / MacOS:)
    81  ```./lit-af --litHomeDir=/path/to/lit1 --autoListenPort=2448```
    82  ```./lit-af --litHomeDir=/path/to/lit2 --autoListenPort=2449``` 
    83  
    84  (On Windows:)
    85  ```lit-af.exe --litHomeDir=/path/to/lit1 --autoListenPort=2448```
    86  ```lit-af.exe --litHomeDir=/path/to/lit2 --autoListenPort=2449```
    87  
    88  Next, issue the `ls` command. You'll see your address printed out to the console:
    89  
    90  ```
    91  lit-af# ls
    92  entered command: ls
    93  	Listening Ports:
    94  Listening for connections on port(s) [:2448] with key ln1a9pp6jv4rgz0r7wh9tqcn89ndqv0mytr095tnp
    95  	Addresses:
    96  0 bcrt1q0hv4tx4hwdcv3p6xnhcf40ellqvst6k4a69m75 (mrzP7h3AQyxhWqVBh7TYBVzVDiaAM8R2AY)
    97  	Type: 257	Sync Height: 200	FeeRate: 80	Utxo: 0	WitConf: 0 Channel: 0
    98  ```
    99  
   100  Then switch to your Bitcoin Core client and pay the address (in this case `bcrt1q0hv4tx4hwdcv3p6xnhcf40ellqvst6k4a69m75`) 10 BTC. 
   101  
   102  ![](screen03.png)
   103  
   104  Next, use the debug console to generate another block (use the command `generate 1`, we don't need 200 blocks this time).
   105  
   106  When you issue the `ls` command again in `lit-af` you'll see that there's a Txo and a balance (behind `WitConf`):
   107  
   108  ```
   109  lit-af# ls
   110  entered command: ls
   111  	Txos:
   112  0 0a5ac3215c4a977ff104ae9c22569fb85fb310a4fde8dd06a0e68bff3fba5a59;0 h:201 amt:1000000000 /44'/257'/0'/0'/0' regtest
   113  	Listening Ports:
   114  Listening for connections on port(s) [:2448] with key ln1a9pp6jv4rgz0r7wh9tqcn89ndqv0mytr095tnp
   115  	Addresses:
   116  0 bcrt1q0hv4tx4hwdcv3p6xnhcf40ellqvst6k4a69m75 (mrzP7h3AQyxhWqVBh7TYBVzVDiaAM8R2AY)
   117  	Type: 257	Sync Height: 201	FeeRate: 80	Utxo: 1000000000	WitConf: 1000000000 Channel: 0
   118  ```
   119  
   120  Repeat the funding steps for the second node.
   121  
   122  
   123  ## Step 6: Connect the nodes together
   124  
   125  In order for the nodes to connect to each other, you need to find out the address of the first node, and then instruct the second node to connect. Connections are bi-directional, so they don't both need to connect to each other.
   126  
   127  First, find out the address on the first node by issuing the `ls` command again. You will see something like this:
   128  
   129  ```
   130  Listening Ports:
   131  Listening for connections on port(s) [:2448] with key ln1kj56x2dl6c58waen2hmkfnh8u7w0n0hgmdzsna
   132  ```
   133  
   134  The key `ln1....` is the LIT address for this node. Then, in the `lit-af` console for the second node, enter this command:
   135  
   136  ```
   137  con ln1kj56x2dl6c58waen2hmkfnh8u7w0n0hgmdzsna@localhost:2448
   138  ```
   139  
   140  The console will respond with:
   141  
   142  ```
   143  entered command: con ln1kj56x2dl6c58waen2hmkfnh8u7w0n0hgmdzsna@localhost:2448
   144  connected to peer ln1kj56x2dl6c58waen2hmkfnh8u7w0n0hgmdzsna@localhost:2448
   145  ```
   146  
   147  The nodes are now connected together. 
   148  
   149  ## Next steps
   150  
   151  Now that you have a set up with two LIT nodes, you can continue with some interesting things, we cover in follow-up tutorials:
   152  
   153  * Form and use payment channels
   154  * [Executing a Discreet Log Contract using LIT-AF] (execute-dlc-litaf.md)
   155