|
| 1 | +## Instructions for running a public testnet end-to-end integration test |
| 2 | + |
| 3 | +What follows is a series of steps to demonstrate running an end-to-end |
| 4 | +integration test of the PAB on the public testnet. |
| 5 | + |
| 6 | +#### Process |
| 7 | + |
| 8 | +Assumptions: |
| 9 | + |
| 10 | +- You have the `plutus-apps` repo checked out at `$PLUTUS` |
| 11 | +- You have [jq](https://stedolan.github.io/jq/) |
| 12 | +- You have a few hours to wait for everything to sync (the first time.) |
| 13 | + |
| 14 | +Steps: |
| 15 | + |
| 16 | +You will need ~6 terminals to run all the different components. |
| 17 | + |
| 18 | + |
| 19 | +1. Build all the necessary components: |
| 20 | + |
| 21 | + ``` |
| 22 | + > cd $PLUTUS |
| 23 | + > cabal build plutus-pab-examples plutus-chain-index cardano-node cardano-wallet |
| 24 | + ``` |
| 25 | + |
| 26 | +2. Start the testnet node locally: |
| 27 | + |
| 28 | + ``` |
| 29 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 30 | + > ./start-testnet-node.sh |
| 31 | + ``` |
| 32 | + |
| 33 | + Note: It's important that this is done from the specific directory, because |
| 34 | + the config paths are relative. |
| 35 | + |
| 36 | +3. Run the cardano wallet backend: |
| 37 | + |
| 38 | + ``` |
| 39 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 40 | + > cabal exec -- cardano-wallet serve \ |
| 41 | + --testnet testnet/testnet-byron-genesis.json \ |
| 42 | + --node-socket testnet/node.sock |
| 43 | + ``` |
| 44 | + |
| 45 | +4. Create or restore a public testnet wallet: |
| 46 | + |
| 47 | + Here you have a few options. You can re-use an existing wallet, or create |
| 48 | + one. |
| 49 | + |
| 50 | + **Create a new wallet** |
| 51 | + |
| 52 | + - Generate a recovery phrase: |
| 53 | + |
| 54 | + ``` |
| 55 | + > cabal exec -- cardano-wallet recovery-phrase generate |
| 56 | + ``` |
| 57 | + |
| 58 | + - Save this in a file named `restore-wallet.json` in the `testnet` folder: |
| 59 | + |
| 60 | + ``` |
| 61 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 62 | + > cat testnet/restore-wallet.json |
| 63 | + { "name": "PAB testing wallet" |
| 64 | + , "mnemonic_sentence": ["word1", "word2", ...] |
| 65 | + , "passphrase": "pab123456789" |
| 66 | + } |
| 67 | + ``` |
| 68 | + |
| 69 | + - Load the wallet: |
| 70 | + |
| 71 | + ``` |
| 72 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 73 | + > curl -H "content-type: application/json" -XPOST \ |
| 74 | + -d @testnet/restore-wallet.json \ |
| 75 | + localhost:8090/v2/wallets |
| 76 | + ``` |
| 77 | + |
| 78 | + Then, take note of the Wallet ID that is created, and save that: |
| 79 | + |
| 80 | + ``` |
| 81 | + > export WALLET_ID=... |
| 82 | + ``` |
| 83 | + |
| 84 | + - Put some tAda in it, by first obtaining an address: |
| 85 | + |
| 86 | + ``` |
| 87 | + > curl -H "content-type: application/json" \ |
| 88 | + -XGET localhost:8090/v2/wallets/$WALLET_ID/addresses | jq '.' |
| 89 | + ``` |
| 90 | + |
| 91 | + (Any address will do.) |
| 92 | + |
| 93 | + - Then, navigate over to the [tesnet |
| 94 | + faucet](https://testnets.cardano.org/en/testnets/cardano/tools/faucet/) and |
| 95 | + send it some tAda. |
| 96 | + |
| 97 | + You can verify that the transfer has taken place by clicking the link the |
| 98 | + faucet application gives you; you see a transaction like so: |
| 99 | + |
| 100 | +  |
| 101 | + |
| 102 | +5. Start the chain index: |
| 103 | + |
| 104 | + ``` |
| 105 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 106 | + > cabal exec -- plutus-chain-index --config testnet/chain-index-config.json start-index |
| 107 | + ``` |
| 108 | + |
| 109 | +6. Start the PAB: |
| 110 | + |
| 111 | + If it's the first time your running, you'll need to ask the PAB to make the |
| 112 | + database: |
| 113 | + |
| 114 | + ``` |
| 115 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 116 | + > cabal exec -- plutus-pab-examples \ |
| 117 | + --config testnet/pab-config.yml migrate |
| 118 | + ``` |
| 119 | + |
| 120 | + Then, run the PAB |
| 121 | + |
| 122 | + ``` |
| 123 | + > cd $PLUTUS/plutus-pab/test-node/ |
| 124 | + > cabal exec -- plutus-pab-examples \ |
| 125 | + --config testnet/pab-config.yml webserver \ |
| 126 | + --passphrase pab123456789 |
| 127 | + ``` |
| 128 | + |
| 129 | +7. Wait for all chain clients (`cardano-node`, `cardano-wallet`, |
| 130 | + `plutus-pab-examples`, `plutus-chain-index`) to fully synchronise with the testnet. |
| 131 | + |
| 132 | + On my computer, the wallet takes about 1 hour, and the chain index takes |
| 133 | + about 3 hours. |
| 134 | + |
| 135 | + You can check what slot it needs to get up to by checking [the testnet |
| 136 | + explorer](https://explorer.cardano-testnet.iohkdev.io/en); and you can query |
| 137 | + the status of the chain index like so: |
| 138 | + |
| 139 | + ``` |
| 140 | + > curl -s localhost:9083/tip | jq '.tipSlot.getSlot' |
| 141 | + ``` |
| 142 | + |
| 143 | + When it's fully synced the slot should be the same slot that the |
| 144 | + plutus-pab-examples process last printed to the console. Note that the PAB |
| 145 | + process will be silent for a while, after the initial log messages, before |
| 146 | + it starts printing log messages about its sync status. **You _must_ wait** |
| 147 | + for the PAB to start printing messages like: |
| 148 | + |
| 149 | + ``` |
| 150 | + ... |
| 151 | + Current block: 327295. Current slot: 41749136. |
| 152 | + Current block: 327295. Current slot: 41749150. |
| 153 | + ``` |
| 154 | + |
| 155 | + before running the next step. (In fact, it's okay not to wait, and it will |
| 156 | + complete eventually; but if you want to see it live, then wait.) |
| 157 | + |
| 158 | + |
| 159 | +8. **Start the integration test** |
| 160 | + |
| 161 | + ``` |
| 162 | + > curl -H "Content-Type: application/json" -v -X POST -d \ |
| 163 | + "{\"caID\":{\"tag\":\"IntegrationTest\"},\"caWallet\":{\"getWalletId\":\"$WALLET_ID\"}}" \ |
| 164 | + localhost:9080/api/contract/activate |
| 165 | + ``` |
| 166 | + |
| 167 | +9. Wait for the integration test to finish. |
| 168 | + |
| 169 | + There will be a message like `"Tx confirmed. Integration test complete."` |
| 170 | + printed from the console running the pab. |
| 171 | + |
| 172 | +That's it! |
0 commit comments