Skip to content

Commit a6dff23

Browse files
vncoelhoNGDAdmin
andauthored
Return expect to verify neo-cli (#3318)
* Return expect to verify neo-cli * Create test-neo-cli.expect * Organize * Update test-neo-cli.expect * Update test-neo-cli.expect * Update main.yml * Update main.yml * Try to improve path and dependencies install * Depencies are needed for each task * Break lines * Script path * Organize script folder --------- Co-authored-by: NGD Admin <[email protected]>
1 parent 4c1194f commit a6dff23

File tree

2 files changed

+122
-2
lines changed

2 files changed

+122
-2
lines changed

.github/workflows/main.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,30 @@ jobs:
2424
- name: Check Format (*.cs)
2525
run: dotnet format --verify-no-changes --verbosity diagnostic
2626

27+
Build-Test-Neo-Cli:
28+
needs: [Format]
29+
timeout-minutes: 15
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Setup .NET
36+
uses: actions/setup-dotnet@v4
37+
with:
38+
dotnet-version: ${{ env.DOTNET_VERSION }}
39+
2740
- name: Build (Neo.CLI)
41+
run: dotnet build ./src/Neo.CLI --output ./out/Neo.CLI
42+
43+
- name: Install dependencies
2844
run: |
29-
dotnet build ./src/Neo.CLI \
30-
--output ./out/Neo.CLI
45+
sudo apt-get install libleveldb-dev expect
46+
find ./out -name 'config.json' | xargs perl -pi -e 's|LevelDBStore|MemoryStore|g'
3147
48+
- name: Run tests with expect
49+
run: expect ./scripts/Neo.CLI/test-neo-cli.expect
50+
3251
Test:
3352
needs: [Format]
3453
timeout-minutes: 15
@@ -39,15 +58,18 @@ jobs:
3958
steps:
4059
- name: Checkout
4160
uses: actions/checkout@v4
61+
4262
- name: Setup .NET
4363
uses: actions/setup-dotnet@v4
4464
with:
4565
dotnet-version: ${{ env.DOTNET_VERSION }}
66+
4667
- name: Test
4768
if: matrix.os != 'ubuntu-latest'
4869
run: |
4970
dotnet sln neo.sln remove ./tests/Neo.Plugins.Storage.Tests/Neo.Plugins.Storage.Tests.csproj
5071
dotnet test
72+
5173
- name: Test for coverall
5274
if: matrix.os == 'ubuntu-latest'
5375
run: |
@@ -139,14 +161,17 @@ jobs:
139161
steps:
140162
- name: Checkout
141163
uses: actions/checkout@v4
164+
142165
- name: Get version
143166
id: get_version
144167
run: |
145168
sudo apt install xmlstarlet
146169
find src -name Directory.Build.props | xargs xmlstarlet sel -N i=http://schemas.microsoft.com/developer/msbuild/2003 -t -v "concat('::set-output name=version::v',//i:VersionPrefix/text())" | xargs echo
170+
147171
- name: Check tag
148172
id: check_tag
149173
run: curl -s -I ${{ format('https://github.com/{0}/releases/tag/{1}', github.repository, steps.get_version.outputs.version) }} | head -n 1 | cut -d$' ' -f2 | xargs printf "::set-output name=statusCode::%s" | xargs echo
174+
150175
- name: Create release
151176
if: steps.check_tag.outputs.statusCode == '404'
152177
id: create_release
@@ -157,53 +182,62 @@ jobs:
157182
tag_name: ${{ steps.get_version.outputs.version }}
158183
release_name: ${{ steps.get_version.outputs.version }}
159184
prerelease: ${{ contains(steps.get_version.outputs.version, '-') }}
185+
160186
- name: Setup .NET
161187
if: steps.check_tag.outputs.statusCode == '404'
162188
uses: actions/setup-dotnet@v4
163189
with:
164190
dotnet-version: ${{ env.DOTNET_VERSION }}
191+
165192
- name : Pack (Neo)
166193
if: steps.check_tag.outputs.statusCode == '404'
167194
run: |
168195
dotnet pack ./src/Neo \
169196
--configuration Release \
170197
--output ./out
198+
171199
- name : Pack (Neo.IO)
172200
if: steps.check_tag.outputs.statusCode == '404'
173201
run: |
174202
dotnet pack ./src/Neo.IO \
175203
--configuration Release \
176204
--output ./out
205+
177206
- name : Pack (Neo.Extensions)
178207
if: steps.check_tag.outputs.statusCode == '404'
179208
run: |
180209
dotnet pack ./src/Neo.Extensions \
181210
--configuration Release \
182211
--output ./out
212+
183213
- name : Pack (Neo.Json)
184214
if: steps.check_tag.outputs.statusCode == '404'
185215
run: |
186216
dotnet pack ./src/Neo.Json \
187217
--configuration Release \
188218
--output ./out
219+
189220
- name : Pack (Neo.VM)
190221
if: steps.check_tag.outputs.statusCode == '404'
191222
run: |
192223
dotnet pack ./src/Neo.VM \
193224
--configuration Release \
194225
--output ./out
226+
195227
- name : Pack (Neo.ConsoleService)
196228
if: steps.check_tag.outputs.statusCode == '404'
197229
run: |
198230
dotnet pack ./src/Neo.ConsoleService \
199231
--configuration Release \
200232
--output ./out
233+
201234
- name : Pack (Neo.Cryptography.BLS12_381)
202235
if: steps.check_tag.outputs.statusCode == '404'
203236
run: |
204237
dotnet pack ./src/Neo.Cryptography.BLS12_381 \
205238
--configuration Release \
206239
--output ./out
240+
207241
- name: Publish to NuGet
208242
if: steps.check_tag.outputs.statusCode == '404'
209243
run: |
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/expect -f
2+
#
3+
# This script uses expect to test neo-cli
4+
#
5+
set timeout 10
6+
7+
8+
# Start neo-cli
9+
spawn dotnet out/Neo.CLI/neo-cli.dll
10+
11+
# Expect the main input prompt
12+
expect {
13+
"neo> " { }
14+
"error" { exit 2 }
15+
timeout { exit 1 }
16+
}
17+
18+
#
19+
# Test 'create wallet'
20+
#
21+
send "create wallet test-wallet1.json\n"
22+
23+
expect {
24+
"password:" { send "asd\n" }
25+
"error" { exit 2 }
26+
timeout { exit 1 }
27+
}
28+
29+
expect {
30+
"password:" { send "asd\n" }
31+
"error" { exit 2 }
32+
timeout { exit 1 }
33+
}
34+
35+
expect {
36+
" Address:" { }
37+
"error" { exit 2 }
38+
timeout { exit 1 }
39+
}
40+
41+
42+
#
43+
# Test 'create wallet'
44+
#
45+
send "create wallet test-wallet2.json L2ArHTuiDL4FHu4nfyhamrG8XVYB4QyRbmhj7vD6hFMB5iAMSTf6\n"
46+
47+
expect {
48+
"password:" { send "abcd\n" }
49+
"error" { exit 2 }
50+
timeout { exit 1 }
51+
}
52+
53+
expect {
54+
"password:" { send "abcd\n" }
55+
"error" { exit 2 }
56+
timeout { exit 1 }
57+
}
58+
59+
expect {
60+
"NUj249PQg9EMJfAuxKizdJwMG7GSBzYX2Y" { }
61+
"error" { exit 2 }
62+
timeout { exit 1 }
63+
}
64+
65+
#
66+
# Test 'list address'
67+
#
68+
send "list address\n"
69+
70+
expect {
71+
"neo> " { }
72+
"error" { exit 2 }
73+
timeout { exit 1 }
74+
}
75+
76+
#
77+
# Test 'create address'
78+
#
79+
send "create address\n"
80+
81+
expect {
82+
"neo> " { }
83+
"error" { exit 2 }
84+
timeout { exit 1 }
85+
}
86+
exit 0

0 commit comments

Comments
 (0)