Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hildjj/dcbor-test-vectors
https://github.com/hildjj/dcbor-test-vectors
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hildjj/dcbor-test-vectors
- Owner: hildjj
- Created: 2024-08-14T15:56:57.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-22T20:02:12.000Z (3 months ago)
- Last Synced: 2024-10-10T21:44:20.947Z (about 1 month ago)
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dCBOR Test Vectors
These vectors are intended to test
[draft-mcnally-deterministic-cbor](https://www.ietf.org/archive/id/draft-mcnally-deterministic-cbor-11.txt).## Valid
Valid tests are in the following form:
```ts
interface Valid {
cbor: string, // Base64-encoded
hex: string, // Hex-encoded, same binary data as the cbor field
decoded?: unknown, // For tests that can be expressed as JSON.
diagnostic: string, // CBOR diagnostic notation
roundtrip?: boolean, // If true, encode(decode(hex)) = hex
skipDecode?: boolean, // If true, don't decode the hex to get decoded.
notes?: string, // Why this test is interesting, if provided
}export type ValidDcborTests = Valid[];
```To fully check each of these vectors, perform the following operations:
- Ensure that `Base64Decode(cbor) = HexDecode(cbor)` (optional)
- dCBOR decode either `cbor` or `hex`.
- If `decoded` is provided, and `skipDecode` is not true, ensure the result
matches `decoded`.
- If `roundtrip` is true, ensure that dCBOR encoding the result matches the
original binary data
- Decode either `cbor` or `hex` to diagnostic format in dCBOR mode.
- Ensure the result matches `diagnostic`
- No errors should fire for any of these inputs.## Invalid
Invalid tests are in the form:
```ts
interface Invalid {
diagnostic: string, // CBOR diagnostic notation, for reference only
hex: string, // Hex-encoded binary dCBOR input
notes?: string, // Why this test is interesting, if provided
roundtrip?: boolean, // Try encoding also if true
}export type InvalidDcborTests = Invalid[];
```To check each of these vectors:
- Decode `hex` using dCBOR rules.
- Ensure that an error was reported
- If `roundtrip` is true
- Decode `hex` using permissive (NOT dCBOR!) rules
- Encode the result using dCBOR rules
- Ensure that an error was reported## Provenance
The original source for the first checkin of these vectors was
[draft-mcnally-deterministic-cbor-11](https://www.ietf.org/archive/id/draft-mcnally-deterministic-cbor-11.txt).