Skip to content

Commit

Permalink
Replace example tool and gRPC client "tests" with CLI (#14)
Browse files Browse the repository at this point in the history
The CLI is able to invoke all currently defined methods of `ConcordiumNodeClient`.

The unit tests (which didn't actually perform any assertions) have been replaced with a script `test.sh` inside the CLI folder which executes all the same calls as these tests.

This removes the need for an accessible node when running unit tests, meaning that we can start running `swift test` as part of the CI workflow.
  • Loading branch information
bisgardo authored Jan 26, 2024
1 parent 9dca818 commit e9acd00
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 150 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build+test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ jobs:
run: swift package plugin --allow-writing-to-package-directory swiftformat --lint
- name: Build project
run: swift build
#- name: Run tests
# run: swift test
- name: Run tests
run: swift test
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.DS_Store
.build
/Packages
/.build/
/Packages/
/examples/*/.build/
/examples/*/Packages/
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
Expand Down
77 changes: 0 additions & 77 deletions Tests/ConcordiumSwiftSdkTests/GrpcNodeClientTests.swift

This file was deleted.

25 changes: 0 additions & 25 deletions examples/GetCryptographicParameters/README.md

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"location" : "https://github.com/Concordium/concordium-swift-sdk.git",
"state" : {
"branch" : "main",
"revision" : "89c89678e905fa5bca721a83213201d5b04b3b92"
"revision" : "0a5af878e0b3bf7d7e8c28715788ad34bb38961b"
}
},
{
Expand All @@ -45,6 +45,15 @@
"version" : "1.21.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
Expand All @@ -68,62 +77,62 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "1827dc94bdab2eb5f2fc804e9b0cb43574282566",
"version" : "1.0.2"
"revision" : "12358d55a3824bd5fed310b999ea8cf83a9a1a65",
"version" : "1.0.3"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c",
"version" : "2.62.0"
"revision" : "635b2589494c97e48c62514bc8b37ced762e0a62",
"version" : "2.63.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "798c962495593a23fdea0c0c63fd55571d8dff51",
"version" : "1.20.0"
"revision" : "363da63c1966405764f380c627409b2f9d9e710b",
"version" : "1.21.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "3bd9004b9d685ed6b629760fc84903e48efec806",
"version" : "1.29.0"
"revision" : "0904bf0feb5122b7e5c3f15db7df0eabe623dd87",
"version" : "1.30.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version" : "2.25.0"
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "ebf8b9c365a6ce043bf6e6326a04b15589bd285e",
"version" : "1.20.0"
"revision" : "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce",
"version" : "1.20.1"
}
},
{
Expand All @@ -135,6 +144,15 @@
"version" : "1.25.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
"version" : "1.2.1"
}
},
{
"identity" : "swiftformat",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import PackageDescription

let package = Package(
name: "GetCryptographicParameters",
name: "GrpcCli",
platforms: [
.macOS(.v10_15),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
.package(url: "https://github.com/Concordium/concordium-swift-sdk.git", branch: "main"),
],
targets: [
.executableTarget(
name: "GetCryptographicParameters",
name: "GrpcCli",
dependencies: [
.product(name: "ConcordiumSwiftSDK", package: "concordium-swift-sdk"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "ConcordiumSwiftSdk", package: "concordium-swift-sdk"),
]
),
]
Expand Down
29 changes: 29 additions & 0 deletions examples/GrpcCli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# GrpcCli

A small tool for demonstrating how to integrate the SDK as well as exercising the gRPC client
which is otherwise hard to cover with unit tests.

The CLI is organized into subcommands such as

```shell
GrpcCli cryptographic-parameters
```

for retrieving the cryptographic parameters of the chain and

```shell
GrpcCli account <account-address> info --block-hash=<block-hash>
```

for retrieving information about the account `<account-address>` as of block `<block-hash>`.

By default, the tool attempts to query the gRPC interface of a node running on `localhost:20000`.
Use the options `--host` and `--ip` (or a relay tool such as `socat`) to point it somewhere else.

Use `GrpcCli --help` to explore the full command interface.

The script [`./test.sh`](./test.sh) invokes all available commands.
This will reveal if any of the commands exit with failure.
Note, however, that it only "checks" if the commands exit successfully;
it does not make assertions about the outputs.
Use the environment variables `HOST` and `IP` to specify the gRPC endpoint to use in the script.
Loading

0 comments on commit e9acd00

Please sign in to comment.