Skip to content

Commit 68a922f

Browse files
authored
Fix READMEs and run test_script_in_readme in CI. (#3738)
## Motivation `test_script_in_readme` is behind the `storage-service` feature flag, but never executed explicitly in CI. Several README scripts don't actually work. ## Proposal Fix them, and run them in CI. I couldn't fix `how_to_perform_http_requests`, and it passes for me locally, so I disabled it and created #3743 for now. ## Test Plan Yes! ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 607fd1e commit 68a922f

File tree

9 files changed

+136
-129
lines changed

9 files changed

+136
-129
lines changed

.github/workflows/rust.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,26 @@ jobs:
233233
cargo run --release -p linera-storage-service -- memory --endpoint $LINERA_STORAGE_SERVICE &
234234
cargo test --features storage-service -- storage_service --nocapture
235235
236+
test-readme-scripts:
237+
runs-on: ubuntu-latest-16-cores
238+
timeout-minutes: 40
239+
steps:
240+
- uses: actions/checkout@v3
241+
- uses: actions-rust-lang/setup-rust-toolchain@v1
242+
- name: Install Protoc
243+
uses: arduino/setup-protoc@v1
244+
with:
245+
repo-token: ${{ secrets.GITHUB_TOKEN }}
246+
- name: Build example applications
247+
run: |
248+
cd examples
249+
cargo build --locked --release --target wasm32-unknown-unknown
250+
cd ..
251+
cargo build --locked -p linera-storage-service
252+
- name: Run the storage-service instance and the README script tests
253+
run: |
254+
cargo test --locked -p linera-service --features storage-service -- test_script_in_readme --nocapture
255+
236256
web:
237257
runs-on: ubuntu-latest
238258
timeout-minutes: 20

examples/amm/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ export LINERA_STORAGE="rocksdb:$LINERA_TMP_DIR/client.db"
5858

5959
linera wallet init --faucet $FAUCET_URL
6060

61+
INFO_AMM=($(linera wallet request-chain --faucet $FAUCET_URL))
6162
INFO_1=($(linera wallet request-chain --faucet $FAUCET_URL))
6263
INFO_2=($(linera wallet request-chain --faucet $FAUCET_URL))
63-
INFO_AMM=($(linera wallet request-chain --faucet $FAUCET_URL))
64+
CHAIN_AMM="${INFO_AMM[0]}"
6465
CHAIN_1="${INFO_1[0]}"
6566
CHAIN_2="${INFO_2[0]}"
66-
CHAIN_AMM="${INFO_AMM[0]}"
67+
OWNER_AMM="${INFO_AMM[3]}"
6768
OWNER_1="${INFO_1[3]}"
6869
OWNER_2="${INFO_2[3]}"
69-
OWNER_AMM="${INFO_AMM[3]}"
7070
```
7171

7272
Now we have to publish and create the fungible applications. The flag `--wait-for-outgoing-messages` waits until a quorum of validators has confirmed that all sent cross-chain messages have been delivered.

examples/crowd-funding/README.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,31 +65,31 @@ linera_spawn linera net up --with-faucet --faucet-port $FAUCET_PORT
6565
Create the user wallets and add chains to them:
6666

6767
```bash
68-
export LINERA_WALLET_0="$LINERA_TMP_DIR/wallet_0.json"
69-
export LINERA_STORAGE_0="rocksdb:$LINERA_TMP_DIR/client_0.db"
7068
export LINERA_WALLET_1="$LINERA_TMP_DIR/wallet_1.json"
7169
export LINERA_STORAGE_1="rocksdb:$LINERA_TMP_DIR/client_1.db"
70+
export LINERA_WALLET_2="$LINERA_TMP_DIR/wallet_2.json"
71+
export LINERA_STORAGE_2="rocksdb:$LINERA_TMP_DIR/client_2.db"
7272

73-
linera --with-wallet 0 wallet init --faucet $FAUCET_URL
7473
linera --with-wallet 1 wallet init --faucet $FAUCET_URL
74+
linera --with-wallet 2 wallet init --faucet $FAUCET_URL
7575

76-
INFO_0=($(linera --with-wallet 0 wallet request-chain --faucet $FAUCET_URL))
7776
INFO_1=($(linera --with-wallet 1 wallet request-chain --faucet $FAUCET_URL))
78-
CHAIN_0="${INFO_0[0]}"
77+
INFO_2=($(linera --with-wallet 2 wallet request-chain --faucet $FAUCET_URL))
7978
CHAIN_1="${INFO_1[0]}"
80-
OWNER_0="${INFO_0[3]}"
79+
CHAIN_2="${INFO_2[0]}"
8180
OWNER_1="${INFO_1[3]}"
81+
OWNER_2="${INFO_2[3]}"
8282
```
8383

84-
Note that `linera --with-wallet 0` is equivalent to `linera --wallet "$LINERA_WALLET_0"
85-
--storage "$LINERA_STORAGE_0"`.
84+
Note that `linera --with-wallet 1` is equivalent to `linera --wallet "$LINERA_WALLET_1"
85+
--storage "$LINERA_STORAGE_1"`.
8686

8787
The command below can be used to list the chains created for the test as known by each
8888
wallet:
8989

9090
```bash
91-
linera --with-wallet 0 wallet show
9291
linera --with-wallet 1 wallet show
92+
linera --with-wallet 2 wallet show
9393
```
9494

9595
A table will be shown with the chains registered in the wallet and their meta-data:
@@ -108,8 +108,8 @@ A table will be shown with the chains registered in the wallet and their meta-da
108108

109109
The default chain of each wallet should be highlighted in green. Each chain has an
110110
`Owner` field, and that is what is used for the account. Let's pick the owners of the
111-
default chain of each wallet and call them `$OWNER_0` and `$OWNER_1`. Remember the corresponding
112-
chain IDs as `$CHAIN_0` (the chain where we just published the application) and `$CHAIN_1`
111+
default chain of each wallet and call them `$OWNER_1` and `$OWNER_2`. Remember the corresponding
112+
chain IDs as `$CHAIN_1` (the chain where we just published the application) and `$CHAIN_2`
113113
(some user chain in wallet 2).
114114

115115
### Creating tokens
@@ -124,9 +124,9 @@ Create a fungible token application where two accounts start with the minted tok
124124
with 100 of them and another with 200 of them:
125125

126126
```bash
127-
APP_ID_0=$(linera --with-wallet 0 project publish-and-create \
127+
APP_ID_0=$(linera --with-wallet 1 project publish-and-create \
128128
examples/fungible \
129-
--json-argument '{ "accounts": { "'$OWNER_0'": "100", "'$OWNER_1'": "200" } }' \
129+
--json-argument '{ "accounts": { "'$OWNER_1'": "100", "'$OWNER_2'": "200" } }' \
130130
--json-parameters "{ \"ticker_symbol\": \"FUN\" }")
131131

132132
# Wait for it to fully complete
@@ -141,12 +141,12 @@ Similarly, we're going to create a crowd-funding campaign on the default chain.
141141
to specify our fungible application as a dependency and a parameter:
142142

143143
```bash
144-
APP_ID_1=$(linera --with-wallet 0 \
144+
APP_ID_1=$(linera --with-wallet 1 \
145145
project publish-and-create \
146146
examples/crowd-funding \
147147
crowd_funding \
148148
--required-application-ids $APP_ID_0 \
149-
--json-argument '{ "owner": "'$OWNER_0'", "deadline": 4102473600000000, "target": "100." }' \
149+
--json-argument '{ "owner": "'$OWNER_1'", "deadline": 4102473600000000, "target": "100." }' \
150150
--json-parameters '"'"$APP_ID_0"'"')
151151

152152
# Wait for it to fully complete
@@ -158,12 +158,12 @@ sleep 5
158158
First, a node service has to be started for each wallet, using two different ports:
159159

160160
```bash
161-
linera --with-wallet 0 service --port 8080 &
161+
linera --with-wallet 1 service --port 8080 &
162162

163163
# Wait for it to fully complete
164164
sleep 2
165165

166-
linera --with-wallet 1 service --port 8081 &
166+
linera --with-wallet 2 service --port 8081 &
167167

168168
# Wait for it to fully complete
169169
sleep 2
@@ -175,7 +175,7 @@ Point your browser to http://localhost:8080, and enter the query:
175175

176176
```gql,uri=http://localhost:8080
177177
query { applications(
178-
chainId: "$CHAIN_0"
178+
chainId: "$CHAIN_1"
179179
) { id link } }
180180
```
181181

@@ -186,74 +186,74 @@ application by its ID. The entry also has a field `link`. If you open that in a
186186
see the GraphQL API for that application on that chain.
187187

188188
Let's pledge 30 tokens by the campaign creator themselves.
189-
For `$OWNER_0` on 8080, run `echo "http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1"` to get the URL, open it
189+
For `$OWNER_1` on 8080, run `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID_1"` to get the URL, open it
190190
and run the following query:
191191

192-
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
192+
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID_1
193193
mutation { pledge(
194-
owner:"$OWNER_0",
194+
owner:"$OWNER_1",
195195
amount:"30."
196196
) }
197197
```
198198

199199
This will make the owner show up if we list everyone who has made a pledge so far:
200200

201-
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
201+
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID_1
202202
query { pledges { keys } }
203203
```
204204

205-
To also have `$OWNER_1` make a pledge, they first need to claim their tokens. Those are still
205+
To also have `$OWNER_2` make a pledge, they first need to claim their tokens. Those are still
206206
on the other chain, where the application was created. To get the link on 8081
207-
for the fungible application, run `echo "http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0"`,
207+
for the fungible application, run `echo "http://localhost:8081/chains/$CHAIN_2/applications/$APP_ID_0"`,
208208
open it and run the following query:
209209

210-
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
210+
```gql,uri=http://localhost:8081/chains/$CHAIN_2/applications/$APP_ID_0
211211
mutation { claim(
212212
sourceAccount: {
213-
owner: "$OWNER_1",
214-
chainId: "$CHAIN_0"
213+
owner: "$OWNER_2",
214+
chainId: "$CHAIN_1"
215215
},
216216
amount: "200.",
217217
targetAccount: {
218-
owner: "$OWNER_1",
219-
chainId: "$CHAIN_1"
218+
owner: "$OWNER_2",
219+
chainId: "$CHAIN_2"
220220
}
221221
) }
222222
```
223223

224224
You can check that the 200 tokens have arrived:
225225

226-
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_0
226+
```gql,uri=http://localhost:8081/chains/$CHAIN_2/applications/$APP_ID_0
227227
query {
228-
accounts { entry(key: "$OWNER_1") { value } }
228+
accounts { entry(key: "$OWNER_2") { value } }
229229
}
230230
```
231231

232232
Now, also on 8081, you can open the link for the crowd-funding
233-
application you get when you run `echo "http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1"`
233+
application you get when you run `echo "http://localhost:8081/chains/$CHAIN_2/applications/$APP_ID_1"`
234234
and run:
235235

236-
```gql,uri=http://localhost:8081/chains/$CHAIN_1/applications/$APP_ID_1
236+
```gql,uri=http://localhost:8081/chains/$CHAIN_2/applications/$APP_ID_1
237237
mutation { pledge(
238-
owner:"$OWNER_1",
238+
owner:"$OWNER_2",
239239
amount:"80."
240240
) }
241241
```
242242

243243
This pledges another 80 tokens. With 110 pledged in total, we have now reached the campaign
244244
goal. Now the campaign owner (on 8080) can collect the funds:
245245

246-
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_1
246+
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID_1
247247
mutation { collect }
248248
```
249249

250250
Get the fungible application on
251-
8080 URL by running `echo "http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0"`,
251+
8080 URL by running `echo "http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID_0"`,
252252
then check that we have received 110 tokens, in addition to the
253253
70 that we had left after pledging 30 by running the following query:
254254

255-
```gql,uri=http://localhost:8080/chains/$CHAIN_0/applications/$APP_ID_0
255+
```gql,uri=http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID_0
256256
query {
257-
accounts { entry(key: "$OWNER_0") { value } }
257+
accounts { entry(key: "$OWNER_1") { value } }
258258
}
259259
```

examples/hex-game/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ linera_spawn linera net up --with-faucet --faucet-port $FAUCET_PORT
4848
Create the user wallets and add chains to them:
4949

5050
```bash
51-
export LINERA_WALLET_0="$LINERA_TMP_DIR/wallet_0.json"
52-
export LINERA_STORAGE_0="rocksdb:$LINERA_TMP_DIR/client_0.db"
5351
export LINERA_WALLET_1="$LINERA_TMP_DIR/wallet_1.json"
5452
export LINERA_STORAGE_1="rocksdb:$LINERA_TMP_DIR/client_1.db"
53+
export LINERA_WALLET_2="$LINERA_TMP_DIR/wallet_2.json"
54+
export LINERA_STORAGE_2="rocksdb:$LINERA_TMP_DIR/client_2.db"
5555

5656
linera --with-wallet 1 wallet init --faucet $FAUCET_URL
5757
linera --with-wallet 2 wallet init --faucet $FAUCET_URL

examples/llm/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,22 @@ Then, a node service for the current wallet has to be started:
7878
```bash
7979
PORT=8080
8080
linera --long-lived-services service --port $PORT &
81-
```
81+
```
8282

8383
The experimental option `--long-lived-services` is used for performance, to avoid
8484
reloading the model between queries.
8585

8686
Next, navigate to `llm/web-frontend` and install the requisite `npm`
8787
dependencies:
8888

89-
```bash
89+
```bash,ignore
9090
cd llm/web-frontend
9191
npm install --no-save
9292
BROWSER=none npm start
9393
```
9494

9595
Finally, navigate to `localhost:3000` to interact with the Linera ChatBot.
96-
```bash
96+
97+
```bash,ignore
9798
echo "http://localhost:3000/$CHAIN?app=$APP_ID&port=$PORT"
9899
```

examples/matching-engine/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,6 @@ MATCHING_ENGINE=$(linera --wait-for-outgoing-messages \
115115
--required-application-ids $FUN1_APP_ID $FUN2_APP_ID)
116116
```
117117

118-
And make sure chain 2 also has it:
119-
120-
```bash
121-
linera --wait-for-outgoing-messages request-application \
122-
--requester-chain-id $CHAIN_2 $MATCHING_ENGINE
123-
```
124-
125118
### Using the Matching Engine Application
126119

127120
First, a node service for the current wallet has to be started:

0 commit comments

Comments
 (0)