Skip to content

Commit 0f05549

Browse files
committed
feat: add README, LICENSE*, and Makefile
1 parent 9cd60ca commit 0f05549

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

LICENSE-APACHE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2020 Protocol Labs
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

LICENSE-MIT

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2020 Protocol Labs
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all: testjs testgo
2+
3+
js/node_modules:
4+
cd js && npm install
5+
6+
testjs: js/node_modules
7+
cd js && npm test
8+
9+
testgo:
10+
cd go && go test

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# IPLD Codec Fixtures
2+
3+
This repository contains fixtures for standard IPLD codecs. It is used to verify the correctness, compatibility and limitations of IPLD implementations.
4+
5+
## What?
6+
7+
The [fixtures](./fixtures/) directory contains a suite of test data, where each subdirectory comprises an encoded IPLD block in the formats that are supported for that data. A file containing the binary encoded form of that block has the name `<CID>.<codec-name>`, where the `CID` is the CIDv1 using a SHA2-256 multihash of the block for that codec. The `codec-name` is the standard codec name as found in the [multicodec table](https://github.com/multiformats/multicodec/blob/master/table.csv).
8+
9+
Implementations are expected to be able to:
10+
11+
1. Read and decode the IPLD block from these files
12+
2. Re-encode the IPLD block using the supported codecs
13+
3. Compare the CID of the re-encoded block to the expected CID as per the filename for the given codec
14+
15+
Since the block is encoded in different forms, by re-encoding each decoded form into the different codecs, we are able to test the correctness of the decoding as well as the encoding process. Where the CIDs do not match, there has been a problem either in decoding or encoding the data. If the same error occurs for the data loaded from differently encoded blocks, the error is likely to be with the encoding process. If the error only occurs when re-encoding from a single encoded form of the block then the error may be with the decoding process.
16+
17+
## Adding fixtures
18+
19+
The [_fixtures_src](./_fixtures_src/) directory contains the source of each of fixtures contained in the [fixtures](./fixtures/) directory. Each file in [_fixtures_src](./_fixtures_src/) contains an encoded form of a block using one of the supported codecs. The name of the file is `<fixture-name>.<codec-name>`. The [js/make-fixtures.js](./js/make-fixtures.js) program (run with `node js/make-fixtures.js`) is used to generate the fixtures in [fixtures](./fixtures/) for each of the source files.
20+
21+
Fixture generation uses the JavaScript stack for generating data, but this is not a requirement. If you would like to add fixtures and would like to create them manually, or add an alternative mechanism for generating fixtures from source then please do so.
22+
23+
## Implementations & Codecs
24+
25+
### Go
26+
27+
Fixtures are tested against the [go-ipld-prime](https://github.com/ipld/go-ipld-prime) stack:
28+
29+
* DAG-JSON: [go-ipld-prime/codec/dagjson](https://pkg.go.dev/github.com/ipld/go-ipld-prime/codec/dagjson)
30+
* DAG-CBOR: [go-ipld-prime/codec/dagcbor](https://pkg.go.dev/github.com/ipld/go-ipld-prime/codec/dagcbor)
31+
32+
### JavaScript
33+
34+
Fixtures are tested against the [js-multiformats](https://github.com/multiformats/js-multiformats) stack:
35+
36+
* DAG-CBOR: [@ipld/dag-cbor](https://github.com/ipld/js-dag-cbor)
37+
* DAG-JSON: [@ipld/dag-json](https://github.com/ipld/js-dag-cbor)
38+
39+
## Running tests
40+
41+
### JavaScript
42+
43+
```
44+
make testjs
45+
```
46+
47+
Or, in the [js](./js/) directory, run:
48+
49+
```
50+
npm install
51+
npm test
52+
```
53+
54+
## Go
55+
56+
```
57+
make testgo
58+
```
59+
60+
Or, in the [go](./go/) directory, run:
61+
62+
```
63+
go test
64+
```
65+
66+
## License
67+
68+
Licensed under either of
69+
70+
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
71+
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
72+
73+
### Contribution
74+
75+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)