File tree Expand file tree Collapse file tree 5 files changed +62
-5
lines changed
src/client/node-to-client/state-query Expand file tree Collapse file tree 5 files changed +62
-5
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -uo pipefail
3+
4+ # Check consistency of .cbor files against .cddl in the repository.
5+
6+ # TODO: check whether 'cddl' is installed
7+
8+ # Check that given cbor is valid against all given cddls files concatenated
9+ function check_cbor() {
10+ local cbor_file=$1
11+ shift
12+ local cddl_files=(" $@ " )
13+ local cddl=$( cat " ${cddl_files[@]} " )
14+ # NOTE: cddl spams stdout on invalid cbor, so we drop everything after '-- cannot complete'
15+ out=$( cddl <( echo " ${cddl} " ) validate <( xxd -r -p " ${cbor_file} " ) 2> /dev/null | \
16+ awk -v RS=' --' ' NR==1{print} NR==2{exit}' )
17+ if [ $? -ne 0 ]; then
18+ echo " Invalid cbor file: ${cbor_file} "
19+ echo " Error: ${out% --* } "
20+ printf " CDDL: \n${cddl} "
21+ exit 1
22+ fi
23+ }
24+
25+ cd src/api
26+ check_cbor examples/getSystemStart/query.cbor cddl/local-state-query.cddl cddl/getSystemStart.cddl
27+ check_cbor examples/getSystemStart/result.cbor cddl/local-state-query.cddl cddl/getSystemStart.cddl
Original file line number Diff line number Diff line change 1+ name : Check cbor examples
2+
3+ on :
4+ pull_request :
5+ push :
6+ branches :
7+ - main
8+ schedule :
9+ # Everyday at 4:00 AM
10+ - cron : " 0 4 * * *"
11+
12+ jobs :
13+ check-cbor-examples :
14+ name : Check cbor examples
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Install nix
20+ uses : cachix/install-nix-action@V27
21+ with :
22+ extra_nix_config : |
23+ accept-flake-config = true
24+ log-lines = 1000
25+
26+ - name : Enter nix shell
27+ uses : nicknovitski/nix-develop@v1
28+
29+ - run : ./.github/workflows/check-examples.sh
Original file line number Diff line number Diff line change 2525 mdbook-katex
2626 mdbook-alerts
2727 mdbook-toc
28+
29+ # to validate cbor / cddl
30+ cddl
31+ xxd
2832 ] ;
2933 phases = [ "unpackPhase" "buildPhase" ] ;
3034 buildPhase = ''
3135 mdbook build -d $out
3236 '' ;
3337 }
3438 ) ;
35- defaultPackage = packages . mdbook ;
39+ packages . default = packages . mdbook ;
3640 }
3741 ) ;
3842}
Original file line number Diff line number Diff line change 1- $query /= 1
1+ $query /= [1]
22$result /= [year, dayOfYear, timeOfDayPico]
33
44year = bigint
Original file line number Diff line number Diff line change @@ -18,9 +18,6 @@ acquireFailurePointNotOnChain = 1
1818failure = acquireFailurePointTooOld
1919 / acquireFailurePointNotOnChain
2020
21- $query = any
22- $result = any
23-
2421msgAcquire = [0, point]
2522 / [8]
2623 / [10]
You can’t perform that action at this time.
0 commit comments