Skip to content

Commit 4d5c201

Browse files
authored
Increase newman postman tests coverage (#393)
Postman newman tests can be used to make multipl quick rpc calls to an endpoint. The current solution is missing a few consensus node hitting calls - Add `eth_gasPrice` - Add `eth_feeHistory` - Update `postman.json` to use `baseUrl` - Add github action to run newman script Signed-off-by: Nana-EC <[email protected]>
1 parent f23e77b commit 4d5c201

File tree

2 files changed

+181
-43
lines changed

2 files changed

+181
-43
lines changed

.github/workflows/postman.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Postman Endpoint Tests
2+
3+
on:
4+
pull_request:
5+
branches: [ main, release/** ]
6+
push:
7+
branches: [ main, release/** ]
8+
tags: [ v* ]
9+
10+
jobs:
11+
setup-local-hedera:
12+
name: Postman Endpoint Tests
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- name: Setup node
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 16
21+
22+
- name: Checkout repo
23+
uses: actions/checkout@v2
24+
25+
- name: Install packages
26+
run: npm ci
27+
28+
- name: Create .env file
29+
run: cp ./packages/server/tests/localAcceptance.env .env
30+
31+
- name: Lerna Bootstrap
32+
run: npm run setup
33+
34+
- name: Install pnpm
35+
run: npm install -g pnpm
36+
37+
- name: Build Typescript
38+
run: npx lerna run build
39+
40+
- name: Run RPC Server
41+
run: npm run integration:prerequisite &
42+
43+
- name: Install newman
44+
run: npm install -g newman
45+
46+
- name: Run the newman script
47+
uses: nick-fields/retry@v2
48+
with:
49+
max_attempts: 10
50+
timeout_minutes: 10
51+
retry_wait_seconds: 45
52+
command: newman run packages/server/tests/postman.json

packages/server/tests/postman.json

Lines changed: 129 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
}
4040
},
4141
"url": {
42-
"raw": "{{base_url}}",
42+
"raw": "{{baseUrl}}",
4343
"host": [
44-
"{{base_url}}"
44+
"{{baseUrl}}"
4545
]
4646
}
4747
},
@@ -79,9 +79,9 @@
7979
}
8080
},
8181
"url": {
82-
"raw": "{{base_url}}",
82+
"raw": "{{baseUrl}}",
8383
"host": [
84-
"{{base_url}}"
84+
"{{baseUrl}}"
8585
]
8686
}
8787
},
@@ -119,9 +119,9 @@
119119
}
120120
},
121121
"url": {
122-
"raw": "{{base_url}}",
122+
"raw": "{{baseUrl}}",
123123
"host": [
124-
"{{base_url}}"
124+
"{{baseUrl}}"
125125
]
126126
}
127127
},
@@ -159,9 +159,95 @@
159159
}
160160
},
161161
"url": {
162-
"raw": "{{base_url}}",
162+
"raw": "{{baseUrl}}",
163163
"host": [
164-
"{{base_url}}"
164+
"{{baseUrl}}"
165+
]
166+
}
167+
},
168+
"response": []
169+
},
170+
{
171+
"name": "eth_feeHistory",
172+
"event": [
173+
{
174+
"listen": "test",
175+
"script": {
176+
"exec": [
177+
"pm.test(\"Success\", () => {",
178+
" var response = pm.response.json();",
179+
" pm.expect(response.result.baseFeePerGas).to.be.an(\"array\");",
180+
" pm.expect(response.result.baseFeePerGas).length(4);",
181+
" pm.expect(response.result.gasUsedRatio).to.be.an(\"array\");",
182+
" pm.expect(response.result.gasUsedRatio).length(3);",
183+
" pm.expect(response.result.oldestBlock).to.match(/^0x[a-f0-9]+$/);",
184+
" pm.expect(response.result.reward).to.be.an(\"array\");",
185+
" pm.expect(response.result.reward).length(3);",
186+
" pm.expect(response.id).to.equal(\"test_id\");",
187+
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
188+
"});",
189+
""
190+
],
191+
"type": "text/javascript"
192+
}
193+
}
194+
],
195+
"request": {
196+
"method": "POST",
197+
"header": [],
198+
"body": {
199+
"mode": "raw",
200+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_feeHistory\",\n \"params\": [3, \"latest\", [25, 75]]\n}",
201+
"options": {
202+
"raw": {
203+
"language": "json"
204+
}
205+
}
206+
},
207+
"url": {
208+
"raw": "{{baseUrl}}",
209+
"host": [
210+
"{{baseUrl}}"
211+
]
212+
}
213+
},
214+
"response": []
215+
},
216+
{
217+
"name": "eth_gasPrice",
218+
"event": [
219+
{
220+
"listen": "test",
221+
"script": {
222+
"exec": [
223+
"pm.test(\"Success\", () => {",
224+
" var response = pm.response.json();",
225+
" pm.expect(response.result).to.match(/^0x[a-f0-9]+$/);",
226+
" pm.expect(response.id).to.equal(\"test_id\");",
227+
" pm.expect(response.jsonrpc).to.equal(\"2.0\");",
228+
"});",
229+
""
230+
],
231+
"type": "text/javascript"
232+
}
233+
}
234+
],
235+
"request": {
236+
"method": "POST",
237+
"header": [],
238+
"body": {
239+
"mode": "raw",
240+
"raw": "{\n \"id\": \"test_id\",\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_gasPrice\",\n \"params\": []\n}",
241+
"options": {
242+
"raw": {
243+
"language": "json"
244+
}
245+
}
246+
},
247+
"url": {
248+
"raw": "{{baseUrl}}",
249+
"host": [
250+
"{{baseUrl}}"
165251
]
166252
}
167253
},
@@ -199,9 +285,9 @@
199285
}
200286
},
201287
"url": {
202-
"raw": "{{base_url}}",
288+
"raw": "{{baseUrl}}",
203289
"host": [
204-
"{{base_url}}"
290+
"{{baseUrl}}"
205291
]
206292
}
207293
},
@@ -259,9 +345,9 @@
259345
}
260346
},
261347
"url": {
262-
"raw": "{{base_url}}",
348+
"raw": "{{baseUrl}}",
263349
"host": [
264-
"{{base_url}}"
350+
"{{baseUrl}}"
265351
]
266352
}
267353
},
@@ -299,9 +385,9 @@
299385
}
300386
},
301387
"url": {
302-
"raw": "{{base_url}}",
388+
"raw": "{{baseUrl}}",
303389
"host": [
304-
"{{base_url}}"
390+
"{{baseUrl}}"
305391
]
306392
}
307393
},
@@ -339,9 +425,9 @@
339425
}
340426
},
341427
"url": {
342-
"raw": "{{base_url}}",
428+
"raw": "{{baseUrl}}",
343429
"host": [
344-
"{{base_url}}"
430+
"{{baseUrl}}"
345431
]
346432
}
347433
},
@@ -379,9 +465,9 @@
379465
}
380466
},
381467
"url": {
382-
"raw": "{{base_url}}",
468+
"raw": "{{baseUrl}}",
383469
"host": [
384-
"{{base_url}}"
470+
"{{baseUrl}}"
385471
]
386472
}
387473
},
@@ -419,9 +505,9 @@
419505
}
420506
},
421507
"url": {
422-
"raw": "{{base_url}}",
508+
"raw": "{{baseUrl}}",
423509
"host": [
424-
"{{base_url}}"
510+
"{{baseUrl}}"
425511
]
426512
}
427513
},
@@ -459,9 +545,9 @@
459545
}
460546
},
461547
"url": {
462-
"raw": "{{base_url}}",
548+
"raw": "{{baseUrl}}",
463549
"host": [
464-
"{{base_url}}"
550+
"{{baseUrl}}"
465551
]
466552
}
467553
},
@@ -501,9 +587,9 @@
501587
}
502588
},
503589
"url": {
504-
"raw": "{{base_url}}",
590+
"raw": "{{baseUrl}}",
505591
"host": [
506-
"{{base_url}}"
592+
"{{baseUrl}}"
507593
]
508594
}
509595
},
@@ -542,9 +628,9 @@
542628
}
543629
},
544630
"url": {
545-
"raw": "{{base_url}}",
631+
"raw": "{{baseUrl}}",
546632
"host": [
547-
"{{base_url}}"
633+
"{{baseUrl}}"
548634
]
549635
}
550636
},
@@ -583,9 +669,9 @@
583669
}
584670
},
585671
"url": {
586-
"raw": "{{base_url}}",
672+
"raw": "{{baseUrl}}",
587673
"host": [
588-
"{{base_url}}"
674+
"{{baseUrl}}"
589675
]
590676
}
591677
},
@@ -623,9 +709,9 @@
623709
}
624710
},
625711
"url": {
626-
"raw": "{{base_url}}",
712+
"raw": "{{baseUrl}}",
627713
"host": [
628-
"{{base_url}}"
714+
"{{baseUrl}}"
629715
]
630716
}
631717
},
@@ -663,9 +749,9 @@
663749
}
664750
},
665751
"url": {
666-
"raw": "{{base_url}}",
752+
"raw": "{{baseUrl}}",
667753
"host": [
668-
"{{base_url}}"
754+
"{{baseUrl}}"
669755
]
670756
}
671757
},
@@ -703,9 +789,9 @@
703789
}
704790
},
705791
"url": {
706-
"raw": "{{base_url}}",
792+
"raw": "{{baseUrl}}",
707793
"host": [
708-
"{{base_url}}"
794+
"{{baseUrl}}"
709795
]
710796
}
711797
},
@@ -743,9 +829,9 @@
743829
}
744830
},
745831
"url": {
746-
"raw": "{{base_url}}",
832+
"raw": "{{baseUrl}}",
747833
"host": [
748-
"{{base_url}}"
834+
"{{baseUrl}}"
749835
]
750836
}
751837
},
@@ -783,9 +869,9 @@
783869
}
784870
},
785871
"url": {
786-
"raw": "{{base_url}}",
872+
"raw": "{{baseUrl}}",
787873
"host": [
788-
"{{base_url}}"
874+
"{{baseUrl}}"
789875
]
790876
}
791877
},
@@ -823,9 +909,9 @@
823909
}
824910
},
825911
"url": {
826-
"raw": "{{base_url}}",
912+
"raw": "{{baseUrl}}",
827913
"host": [
828-
"{{base_url}}"
914+
"{{baseUrl}}"
829915
]
830916
}
831917
},
@@ -863,9 +949,9 @@
863949
}
864950
},
865951
"url": {
866-
"raw": "{{base_url}}",
952+
"raw": "{{baseUrl}}",
867953
"host": [
868-
"{{base_url}}"
954+
"{{baseUrl}}"
869955
]
870956
}
871957
},
@@ -894,7 +980,7 @@
894980
],
895981
"variable": [
896982
{
897-
"key": "base_url",
983+
"key": "baseUrl",
898984
"value": "localhost:7546",
899985
"type": "string"
900986
}

0 commit comments

Comments
 (0)