From 1ffd3086fd084eeed0623034c9f0780bbdf30014 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 15:00:05 +0200 Subject: [PATCH 01/23] fix: remove t0440 - kubo specific --- tests/t0400_api_no_gateway_test.go | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 tests/t0400_api_no_gateway_test.go diff --git a/tests/t0400_api_no_gateway_test.go b/tests/t0400_api_no_gateway_test.go deleted file mode 100644 index f4c9cb2a5..000000000 --- a/tests/t0400_api_no_gateway_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package tests - -import ( - "testing" - - "github.com/ipfs/gateway-conformance/tooling/test" -) - -func TestApiNoGateway(t *testing.T) { - tests := []test.CTest{} - - test.Run(t, tests) -} From 6c0e6e04bd95f4c890484ec0f21d1855f783fc73 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 15:55:54 +0200 Subject: [PATCH 02/23] fix: style --- tests/t0117_gateway_block_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/t0117_gateway_block_test.go b/tests/t0117_gateway_block_test.go index e8908c628..41abbcefc 100644 --- a/tests/t0117_gateway_block_test.go +++ b/tests/t0117_gateway_block_test.go @@ -11,6 +11,7 @@ import ( func TestGatewayBlock(t *testing.T) { fixture := car.MustOpenUnixfsCar("t0117-gateway-block.car") + tests := SugarTests{ { Name: "GET with format=raw param returns a raw block", From 90c3427bdf1ff8373a84d03c2a356f8eca373eb2 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 15:56:35 +0200 Subject: [PATCH 03/23] feat: add NOT and sprintf in header --- tooling/check/check.go | 27 +++++++++++++++++++++++++++ tooling/test/sugar.go | 32 ++++++++++++++++++++++++-------- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/tooling/check/check.go b/tooling/check/check.go index 420ae9cd3..b0a798352 100644 --- a/tooling/check/check.go +++ b/tooling/check/check.go @@ -196,3 +196,30 @@ func (c CheckFunc[T]) Check(v T) CheckOutput { } var _ Check[string] = &CheckFunc[string]{} + +type CheckNot struct { + check Check[string] +} + +func Not(check Check[string]) Check[string] { + return CheckNot{ + check: check, + } +} + +func (c CheckNot) Check(v string) CheckOutput { + result := c.check.Check(v) + + if result.Success { + return CheckOutput{ + Success: false, + Reason: fmt.Sprintf("expected %v to fail, but it succeeded", c.check), + } + } + + return CheckOutput{ + Success: true, + } +} + +var _ Check[string] = CheckNot{} diff --git a/tooling/test/sugar.go b/tooling/test/sugar.go index a3f78ff11..b35f03a5a 100644 --- a/tooling/test/sugar.go +++ b/tooling/test/sugar.go @@ -176,10 +176,16 @@ func (e ExpectBuilder) Response() CResponse { // TODO: detect collision in keys for _, h := range e.Headers_ { + c := h.Check + + if h.Not_ { + c = check.Not(h.Check) + } + if h.Hint_ != "" { - headers[h.Key] = check.WithHint(h.Hint_, h.Check) + headers[h.Key] = check.WithHint(h.Hint_, c) } else { - headers[h.Key] = h.Check + headers[h.Key] = c } } @@ -195,14 +201,19 @@ type HeaderBuilder struct { Value string Check check.Check[string] Hint_ string + Not_ bool } -func Header(key string, opts ...string) HeaderBuilder { - if len(opts) > 1 { - panic("too many options") - } - if len(opts) > 0 { - return HeaderBuilder{Key: key, Value: opts[0], Check: check.IsEqual(opts[0])} +func Header(key string, rest ...any) HeaderBuilder { + if len(rest) > 0 { + // check if rest[0] is a string + if value, ok := rest[0].(string); ok { + value := fmt.Sprintf(value, rest[1:]...) + return HeaderBuilder{Key: key, Value: value, Check: check.IsEqual(value)} + + } else { + panic("rest[0] must be a string") + } } return HeaderBuilder{Key: key} @@ -239,3 +250,8 @@ func (h HeaderBuilder) Checks(f func(string) bool) HeaderBuilder { } return h } + +func (h HeaderBuilder) Not() HeaderBuilder { + h.Not_ = !h.Not_ + return h +} From 42248a48b1ea32d8585141bbae7da5595eda176a Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 15:56:52 +0200 Subject: [PATCH 04/23] feat: t0123 - dag pb conversion tests --- tests/t0123_gateway_json_cbor_test.go | 246 +++++++++++++++++++++++++- 1 file changed, 244 insertions(+), 2 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 01fff9e51..22140bf06 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -1,13 +1,255 @@ package tests import ( + "fmt" "testing" + "github.com/ipfs/gateway-conformance/tooling/car" "github.com/ipfs/gateway-conformance/tooling/test" + . "github.com/ipfs/gateway-conformance/tooling/test" ) func TestGatewayJsonCbor(t *testing.T) { - tests := []test.CTest{} + fixture := car.MustOpenUnixfsCar("t0123-gateway-json-cbor.car") + + dirCID := fixture.MustGetCid() // root dir + fileJSONCID := fixture.MustGetCid("ą", "ę", "t.json") + fileJSONData := fixture.MustGetRawData("ą", "ę", "t.json") + fileCID := fixture.MustGetCid("ą", "ę", "file-źł.txt") + fileSize := len(fixture.MustGetRawData("ą", "ę", "file-źł.txt")) + + fmt.Println("rootDirCID:", dirCID) + fmt.Println("fileJSONCID:", fileJSONCID) + fmt.Println("fileJSONData:", fileJSONData) + fmt.Println("fileCID:", fileCID) + fmt.Println("fileSize:", fileSize) + + tests := SugarTests{ + { + Name: "GET UnixFS file with JSON bytes is returned with application/json Content-Type (1)", + Hint: ` + ## Quick regression check for JSON stored on UnixFS: + ## it has nothing to do with DAG-JSON and JSON codecs, + ## but a lot of JSON data is stored on UnixFS and is requested with or without various hints + ## and we want to avoid surprises like https://github.com/protocol/bifrost-infra/issues/2290 + `, + Request: Request(). + Path("ipfs/%s", fileJSONCID). + Headers( + Header("Accept", "application/json"), + ), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("application/json"), + ). + Body(fileJSONData), + }, + { + Name: "GET UnixFS file with JSON bytes is returned with application/json Content-Type (2)", + Hint: ` + ## Quick regression check for JSON stored on UnixFS: + ## it has nothing to do with DAG-JSON and JSON codecs, + ## but a lot of JSON data is stored on UnixFS and is requested with or without various hints + ## and we want to avoid surprises like https://github.com/protocol/bifrost-infra/issues/2290 + `, + Request: Request(). + Path("ipfs/%s", fileJSONCID). + Headers( + Header("Accept", "application/json"), + ), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("application/json"), + ). + Body(fileJSONData), + }, + } + + test.Run(t, tests.Build()) +} + +// ## Reading UnixFS (data encoded with dag-pb codec) as DAG-CBOR and DAG-JSON +// ## (returns representation defined in https://ipld.io/specs/codecs/dag-pb/spec/#logical-format) +func TestDAgPbConversion(t *testing.T) { + fixture := car.MustOpenUnixfsCar("t0123-gateway-json-cbor.car") + + dirCID := fixture.MustGetCid() // root dir + fileCID := fixture.MustGetCid("ą", "ę", "file-źł.txt") + fileData := fixture.MustGetRawData("ą", "ę", "file-źł.txt") + + table := []struct { + Name string + Format string + Disposition string + }{ + {"DAG-JSON", "json", "inline"}, + {"DAG-CBOR", "cbor", "attachment"}, + } + + for _, row := range table { + tests := SugarTests{ + /** + test_expect_success "GET UnixFS file as $name with format=dag-$format converts to the expected Content-Type" ' + curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=dag-$format" > curl_output 2>&1 && + ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output 2>&1 && + test_cmp ipfs_dag_get_output curl_output && + test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${FILE_CID}.${format}\"" headers && + test_should_not_contain "Content-Type: application/$format" headers + ' + */ + { + Name: fmt.Sprintf("GET UnixFS file as %s with format=dag-%s converts to the expected Content-Type", row.Name, row.Format), + Request: Request(). + Path("ipfs/%s?format=dag-%s", fileCID, row.Format), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("application/vnd.ipld.dag-%s", row.Format), + Header("Content-Disposition"). + Contains("%s; filename=\"%s.%s\"", row.Disposition, fileCID, row.Format), + Header("Content-Type"). + Not().Contains("application/%s", row.Format), + ), + // TODO: test body `ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output` + }, + /** + test_expect_success "GET UnixFS directory as $name with format=dag-$format converts to the expected Content-Type" ' + curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=dag-$format" > curl_output 2>&1 && + ipfs dag get --output-codec dag-$format $DIR_CID > ipfs_dag_get_output 2>&1 && + test_cmp ipfs_dag_get_output curl_output && + test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${DIR_CID}.${format}\"" headers && + test_should_not_contain "Content-Type: application/$format" headers + ' + */ + { + Name: fmt.Sprintf("GET UnixFS directory as %s with format=dag-%s converts to the expected Content-Type", row.Name, row.Format), + Request: Request(). + Path("ipfs/%s?format=dag-%s", dirCID, row.Format), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("application/vnd.ipld.dag-%s", row.Format), + Header("Content-Disposition"). + Contains("%s; filename=\"%s.%s\"", row.Disposition, dirCID, row.Format), + Header("Content-Type"). + Not().Contains("application/%s", row.Format), + ), + // TODO: test body `ipfs dag get --output-codec dag-$format $DIR_CID > ipfs_dag_get_output` + }, + /** + test_expect_success "GET UnixFS as $name with 'Accept: application/vnd.ipld.dag-$format' converts to the expected Content-Type" ' + curl -sD - -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${FILE_CID}.${format}\"" curl_output && + test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output && + test_should_not_contain "Content-Type: application/$format" curl_output + ' + */ + { + Name: fmt.Sprintf("GET UnixFS as %s with 'Accept: application/vnd.ipld.dag-%s' converts to the expected Content-Type", row.Name, row.Format), + Request: Request(). + Path("ipfs/%s", fileCID). + Headers( + Header("Accept", "application/vnd.ipld.dag-%s", row.Format), + ), + Response: Expect(). + Status(200). + Headers( + Header("Content-Disposition"). + Contains("%s; filename=\"%s.%s\"", row.Disposition, fileCID, row.Format), + Header("Content-Type"). + Equals("application/vnd.ipld.dag-%s", row.Format), + Header("Content-Type"). + Not().Contains("application/%s", row.Format), + ), + }, + /** + test_expect_success "GET UnixFS as $name with 'Accept: foo, application/vnd.ipld.dag-$format,bar' converts to the expected Content-Type" ' + curl -sD - -H "Accept: foo, application/vnd.ipld.dag-$format,text/plain" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 && + test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output + ' + */ + { + Name: fmt.Sprintf("GET UnixFS as %s with 'Accept: foo, application/vnd.ipld.dag-%s,bar' converts to the expected Content-Type", row.Name, row.Format), + Request: Request(). + Path("ipfs/%s", fileCID). + Headers( + Header("Accept", "foo, application/vnd.ipld.dag-%s,bar", row.Format), + ), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("application/vnd.ipld.dag-%s", row.Format), + ), + }, + /** + test_expect_success "GET UnixFS with format=$format (not dag-$format) is no-op (no conversion)" ' + curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=$format" > curl_output 2>&1 && + ipfs cat $FILE_CID > cat_output && + test_cmp cat_output curl_output && + test_should_contain "Content-Type: text/plain" headers && + test_should_not_contain "Content-Type: application/$format" headers && + test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" headers + ' + */ + { + Name: fmt.Sprintf("GET UnixFS with format=%s (not dag-%s) is no-op (no conversion)", row.Format, row.Format), + Request: Request(). + Path("ipfs/%s?format=%s", fileCID, row.Format), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("text/plain"), + Header("Content-Type"). + Not().Contains("application/%s", row.Format), + Header("Content-Type"). + Not().Contains("application/vnd.ipld.dag-%s", row.Format), + ).Body( + fileData, + ), + }, + /** + test_expect_success "GET UnixFS with 'Accept: application/$format' (not dag-$format) is no-op (no conversion)" ' + curl -sD headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 && + ipfs cat $FILE_CID > cat_output && + test_cmp cat_output curl_output && + test_should_contain "Content-Type: text/plain" headers && + test_should_not_contain "Content-Type: application/$format" headers && + test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" headers + ' + */ + { + Name: fmt.Sprintf("GET UnixFS with 'Accept: application/%s' (not dag-%s) is no-op (no conversion)", row.Format, row.Format), + Request: Request(). + Path("ipfs/%s", fileCID). + Headers( + Header("Accept", "application/%s", row.Format), + ), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type"). + Equals("text/plain"), + Header("Content-Type"). + Not().Contains("application/%s", row.Format), + Header("Content-Type"). + Not().Contains("application/vnd.ipld.dag-%s", row.Format), + ).Body( + fileData, + ), + }, + } + + test.Run(t, tests.Build()) + } - test.Run(t, tests) } From 942a53a700569741690d983d8406b0bc96f497d8 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 16:46:12 +0200 Subject: [PATCH 05/23] feat: test plain code (broken) --- fixtures/t0123/plain-that-can-be-dag.cbor.car | Bin 0 -> 140 bytes fixtures/t0123/plain-that-can-be-dag.json.car | Bin 0 -> 150 bytes fixtures/t0123/plain.cbor.car | Bin 0 -> 113 bytes fixtures/t0123/plain.json.car | Bin 0 -> 124 bytes tests/t0123_gateway_json_cbor_test.go | 149 ++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 fixtures/t0123/plain-that-can-be-dag.cbor.car create mode 100644 fixtures/t0123/plain-that-can-be-dag.json.car create mode 100644 fixtures/t0123/plain.cbor.car create mode 100644 fixtures/t0123/plain.json.car diff --git a/fixtures/t0123/plain-that-can-be-dag.cbor.car b/fixtures/t0123/plain-that-can-be-dag.cbor.car new file mode 100644 index 0000000000000000000000000000000000000000..1091dd95ed967afcfd2ddd2999c3c3eb4a293a51 GIT binary patch literal 140 zcmcColvA$zIbN$x49A1rj<^S3c-M}1G?s{b5&wQRCPZYnIe z&NMZ>EVZaOGe3_pfEd*aQ%X{cODa?fauPH1bhC={^K?rx5=(TG6Z3QvbBgnIlTvk4 I64Svl0K@b{ zmBq^GWvNBQnfZB)kwhu4=HgT;Ni8l>vQkhg$Vtr1)6FW*&(kf*NG#D!PR!Fy%qh;- RO-j{GNlXXJC~?(t0RZ#jH@5%) literal 0 HcmV?d00001 diff --git a/fixtures/t0123/plain.cbor.car b/fixtures/t0123/plain.cbor.car new file mode 100644 index 0000000000000000000000000000000000000000..e92c6ded06e266402fc5b154dead3563775e46c6 GIT binary patch literal 113 zcmcColvVK2iooFH0>d&dkqav?oe=H5aE+NosM4l9hr|K~7?3o curl_output 2>&1 && + ipfs block get $CID > ipfs_block_output 2>&1 && + test_cmp ipfs_block_output curl_output && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && + test_should_contain "Content-Type: application/$format" headers + ' + */ + { + Name: fmt.Sprintf("GET %s without Accept or format= has expected %s Content-Type and body as-is", row.Name, row.Format), + Hint: ` + No explicit format, just codec in CID + `, + Request: Request(). + Path("ipfs/%s", plainCID), + Response: Expect(). + Status(200). + Headers( + Header("Content-Disposition"). + Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), + Header("Content-Type"). + Equals(fmt.Sprintf("application/%s", row.Format)), + ).Body( + plainFixture.MustGetRawData(), + ), + }, + /** + # explicit format still gives correct output, just codec in CID + test_expect_success "GET $name with ?format= has expected $format Content-Type and body as-is" ' + CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) && + curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" > curl_output 2>&1 && + ipfs block get $CID > ipfs_block_output 2>&1 && + test_cmp ipfs_block_output curl_output && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && + test_should_contain "Content-Type: application/$format" headers + ' + */ + { + Name: fmt.Sprintf("GET %s with ?format= has expected %s Content-Type and body as-is", row.Name, row.Format), + Hint: ` + Explicit format still gives correct output, just codec in CID + `, + Request: Request(). + Path("ipfs/%s", plainCID). + Query("format", row.Format), + Response: Expect(). + Status(200). + Headers( + Header("Content-Disposition"). + Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), + Header("Content-Type"). + Equals(fmt.Sprintf("application/%s", row.Format)), + ).Body( + plainFixture.MustGetRawData(), + ), + }, + /** + # explicit format still gives correct output, just codec in CID + test_expect_success "GET $name with Accept has expected $format Content-Type and body as-is" ' + CID=$(echo "{ \"test\": \"plain json\" }" | ipfs dag put --input-codec json --store-codec $format) && + curl -sD headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 && + ipfs block get $CID > ipfs_block_output 2>&1 && + test_cmp ipfs_block_output curl_output && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && + test_should_contain "Content-Type: application/$format" headers + ' + */ + { + Name: fmt.Sprintf("GET %s with Accept has expected %s Content-Type and body as-is", row.Name, row.Format), + Hint: ` + Explicit format still gives correct output, just codec in CID + `, + Request: Request(). + Path("ipfs/%s", plainCID). + Header("Accept", fmt.Sprintf("application/%s", row.Format)), + Response: Expect(). + Status(200). + Headers( + Header("Content-Disposition"). + Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), + Header("Content-Type"). + Equals(fmt.Sprintf("application/%s", row.Format)), + ).Body( + plainFixture.MustGetRawData(), + ), + }, + /** + # explicit dag-* format passed, attempt to parse as dag* variant + ## Note: this works only for simple JSON that can be upgraded to DAG-JSON. + test_expect_success "GET $name with format=dag-$format interprets $format as dag-* variant and produces expected Content-Type and body" ' + CID=$(echo "{ \"test\": \"plain-json-that-can-also-be-dag-json\" }" | ipfs dag put --input-codec json --store-codec $format) && + curl -sD headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" > curl_output_param 2>&1 && + ipfs dag get --output-codec dag-$format $CID > ipfs_dag_get_output 2>&1 && + test_cmp ipfs_dag_get_output curl_output_param && + test_should_contain "Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" headers && + test_should_contain "Content-Type: application/vnd.ipld.dag-$format" headers && + curl -s -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output_accept 2>&1 && + test_cmp curl_output_param curl_output_accept + ' + */ + { + Name: fmt.Sprintf("GET %s with format=dag-%s interprets %s as dag-* variant and produces expected Content-Type and body", row.Name, row.Format, row.Format), + Hint: ` + Explicit dag-* format passed, attempt to parse as dag* variant + Note: this works only for simple JSON that can be upgraded to DAG-JSON. + `, + Request: Request(). + Path("ipfs/%s", plainOrDagCID). + Query("format", fmt.Sprintf("dag-%s", row.Format)), + Response: Expect(). + Status(200). + Headers( + Header("Content-Disposition"). + Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainOrDagCID, row.Format)), + Header("Content-Type"). + Equals(fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + ).Body( + plainFixture.MustGetRawData(), + ), + }, + } + + test.Run(t, tests.Build()) + } +} From 10783f6731546acc71bb59599947757e2a3c289c Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Mar 2023 17:55:25 +0200 Subject: [PATCH 06/23] wip: load json --- tooling/car/unixfs.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 7a3496a4c..79d1e2333 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -14,6 +14,9 @@ import ( "github.com/ipfs/go-merkledag" "github.com/ipfs/go-unixfs/io" "github.com/ipld/go-car/v2/blockstore" + "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/codec/json" + "github.com/multiformats/go-multicodec" ) type UnixfsDag struct { @@ -23,6 +26,16 @@ type UnixfsDag struct { links map[string]*UnixfsDag } +func init() { + format.Register(uint64(multicodec.Json), json.Decode) + format.Register(uint64(multicodec.DagJson), dagjson.Decode) + + // TODO: register the json codec (0x200) so that merkleDAG nodes can be decoded + // legacy.RegisterCodec(uint64(multicodec.Json), basicnode.Prototype.Any, ) + // legacy.RegisterCodec(uint64(multicodec.DagJson), basicnode.Prototype.Any, ) +} + + func newUnixfsDagFromCar(file string) (*UnixfsDag, error) { bs, err := blockstore.OpenReadOnly(file) if err != nil { From da7c7d1017d72d3e5ae468837561a56c32e4798d Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 28 Mar 2023 17:05:20 +0200 Subject: [PATCH 07/23] chore: move to boxo --- go.mod | 61 ++++--------- go.sum | 199 ++++++++++-------------------------------- tooling/car/unixfs.go | 22 ++--- 3 files changed, 68 insertions(+), 214 deletions(-) diff --git a/go.mod b/go.mod index 4f07f9b9c..d94b2411b 100644 --- a/go.mod +++ b/go.mod @@ -3,46 +3,21 @@ module github.com/ipfs/gateway-conformance go 1.19 require ( - github.com/ipfs/go-cid v0.3.2 - github.com/ipld/go-car/v2 v2.7.0 + github.com/ipfs/boxo v0.8.0-rc1 + github.com/ipfs/go-cid v0.4.0 + github.com/ipld/go-car/v2 v2.9.1-0.20230325062757-fff0e4397a3d + github.com/urfave/cli/v2 v2.25.0 ) require ( - github.com/ajg/form v1.5.1 // indirect github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect - github.com/andybalholm/brotli v1.0.4 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/structs v1.1.0 // indirect - github.com/gavv/httpexpect/v2 v2.13.0 // indirect - github.com/gobwas/glob v0.2.3 // indirect - github.com/google/go-querystring v1.1.0 // indirect - github.com/gorilla/websocket v1.4.2 // indirect - github.com/imkira/go-interpol v1.1.0 // indirect - github.com/ipfs/go-unixfsnode v1.5.2 // indirect + github.com/ipfs/go-ipfs-files v0.3.0 // indirect github.com/ipld/go-codec-dagpb v1.6.0 // indirect github.com/ipld/go-ipld-prime v0.20.0 // indirect - github.com/klauspost/compress v1.15.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/sanity-io/litter v1.5.5 // indirect - github.com/sergi/go-diff v1.0.0 // indirect - github.com/stretchr/testify v1.8.1 // indirect - github.com/urfave/cli/v2 v2.25.0 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.34.0 // indirect - github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect - github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect - github.com/yudai/gojsondiff v1.0.0 // indirect - github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect - golang.org/x/net v0.5.0 // indirect golang.org/x/sync v0.1.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - moul.io/http2curl/v2 v2.3.0 // indirect ) require ( @@ -53,50 +28,48 @@ require ( github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/ipfs/bbloom v0.0.4 // indirect github.com/ipfs/go-bitfield v1.1.0 // indirect - github.com/ipfs/go-block-format v0.1.1 // indirect + github.com/ipfs/go-block-format v0.1.2 // indirect github.com/ipfs/go-blockservice v0.5.0 github.com/ipfs/go-datastore v0.6.0 // indirect - github.com/ipfs/go-ipfs-blockstore v1.2.0 // indirect + github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect github.com/ipfs/go-ipfs-util v0.0.2 // indirect github.com/ipfs/go-ipld-cbor v0.0.6 // indirect github.com/ipfs/go-ipld-format v0.4.0 github.com/ipfs/go-ipld-legacy v0.1.1 // indirect - github.com/ipfs/go-libipfs v0.4.0 // indirect - github.com/ipfs/go-log v1.0.5 // indirect + github.com/ipfs/go-libipfs v0.6.0 // indirect + github.com/ipfs/go-log v1.0.5 github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/ipfs/go-merkledag v0.9.0 + github.com/ipfs/go-merkledag v0.10.0 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect - github.com/ipfs/go-unixfs v0.4.3 + github.com/ipfs/go-unixfs v0.4.5 github.com/ipfs/go-verifcid v0.0.2 // indirect github.com/jbenet/goprocess v0.1.4 // indirect github.com/klauspost/cpuid/v2 v2.2.3 // indirect - github.com/libp2p/go-msgio v0.3.0 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect github.com/multiformats/go-multibase v0.1.1 // indirect - github.com/multiformats/go-multicodec v0.8.0 // indirect + github.com/multiformats/go-multicodec v0.8.1 // indirect github.com/multiformats/go-multihash v0.2.1 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa // indirect - go.opentelemetry.io/otel v1.12.0 // indirect - go.opentelemetry.io/otel/trace v1.12.0 // indirect + go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.5.0 // indirect - golang.org/x/exp v0.0.0-20230129154200-a960b3787bd2 // indirect - golang.org/x/sys v0.4.0 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect + golang.org/x/sys v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/protobuf v1.28.1 // indirect lukechampine.com/blake3 v1.1.7 // indirect diff --git a/go.sum b/go.sum index 2e0b83a31..407c60aa9 100644 --- a/go.sum +++ b/go.sum @@ -1,82 +1,59 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= -github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a h1:E/8AP5dFtMhl5KPJz66Kt9G0n+7Sn41Fy1wv9/jHOrc= github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= -github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg= github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0= -github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= -github.com/fasthttp/websocket v1.4.3-rc.6/go.mod h1:43W9OM2T8FeXpCWMsBd9Cb7nE2CACNqNvCqQCoty/Lc= -github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gavv/httpexpect/v2 v2.13.0 h1:d9bGxLIjUpi0m1RXwxmvY7WPwhBqHQqr1gnLhB+q1ls= -github.com/gavv/httpexpect/v2 v2.13.0/go.mod h1:Cw5O0RmjQOmUewnAPTnwhXHGmO2vXGjw07vFOq2jYRg= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= -github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= -github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= -github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= -github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= +github.com/ipfs/boxo v0.8.0-rc1 h1:DL5SDbBNSS9ZNsF+UhoQ39d05/wgoJ2k/T+y7JeWRaw= +github.com/ipfs/boxo v0.8.0-rc1/go.mod h1:EgDiNox/+W/+ySwEotRrHlvdmrhbSAB4p22ELg+ZsCc= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk= -github.com/ipfs/go-block-format v0.1.1 h1:129vSO3zwbsYADcyQWcOYiuCpAqt462SFfqFHdFJhhI= -github.com/ipfs/go-block-format v0.1.1/go.mod h1:+McEIT+g52p+zz5xGAABGSOKrzmrdX97bc0USBdWPUs= +github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo= +github.com/ipfs/go-block-format v0.1.2/go.mod h1:mACVcrxarQKstUU3Yf/RdwbC4DzPV6++rO2a3d+a/KE= github.com/ipfs/go-blockservice v0.5.0 h1:B2mwhhhVQl2ntW2EIpaWPwSCxSuqr5fFA93Ms4bYLEY= github.com/ipfs/go-blockservice v0.5.0/go.mod h1:W6brZ5k20AehbmERplmERn8o2Ni3ZZubvAxaIUeaT6w= github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= @@ -86,17 +63,17 @@ github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= -github.com/ipfs/go-cid v0.3.2 h1:OGgOd+JCFM+y1DjWPmVH+2/4POtpDzwcr7VgnB7mZXc= -github.com/ipfs/go-cid v0.3.2/go.mod h1:gQ8pKqT/sUxGY+tIwy1RPpAojYu7jAyCp5Tz1svoupw= +github.com/ipfs/go-cid v0.4.0 h1:a4pdZq0sx6ZSxbCizebnKiMCx/xI/aBBFlB73IgH4rA= +github.com/ipfs/go-cid v0.4.0/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk= github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= -github.com/ipfs/go-ipfs-blockstore v1.2.0 h1:n3WTeJ4LdICWs/0VSfjHrlqpPpl6MZ+ySd3j8qz0ykw= -github.com/ipfs/go-ipfs-blockstore v1.2.0/go.mod h1:eh8eTFLiINYNSNawfZOC7HOxNTxpB1PFuA5E1m/7exE= +github.com/ipfs/go-ipfs-blockstore v1.3.0 h1:m2EXaWgwTzAfsmt5UdJ7Is6l4gJcaM/A12XwJyvYvMM= +github.com/ipfs/go-ipfs-blockstore v1.3.0/go.mod h1:KgtZyc9fq+P2xJUiCAzbRdhhqJHvsw8u2Dlqy2MyRTE= github.com/ipfs/go-ipfs-blocksutil v0.0.1 h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IWFJMcGIPQ= -github.com/ipfs/go-ipfs-chunker v0.0.1 h1:cHUUxKFQ99pozdahi+uSC/3Y6HeRpi9oTeUHbE27SEw= +github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8= github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ= github.com/ipfs/go-ipfs-ds-help v1.1.0 h1:yLE2w9RAsl31LtfMt91tRZcrx+e61O5mDxFRR994w4Q= @@ -104,8 +81,10 @@ github.com/ipfs/go-ipfs-ds-help v1.1.0/go.mod h1:YR5+6EaebOhfcqVCyqemItCLthrpVNo github.com/ipfs/go-ipfs-exchange-interface v0.2.0 h1:8lMSJmKogZYNo2jjhUs0izT+dck05pqUw4mWNW9Pw6Y= github.com/ipfs/go-ipfs-exchange-interface v0.2.0/go.mod h1:z6+RhJuDQbqKguVyslSOuVDhqF9JtTrO3eptSAiW2/Y= github.com/ipfs/go-ipfs-exchange-offline v0.3.0 h1:c/Dg8GDPzixGd0MC8Jh6mjOwU57uYokgWRFidfvEkuA= +github.com/ipfs/go-ipfs-files v0.3.0 h1:fallckyc5PYjuMEitPNrjRfpwl7YFt69heCOUhsbGxQ= +github.com/ipfs/go-ipfs-files v0.3.0/go.mod h1:xAUtYMwB+iu/dtf6+muHNSFQCJG2dSiStR2P6sn9tIM= github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs= -github.com/ipfs/go-ipfs-pq v0.0.2 h1:e1vOOW6MuOwG2lqxcLA+wEn93i/9laCY8sXAw76jFOY= +github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE= github.com/ipfs/go-ipfs-routing v0.3.0 h1:9W/W3N+g+y4ZDeffSgqhgo7BsBSJwPMcyssET9OWevc= github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= @@ -114,32 +93,29 @@ github.com/ipfs/go-ipld-cbor v0.0.6 h1:pYuWHyvSpIsOOLw4Jy7NbBkCyzLDcl64Bf/LZW7eB github.com/ipfs/go-ipld-cbor v0.0.6/go.mod h1:ssdxxaLJPXH7OjF5V4NSjBbcfh+evoR4ukuru0oPXMA= github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms= github.com/ipfs/go-ipld-format v0.2.0/go.mod h1:3l3C1uKoadTPbeNfrDi+xMInYKlx2Cvg1BuydPSdzQs= -github.com/ipfs/go-ipld-format v0.3.0/go.mod h1:co/SdBE8h99968X0hViiw1MNlh6fvxxnHpvVLnH7jSM= github.com/ipfs/go-ipld-format v0.4.0 h1:yqJSaJftjmjc9jEOFYlpkwOLVKv68OD27jFLlSghBlQ= github.com/ipfs/go-ipld-format v0.4.0/go.mod h1:co/SdBE8h99968X0hViiw1MNlh6fvxxnHpvVLnH7jSM= github.com/ipfs/go-ipld-legacy v0.1.1 h1:BvD8PEuqwBHLTKqlGFTHSwrwFOMkVESEvwIYwR2cdcc= github.com/ipfs/go-ipld-legacy v0.1.1/go.mod h1:8AyKFCjgRPsQFf15ZQgDB8Din4DML/fOmKZkkFkrIEg= -github.com/ipfs/go-libipfs v0.4.0 h1:TkUxJGjtPnSzAgkw7VjS0/DBay3MPjmTBa4dGdUQCDE= -github.com/ipfs/go-libipfs v0.4.0/go.mod h1:XsU2cP9jBhDrXoJDe0WxikB8XcVmD3k2MEZvB3dbYu8= -github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= +github.com/ipfs/go-libipfs v0.6.0 h1:3FuckAJEm+zdHbHbf6lAyk0QUzc45LsFcGw102oBCZM= +github.com/ipfs/go-libipfs v0.6.0/go.mod h1:UjjDIuehp2GzlNP0HEr5I9GfFT7zWgst+YfpUEIThtw= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipfs/go-merkledag v0.9.0 h1:DFC8qZ96Dz1hMT7dtIpcY524eFFDiEWAF8hNJHWW2pk= -github.com/ipfs/go-merkledag v0.9.0/go.mod h1:bPHqkHt5OZ0p1n3iqPeDiw2jIBkjAytRjS3WSBwjq90= +github.com/ipfs/go-merkledag v0.10.0 h1:IUQhj/kzTZfam4e+LnaEpoiZ9vZF6ldimVlby+6OXL4= +github.com/ipfs/go-merkledag v0.10.0/go.mod h1:zkVav8KiYlmbzUzNM6kENzkdP5+qR7+2mCwxkQ6GIj8= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= -github.com/ipfs/go-peertaskqueue v0.8.0 h1:JyNO144tfu9bx6Hpo119zvbEL9iQ760FHOiJYsUjqaU= -github.com/ipfs/go-unixfs v0.4.3 h1:EdDc1sNZNFDUlo4UrVAvvAofVI5EwTnKu8Nv8mgXkWQ= -github.com/ipfs/go-unixfs v0.4.3/go.mod h1:TSG7G1UuT+l4pNj91raXAPkX0BhJi3jST1FDTfQ5QyM= -github.com/ipfs/go-unixfsnode v1.5.2 h1:CvsiTt58W2uR5dD8bqQv+aAY0c1qolmXmSyNbPHYiew= -github.com/ipfs/go-unixfsnode v1.5.2/go.mod h1:NlOebRwYx8lMCNMdhAhEspYPBD3obp7TE0LvBqHY+ks= +github.com/ipfs/go-peertaskqueue v0.8.1 h1:YhxAs1+wxb5jk7RvS0LHdyiILpNmRIRnZVztekOF0pg= +github.com/ipfs/go-unixfs v0.4.5 h1:wj8JhxvV1G6CD7swACwSKYa+NgtdWC1RUit+gFnymDU= +github.com/ipfs/go-unixfs v0.4.5/go.mod h1:BIznJNvt/gEx/ooRMI4Us9K8+qeGO7vx1ohnbk8gjFg= +github.com/ipfs/go-unixfsnode v1.6.0 h1:JOSA02yaLylRNi2rlB4ldPr5VcZhcnaIVj5zNLcOjDo= github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs= github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU= -github.com/ipld/go-car/v2 v2.7.0 h1:OFxJl6X6Ii7y7wYX4R+P8q9+vuz4vaY2Y9u1GHzfxbE= -github.com/ipld/go-car/v2 v2.7.0/go.mod h1:qoqfgPnQYcaAYcfphctffdaNWJIWBR2QN4pjuKUtgao= +github.com/ipld/go-car/v2 v2.9.1-0.20230325062757-fff0e4397a3d h1:22g+x1tgWSXK34i25qjs+afr7basaneEkHaglBshd2g= +github.com/ipld/go-car/v2 v2.9.1-0.20230325062757-fff0e4397a3d/go.mod h1:SH2pi/NgfGBsV/CGBAQPxMfghIgwzbh5lQ2N+6dNRI8= github.com/ipld/go-codec-dagpb v1.6.0 h1:9nYazfyu9B1p3NAgfVdpRco3Fs2nFC72DqVsMj6rOcc= github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYtmKZ+agnUw9s= github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8= @@ -153,13 +129,8 @@ github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZl github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U= -github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU= @@ -175,30 +146,23 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= -github.com/libp2p/go-libp2p v0.25.0 h1:ND6Hc6ZYCzC8S++C4mOD7LdPnLXRkNbr12/8FXgUfIo= +github.com/libp2p/go-libp2p v0.26.3 h1:6g/psubqwdaBqNNoidbRKSTBEYgaOuKBhHl8Q5tO+PM= github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= -github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= github.com/libp2p/go-nat v0.1.0 h1:MfVsH6DLcpa04Xr+p8hmVRG4juse0s3J8HyNWYHffXg= -github.com/libp2p/go-netroute v0.2.0 h1:0FpsbsvuSnAhXFnCY0VLFbJOzaK0VnP0r1QT/o4nWRE= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= -github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= @@ -217,8 +181,8 @@ github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/g github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI= github.com/multiformats/go-multibase v0.1.1/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8= -github.com/multiformats/go-multicodec v0.8.0 h1:evBmgkbSQux+Ds2IgfhkO38Dl2GDtRW8/Rp6YiSHX/Q= -github.com/multiformats/go-multicodec v0.8.0/go.mod h1:GUC8upxSBE4oG+q3kWZRw/+6yC1BqO550bjhWsJbZlw= +github.com/multiformats/go-multicodec v0.8.1 h1:ycepHwavHafh3grIbR1jIXnKCsFm0fqsfEOsJ8NtKE8= +github.com/multiformats/go-multicodec v0.8.1/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= @@ -226,23 +190,17 @@ github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUj github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg= github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= -github.com/multiformats/go-multistream v0.3.3 h1:d5PZpjwRgVlbwfdTDjife7XszfZd8KYWfROYFlGcR8o= +github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 h1:1/WtZae0yGtPq+TI6+Tv1WTxkukpXeMlviSxvL7SRgk= github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9/go.mod h1:x3N5drFsm2uilKKuuYo6LdyD8vZAW55sH/9w+pbo1sw= -github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= @@ -250,7 +208,6 @@ github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXx github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4= github.com/polydawn/refmt v0.89.0/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= @@ -259,11 +216,6 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= -github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= -github.com/savsgio/gotils v0.0.0-20210617111740-97865ed5a873/go.mod h1:dmPawKuiAeG/aFYVs2i+Dyosoo7FNcm+Pi8iK6ZUrX8= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= @@ -275,27 +227,13 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3 github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.25.0 h1:ykdZKuQey2zq0yin/l7JOm9Mh+pg72ngYMeB0ABn6q8= github.com/urfave/cli/v2 v2.25.0/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.27.0/go.mod h1:cmWIqlu99AO/RKcp1HWaViTqc57FswJOfYYdPJBl8BA= -github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= -github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/warpfork/go-testmark v0.11.0 h1:J6LnV8KpceDvo7spaNU4+DauH2n1x+6RaO2rJrmpQ9U= github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= @@ -307,30 +245,15 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:X github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa h1:EyA027ZAkuaCLoxVX4r1TZMPy1d31fM6hbfQ4OU4I5o= github.com/whyrusleeping/cbor-gen v0.0.0-20230126041949-52956bd4c9aa/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= -github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= -github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= -github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= -github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= -github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= -github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opentelemetry.io/otel v1.12.0 h1:IgfC7kqQrRccIKuB7Cl+SRUmsKbEwSGPr0Eu+/ht1SQ= -go.opentelemetry.io/otel v1.12.0/go.mod h1:geaoz0L0r1BEOR81k7/n9W4TCXYCJ7bPO7K374jQHG0= -go.opentelemetry.io/otel/trace v1.12.0 h1:p28in++7Kd0r2d8gSt931O57fdjUyWxkVbESuILAeUc= -go.opentelemetry.io/otel/trace v1.12.0/go.mod h1:pHlgBynn6s25qJ2szD+Bv+iwKJttjHSI3lUAyf0GNuQ= +go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= +go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= +go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= @@ -353,69 +276,47 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/exp v0.0.0-20230129154200-a960b3787bd2 h1:5sPMf9HJXrvBWIamTw+rTST0bZ3Mho2n1p58M0+W99c= -golang.org/x/exp v0.0.0-20230129154200-a960b3787bd2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w= +golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -424,10 +325,9 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= +golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -439,22 +339,15 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175 google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= -moul.io/http2curl/v2 v2.3.0 h1:9r3JfDzWPcbIklMOs2TnIFzDYvfAZvjeavG6EzP7jYs= -moul.io/http2curl/v2 v2.3.0/go.mod h1:RW4hyBjTWSYDOxapodpNEtX0g5Eb16sxklBqmd2RHcE= diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 79d1e2333..6eb9b66c6 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -7,16 +7,14 @@ import ( "path" "strings" + "github.com/ipfs/boxo/blockservice" + "github.com/ipfs/boxo/ipld/car/v2/blockstore" + "github.com/ipfs/boxo/ipld/merkledag" + "github.com/ipfs/boxo/ipld/unixfs/io" "github.com/ipfs/gateway-conformance/tooling/fixtures" - "github.com/ipfs/go-blockservice" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" format "github.com/ipfs/go-ipld-format" - "github.com/ipfs/go-merkledag" - "github.com/ipfs/go-unixfs/io" - "github.com/ipld/go-car/v2/blockstore" - "github.com/ipld/go-ipld-prime/codec/dagjson" - "github.com/ipld/go-ipld-prime/codec/json" - "github.com/multiformats/go-multicodec" ) type UnixfsDag struct { @@ -26,16 +24,6 @@ type UnixfsDag struct { links map[string]*UnixfsDag } -func init() { - format.Register(uint64(multicodec.Json), json.Decode) - format.Register(uint64(multicodec.DagJson), dagjson.Decode) - - // TODO: register the json codec (0x200) so that merkleDAG nodes can be decoded - // legacy.RegisterCodec(uint64(multicodec.Json), basicnode.Prototype.Any, ) - // legacy.RegisterCodec(uint64(multicodec.DagJson), basicnode.Prototype.Any, ) -} - - func newUnixfsDagFromCar(file string) (*UnixfsDag, error) { bs, err := blockstore.OpenReadOnly(file) if err != nil { From 7123544a3680835a9bacbd87a64fab4b0562429e Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 28 Mar 2023 17:05:44 +0200 Subject: [PATCH 08/23] feat: add json check + 123 fixtures plain --- tests/t0123_gateway_json_cbor_test.go | 35 ++++++++++++----------- tooling/car/unixfs.go | 26 +++++++++++++++++ tooling/check/check.go | 41 +++++++++++++++++++++++++++ tooling/test/sugar.go | 4 +++ 4 files changed, 89 insertions(+), 17 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index f8880d86a..7162878e3 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/ipfs/gateway-conformance/tooling/car" + . "github.com/ipfs/gateway-conformance/tooling/check" "github.com/ipfs/gateway-conformance/tooling/test" . "github.com/ipfs/gateway-conformance/tooling/test" ) @@ -267,11 +268,11 @@ func TestPlainCodec(t *testing.T) { } for _, row := range table { - plainFixture := car.MustOpenUnixfsCar(fmt.Sprintf("t0123/plain.%s.car", row.Format)) - plainOrDagFixture := car.MustOpenUnixfsCar(fmt.Sprintf("t0123/plain-that-can-be-dag.%s.car", row.Format)) + plainFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain.%s.car", row.Format)) + plainOrDagFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain-that-can-be-dag.%s.car", row.Format)) - plainCID := plainFixture.MustGetCid() - plainOrDagCID := plainOrDagFixture.MustGetCid() + plainCID := plainFixture.Cid() + plainOrDagCID := plainOrDagFixture.Cid() tests := SugarTests{ /** @@ -286,7 +287,7 @@ func TestPlainCodec(t *testing.T) { ' */ { - Name: fmt.Sprintf("GET %s without Accept or format= has expected %s Content-Type and body as-is", row.Name, row.Format), + Name: fmt.Sprintf(`GET %s without Accept or format= has expected "%s" Content-Type and body as-is`, row.Name, row.Format), Hint: ` No explicit format, just codec in CID `, @@ -296,11 +297,11 @@ func TestPlainCodec(t *testing.T) { Status(200). Headers( Header("Content-Disposition"). - Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), + Contains(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), Header("Content-Type"). - Equals(fmt.Sprintf("application/%s", row.Format)), + Contains(fmt.Sprintf("application/%s", row.Format)), ).Body( - plainFixture.MustGetRawData(), + plainFixture.RawData(), ), }, /** @@ -326,11 +327,11 @@ func TestPlainCodec(t *testing.T) { Status(200). Headers( Header("Content-Disposition"). - Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), + Contains("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format), Header("Content-Type"). - Equals(fmt.Sprintf("application/%s", row.Format)), + Contains("application/%s", row.Format), ).Body( - plainFixture.MustGetRawData(), + plainFixture.RawData(), ), }, /** @@ -356,11 +357,11 @@ func TestPlainCodec(t *testing.T) { Status(200). Headers( Header("Content-Disposition"). - Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format)), + Contains("%s; filename=\"%s.%s\"", row.Disposition, plainCID, row.Format), Header("Content-Type"). - Equals(fmt.Sprintf("application/%s", row.Format)), + Contains("application/%s", row.Format), ).Body( - plainFixture.MustGetRawData(), + plainFixture.RawData(), ), }, /** @@ -390,11 +391,11 @@ func TestPlainCodec(t *testing.T) { Status(200). Headers( Header("Content-Disposition"). - Equals(fmt.Sprintf("%s; filename=\"%s.%s\"", row.Disposition, plainOrDagCID, row.Format)), + Contains("%s; filename=\"%s.%s\"", row.Disposition, plainOrDagCID, row.Format), Header("Content-Type"). - Equals(fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + Contains("application/vnd.ipld.dag-%s", row.Format), ).Body( - plainFixture.MustGetRawData(), + IsJSONEqual(plainOrDagFixture.RawData()), ), }, } diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 6eb9b66c6..d59bc4860 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -103,3 +103,29 @@ func MustOpenUnixfsCar(file string) *UnixfsDag { } return dag } + +func newBlockFromCar(file string) (blocks.Block, error) { + bs, err := blockstore.OpenReadOnly(file) + if err != nil { + return nil, err + } + root, err := bs.Roots() + if err != nil { + return nil, err + } + if len(root) != 1 { + return nil, fmt.Errorf("expected 1 root, got %d", len(root)) + } + return bs.Get(context.Background(), root[0]) +} + +func MustOpenRawBlockFromCar(file string) blocks.Block { + fixturePath := path.Join(fixtures.Dir(), file) + + block, err := newBlockFromCar(fixturePath) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + return block +} \ No newline at end of file diff --git a/tooling/check/check.go b/tooling/check/check.go index b0a798352..e31c81130 100644 --- a/tooling/check/check.go +++ b/tooling/check/check.go @@ -1,7 +1,9 @@ package check import ( + "encoding/json" "fmt" + "reflect" "regexp" "strings" ) @@ -223,3 +225,42 @@ func (c CheckNot) Check(v string) CheckOutput { } var _ Check[string] = CheckNot{} + +type CheckIsJSONEqual struct { + Value []byte +} + +func IsJSONEqual(value []byte) Check[[]byte] { + return &CheckIsJSONEqual{ + Value: value, + } +} + +func areJSONEqual(b1, b2 []byte) bool { + var o1, o2 interface{} + err := json.Unmarshal(b1, &o1) + if err != nil { + panic(err) // TODO: move a t.Testing around to `t.Fatal` this case + } + err = json.Unmarshal(b2, &o2) + if err != nil { + panic(err) // TODO: move a t.Testing around to `t.Fatal` this case + } + + return reflect.DeepEqual(o1, o2) +} + +func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { + if areJSONEqual(v, c.Value) { + return CheckOutput{ + Success: true, + } + } + + return CheckOutput{ + Success: false, + Reason: fmt.Sprintf("expected '%s', got '%s'", string(c.Value), string(v)), + } +} + +var _ Check[[]byte] = &CheckIsJSONEqual{} \ No newline at end of file diff --git a/tooling/test/sugar.go b/tooling/test/sugar.go index b35f03a5a..bd1c64dbc 100644 --- a/tooling/test/sugar.go +++ b/tooling/test/sugar.go @@ -144,6 +144,10 @@ func (e ExpectBuilder) Body(body interface{}) ExpectBuilder { e.Body_ = body case check.CheckWithHint[string]: e.Body_ = body + case check.Check[[]byte]: + e.Body_ = body + case check.CheckWithHint[[]byte]: + e.Body_ = body default: panic("body must be string, []byte, or a regular check") } From 4afb1e26db9d37798938a6c75cf1faedbae9fe26 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 29 Mar 2023 12:51:09 +0200 Subject: [PATCH 09/23] feat: add body bytes check + exists + more t0123 --- fixtures/t0123/dag-cbor-traversal.car | Bin 0 -> 318 bytes fixtures/t0123/dag-json-traversal.car | Bin 0 -> 406 bytes fixtures/t0123/dag-pb.car | Bin 0 -> 392 bytes fixtures/t0123/dag-pb.json | 23 ++ tests/t0123_gateway_json_cbor_test.go | 470 +++++++++++++++++++++++++- tooling/car/unixfs.go | 1 + tooling/check/check.go | 25 +- tooling/test/sugar.go | 8 +- tooling/test/test.go | 10 + 9 files changed, 528 insertions(+), 9 deletions(-) create mode 100644 fixtures/t0123/dag-cbor-traversal.car create mode 100644 fixtures/t0123/dag-json-traversal.car create mode 100644 fixtures/t0123/dag-pb.car create mode 100644 fixtures/t0123/dag-pb.json diff --git a/fixtures/t0123/dag-cbor-traversal.car b/fixtures/t0123/dag-cbor-traversal.car new file mode 100644 index 0000000000000000000000000000000000000000..92c3d4f3e21718627007431c6b6d0cc1693be206 GIT binary patch literal 318 zcmcColvlXV(2oIMVptN{kPzW{vS&r0ub_{_K>mhu-w1 zv^b}ir4|)u=I1dM5Tklwa$0`=qLiG>yll7)cbQITWL7ctu-q3j&R(lE-F}^dl&{i> zKYDy?e%dYj{535;Oie9HtSCq+tW3+S zN-Qr(GOx-pP0uSxH_s|J&aEu1%u6yc%1f`xP0cs2$TQ8(%{47ZOe!%eRI1fc%1_El zO)dc$mz0EK_&Lb+xI#2#-t#MrbvfF8z zZSAu%HyyJ6o*#0o^a0ObkQqf7E=#I1%FigR$SF!oPs}qet|&?`PD`!KG%e4s$jmO! z&n(R|%`{C;EzUElN-r=@Ez7Mm0lKW#8EhqA$>U3}JAK&Rg?BCqN|fEat~K(+;;O!m mNqL*n-%L%jtX9fM&B*}i+sBr1Tzs1^WU$DR8C literal 0 HcmV?d00001 diff --git a/fixtures/t0123/dag-pb.car b/fixtures/t0123/dag-pb.car new file mode 100644 index 0000000000000000000000000000000000000000..a6bb076c7e323e449dfe3f6290adbe7e3826cf21 GIT binary patch literal 392 zcmcColv6N9G>c!tg+FvpA8Lzlk~eSLZrIRuTwwE~hlf;U z76qo4r4|)u=I1eXF%qL(NS8|mq^|IQa`O8b2I)OECVzyMewgCAPNpIter34l*}|*5 zT4#fWnA7s}C0vCJfyzUL6rzjWn-?3Nly$m#PLi+f!g;?F8kf!m7^ME`R`a{7@j*j~ z9jIKdq@qNEmy3ymF`6hVpl07>^l?*Z@mjj;ut>RWcE+qL>A(DBr2-c2SUERp>UaIG uLhMP2MPRe}KxP|(+(Sr@M`}(^zK%k9eo;<}B9|dCUVv)x3~&op import_output && + test_should_contain $DAG_CBOR_TRAVERSAL_CID import_output && + ipfs dag import ../t0123-gateway-json-cbor/dag-json-traversal.car > import_output && + test_should_contain $DAG_JSON_TRAVERSAL_CID import_output && + ipfs dag import ../t0123-gateway-json-cbor/dag-pb.car > import_output && + test_should_contain $DAG_PB_CID import_output + ' + */ + tests := SugarTests{ + /** + test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" ' + curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo?format=dag-json" > curl_output 2>&1 && + test_should_contain "501 Not Implemented" curl_output && + test_should_contain "reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented" curl_output + ' + */ + { + Name: "GET DAG-JSON traversal returns 501 if there is path remainder", + Request: Request(). + Path("ipfs/%s/foo", dagJSONTraversalCID). + Query("format", "dag-json"), + Response: Expect(). + Status(501). + Body(Contains("reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented")), + }, + /** + test_expect_success "GET DAG-JSON traverses multiple links" ' + curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo/link/bar?format=dag-json" > curl_output 2>&1 && + jq --sort-keys . curl_output > actual && + echo "{ \"hello\": \"this is not a link\" }" | jq --sort-keys . > expected && + test_cmp expected actual + ' + */ + { + Name: "GET DAG-JSON traverses multiple links", + Request: Request(). + Path("ipfs/%s/foo/link/bar", dagJSONTraversalCID). + Query("format", "dag-json"), + Response: Expect(). + Status(200), + // TODO: fix loading blocks into JSON: + // Body(IsJSONEqual(`{"hello": "this is not a link"}`)), + }, + /** + test_expect_success "GET DAG-CBOR traversal returns 501 if there is path remainder" ' + curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_CBOR_TRAVERSAL_CID/foo?format=dag-cbor" > curl_output 2>&1 && + test_should_contain "501 Not Implemented" curl_output && + test_should_contain "reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented" curl_output + ' + */ + { + Name: "GET DAG-CBOR traversal returns 501 if there is path remainder", + Request: Request(). + Path("ipfs/%s/foo", dagCBORTraversalCID). + Query("format", "dag-cbor"), + Response: Expect(). + Status(501). + Body(Contains("reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented")), + }, + /** + test_expect_success "GET DAG-CBOR traverses multiple links" ' + curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_CBOR_TRAVERSAL_CID/foo/link/bar?format=dag-json" > curl_output 2>&1 && + jq --sort-keys . curl_output > actual && + echo "{ \"hello\": \"this is not a link\" }" | jq --sort-keys . > expected && + test_cmp expected actual + ' + */ + { + Name: "GET DAG-CBOR traverses multiple links", + Request: Request(). + Path("ipfs/%s/foo/link/bar", dagCBORTraversalCID). + Query("format", "dag-json"), + Response: Expect(). + Status(200), + // TODO: fix loading blocks into JSON: + // Body(IsJSONEqual(`{"hello": "this is not a link"}`)), + }, + } + + test.Run(t, tests.Build()) +} + +// ## NATIVE TESTS for DAG-JSON (0x0129) and DAG-CBOR (0x71): +// ## DAG- regression tests for core behaviors when native DAG-(CBOR|JSON) is requested +func TestNativeDag(t *testing.T) { + missingCID := "" // TODO: generate + + table := []struct { + Name string + Format string + Disposition string + }{ + {"plain JSON codec", "json", "inline"}, + {"plain CBOR codec", "cbor", "attachment"}, + } + + for _, row := range table { + dagTraversal := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/dag-%s-traversal.car", row.Format)) + dagTraversalCID := dagTraversal.Cid() + // using unix fs / merkledag loader: + // could not choose a decoder: no decoder registered for multicodec code 113 (0x71) + + // plainFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain.%s.car", row.Format)) + // plainOrDagFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain-that-can-be-dag.%s.car", row.Format)) + + // plainCID := plainFixture.Cid() + // plainOrDagCID := plainOrDagFixture.Cid() + + tests := SugarTests{ + /** + # GET without explicit format and Accept: text/html returns raw block + + test_expect_success "GET $name from /ipfs without explicit format returns the same payload as the raw block" ' + ipfs block get "/ipfs/$CID" > expected && + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o curl_output && + test_cmp expected curl_output + ' + */ + { + Name: fmt.Sprintf("GET %s from /ipfs without explicit format returns the same payload as the raw block", row.Name), + Hint: `GET without explicit format and Accept: text/html returns raw block`, + Request: Request(). + Path("ipfs/%s", dagTraversalCID), + Response: Expect(). + Status(200), + // TODO: make this work by loading the block with the right codec: + // Body(IsJSONEqual(dagTraversal.RawData())), + }, + /** + # GET dag-cbor block via Accept and ?format and ensure both are the same as `ipfs block get` output + + test_expect_success "GET $name from /ipfs with format=dag-$format returns the same payload as the raw block" ' + ipfs block get "/ipfs/$CID" > expected && + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o curl_ipfs_dag_param_output && + test_cmp expected curl_ipfs_dag_param_output + ' + */ + { + Name: fmt.Sprintf("GET %s from /ipfs with format=dag-%s returns the same payload as the raw block", row.Name, row.Format), + Hint: `GET dag-cbor block via Accept and ?format and ensure both are the same as ipfs block get output`, + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Query("format", fmt.Sprintf("dag-%s", row.Format)), + Response: Expect(). + Status(200), + // TODO: make this work by loading the block with the right codec: + // Body(IsJSONEqual(dagTraversal.RawData())), + }, + /** + test_expect_success "GET $name from /ipfs for application/$format returns the same payload as format=dag-$format" ' + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o expected && + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" -o plain_output && + test_cmp expected plain_output + ' + */ + { + Name: fmt.Sprintf("GET %s from /ipfs for application/%s returns the same payload as format=dag-%s", row.Name, row.Format, row.Format), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Query("format", row.Format), + // TODO: implement two requests. + Response: Expect(). + Status(200), + // TODO: equalities between requests. + }, + /** + test_expect_success "GET $name from /ipfs with application/vnd.ipld.dag-$format returns the same payload as the raw block" ' + ipfs block get "/ipfs/$CID" > expected_block && + curl -sX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o curl_ipfs_dag_block_accept_output && + test_cmp expected_block curl_ipfs_dag_block_accept_output + ' + */ + { + Name: fmt.Sprintf("GET %s from /ipfs with application/vnd.ipld.dag-%s returns the same payload as the raw block", row.Name, row.Format), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + Response: Expect(). + Status(200), + // TODO: make this work by loading the block with the right codec: + // Body(IsJSONEqual(dagTraversal.RawData())), }, + /** + # Make sure DAG-* can be requested as plain JSON or CBOR and response has plain Content-Type for interop purposes + + test_expect_success "GET $name with format=$format returns same payload as format=dag-$format but with plain Content-Type" ' + curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o expected && + curl -sD plain_headers "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=$format" -o plain_output && + test_should_contain "Content-Type: application/$format" plain_headers && + test_cmp expected plain_output + ' + */ + { + Name: fmt.Sprintf("GET %s with format=%s returns same payload as format=dag-%s but with plain Content-Type", row.Name, row.Format, row.Format), + Hint: `Make sure DAG-* can be requested as plain JSON or CBOR and response has plain Content-Type for interop purposes`, + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Query("format", row.Format), + Response: Expect(). + Status(200). + Header(Header("Content-Type", "application/%s", row.Format)), + // TODO: equalities between requests. + }, + /** + test_expect_success "GET $name with Accept: application/$format returns same payload as application/vnd.ipld.dag-$format but with plain Content-Type" ' + curl -s -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > expected && + curl -sD plain_headers -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > plain_output && + test_should_contain "Content-Type: application/$format" plain_headers && + test_cmp expected plain_output + ' + */ + { + Name: fmt.Sprintf("GET %s with Accept: application/%s returns same payload as application/vnd.ipld.dag-%s but with plain Content-Type", row.Name, row.Format, row.Format), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Header("Accept", "application/%s", row.Format), + Response: Expect(). + Status(200). + Header(Header("Content-Type", "application/%s", row.Format)), + // TODO: equalities between requests. + }, + /** + # Make sure expected HTTP headers are returned with the dag- block + + test_expect_success "GET response for application/vnd.ipld.dag-$format has expected Content-Type" ' + curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" >/dev/null 2>curl_output && + test_should_contain "< Content-Type: application/vnd.ipld.dag-$format" curl_output + ' + test_expect_success "GET response for application/vnd.ipld.dag-$format includes Content-Length" ' + BYTES=$(ipfs block get $CID | wc --bytes) + test_should_contain "< Content-Length: $BYTES" curl_output + ' + test_expect_success "GET response for application/vnd.ipld.dag-$format includes Content-Disposition" ' + test_should_contain "< Content-Disposition: ${disposition}\; filename=\"${CID}.${format}\"" curl_output + ' + test_expect_success "GET response for application/vnd.ipld.dag-$format includes nosniff hint" ' + test_should_contain "< X-Content-Type-Options: nosniff" curl_output + ' + */ + { + Name: fmt.Sprintf("GET response for application/vnd.ipld.dag-%s has expected Content-Type", row.Format), + Hint: `Make sure expected HTTP headers are returned with the dag- block`, + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + Response: Expect(). + Headers( + Header("Content-Type").Hint("expected Content-Type").Equals("application/vnd.ipld.dag-%s", row.Format), + Header("Content-Length").Hint("includes Content-Length").Equals("%d", len(dagTraversal.RawData())), + Header("Content-Disposition").Hint("includes Content-Disposition").Contains("%s; filename=\"%s.%s\"", row.Disposition, dagTraversalCID, row.Format), + Header("X-Content-Type-Options").Hint("includes nosniff hint").Contains("nosniff"), + ), + }, + /** + test_expect_success "GET for application/vnd.ipld.dag-$format with query filename includes Content-Disposition with custom filename" ' + curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?filename=foobar.$format" >/dev/null 2>curl_output_filename && + test_should_contain "< Content-Disposition: ${disposition}\; filename=\"foobar.$format\"" curl_output_filename + ' + */ + { + Name: fmt.Sprintf("GET for application/vnd.ipld.dag-%s with query filename includes Content-Disposition with custom filename", row.Format), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Query("filename", fmt.Sprintf("foobar.%s", row.Format)). + Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + Response: Expect(). + Header(Header("Content-Disposition").Hint("includes Content-Disposition").Contains("%s; filename=\"foobar.%s\"", row.Disposition, row.Format)), + }, + /** + test_expect_success "GET for application/vnd.ipld.dag-$format with ?download=true forces Content-Disposition: attachment" ' + curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?filename=foobar.$format&download=true" >/dev/null 2>curl_output_filename && + test_should_contain "< Content-Disposition: attachment" curl_output_filename + ' + */ + { + Name: fmt.Sprintf("GET for application/vnd.ipld.dag-%s with ?download=true forces Content-Disposition: attachment", row.Format), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Query("filename", fmt.Sprintf("foobar.%s", row.Format)). + Query("download", "true"). + Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + Response: Expect(). + Header(Header("Content-Disposition").Hint("includes Content-Disposition").Contains("attachment; filename=\"foobar.%s\"", row.Format)), + }, + /** + # Cache control HTTP headers + # (basic checks, detailed behavior is tested in t0116-gateway-cache.sh) + + test_expect_success "GET response for application/vnd.ipld.dag-$format includes Etag" ' + test_should_contain "< Etag: \"${CID}.dag-$format\"" curl_output + ' + test_expect_success "GET response for application/vnd.ipld.dag-$format includes X-Ipfs-Path and X-Ipfs-Roots" ' + test_should_contain "< X-Ipfs-Path" curl_output && + test_should_contain "< X-Ipfs-Roots" curl_output + ' + test_expect_success "GET response for application/vnd.ipld.dag-$format includes Cache-Control" ' + test_should_contain "< Cache-Control: public, max-age=29030400, immutable" curl_output + ' + */ + { + Name: fmt.Sprintf("Cache control HTTP headers (%s)", row.Format), + Hint: `(basic checks, detailed behavior is tested in t0116-gateway-cache.sh)`, + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), + Response: Expect(). + Headers( + Header("Etag").Hint("includes Etag").Contains("%s.dag-%s", dagTraversalCID, row.Format), + Header("X-Ipfs-Path").Hint("includes X-Ipfs-Path").Exists(), + Header("X-Ipfs-Roots").Hint("includes X-Ipfs-Roots").Exists(), + Header("Cache-Control").Hint("includes Cache-Control").Contains("public, max-age=29030400, immutable"), + ), + }, + /** + # HTTP HEAD behavior + test_expect_success "HEAD $name with no explicit format returns HTTP 200" ' + curl -I "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o output && + test_should_contain "HTTP/1.1 200 OK" output && + test_should_contain "Content-Type: application/vnd.ipld.dag-$format" output && + test_should_contain "Content-Length: " output + ' + */ + { + Name: fmt.Sprintf("HEAD %s with no explicit format returns HTTP 200", row.Name), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Method("HEAD"), + Response: Expect(). + Status(200). + Headers( + Header("Content-Type").Hint("includes Content-Type").Contains("application/vnd.ipld.dag-%s", row.Format), + Header("Content-Length").Hint("includes Content-Length").Exists(), + ), + }, + /** + test_expect_success "HEAD $name with an explicit DAG-JSON format returns HTTP 200" ' + curl -I "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-json" -o output && + test_should_contain "HTTP/1.1 200 OK" output && + test_should_contain "Etag: \"$CID.dag-json\"" output && + test_should_contain "Content-Type: application/vnd.ipld.dag-json" output && + test_should_contain "Content-Length: " output + ' + */ + { + Name: fmt.Sprintf("HEAD %s with an explicit DAG-JSON format returns HTTP 200", row.Name), + Request: Request(). + Path("ipfs/%s", dagTraversalCID). + Query("format", "dag-json"). + Method("HEAD"), + Response: Expect(). + Status(200). + Headers( + Header("Etag").Hint("includes Etag").Contains("%s.dag-json", dagTraversalCID), + Header("Content-Type").Hint("includes Content-Type").Contains("application/vnd.ipld.dag-json"), + Header("Content-Length").Hint("includes Content-Length").Exists(), + ), + }, + /** + test_expect_success "HEAD $name with only-if-cached for missing block returns HTTP 412 Precondition Failed" ' + MISSING_CID=$(echo "{\"t\": \"$(date +%s)\"}" | ipfs dag put --store-codec=dag-${format}) && + ipfs block rm -f -q $MISSING_CID && + curl -I -H "Cache-Control: only-if-cached" "http://127.0.0.1:$GWAY_PORT/ipfs/$MISSING_CID" -o output && + test_should_contain "HTTP/1.1 412 Precondition Failed" output + ' + */ + { + Name: fmt.Sprintf("HEAD %s with only-if-cached for missing block returns HTTP 412 Precondition Failed", row.Name), + Request: Request(). + Path("ipfs/%s", missingCID). + Header("Cache-Control", "only-if-cached"). + Method("HEAD"), + Response: Expect(). + Status(412), + }, + /** + # IPNS behavior (should be same as immutable /ipfs, but with different caching headers) + # To keep tests small we only confirm payload is the same, and then only test delta around caching headers. + + test_expect_success "Prepare IPNS with dag-$format" ' + IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${format}_test_key | head -n1 | tr -d "\n") && + ipfs name publish --key ${format}_test_key --allow-offline -Q "/ipfs/$CID" > name_publish_out && + test_check_peerid "${IPNS_ID}" && + ipfs name resolve "${IPNS_ID}" > output && + printf "/ipfs/%s\n" "$CID" > expected && + test_cmp expected output + ' + */ + // TODO: IPNS + /** + test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" ' + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o ipfs_output && + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" -o ipns_output && + test_cmp ipfs_output ipns_output + ' + */ + // TODO: IPNS + /** + test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" ' + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID?format=dag-$format" -o ipfs_output && + curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID?format=dag-$format" -o ipns_output && + test_cmp ipfs_output ipns_output + ' + */ + /** + test_expect_success "GET $name from /ipns with explicit application/vnd.ipld.dag-$format has expected headers" ' + curl -svX GET -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" >/dev/null 2>curl_output && + test_should_not_contain "Cache-Control" curl_output && + test_should_contain "< Content-Type: application/vnd.ipld.dag-$format" curl_output && + test_should_contain "< Etag: \"${CID}.dag-$format\"" curl_output && + test_should_contain "< X-Ipfs-Path" curl_output && + test_should_contain "< X-Ipfs-Roots" curl_output + ' + */ + // TODO: IPNS + /** + # When Accept header includes text/html and no explicit format is requested for DAG-(CBOR|JSON) + # The gateway returns generated HTML index (see dag-index-html) for web browsers (similar to dir-index-html returned for unixfs dirs) + # As this is generated, we don't return immutable Cache-Control, even on /ipfs (same as for dir-index-html) + + test_expect_success "GET $name on /ipfs with Accept: text/html returns HTML (dag-index-html)" ' + curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" > curl_output 2>&1 && + test_should_not_contain "Content-Disposition" curl_output && + test_should_not_contain "Cache-Control" curl_output && + test_should_contain "Etag: \"DagIndex-" curl_output && + test_should_contain "Content-Type: text/html" curl_output && + test_should_contain "" curl_output + ' + */ + // TODO: IPNS + /** + test_expect_success "GET $name on /ipns with Accept: text/html returns HTML (dag-index-html)" ' + curl -sD - -H "Accept: text/html" "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" > curl_output 2>&1 && + test_should_not_contain "Content-Disposition" curl_output && + test_should_not_contain "Cache-Control" curl_output && + test_should_contain "Etag: \"DagIndex-" curl_output && + test_should_contain "Content-Type: text/html" curl_output && + test_should_contain "" curl_output + ' + */ } test.Run(t, tests.Build()) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index d59bc4860..c4ccde076 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -61,6 +61,7 @@ func (d *UnixfsDag) getNode(names ...string) (format.Node, error) { d.links[l.Name] = &UnixfsDag{dsvc: d.dsvc, cid: l.Cid} } } + d = d.links[name] if d == nil { return nil, fmt.Errorf("no link named %s", strings.Join(names, "/")) diff --git a/tooling/check/check.go b/tooling/check/check.go index e31c81130..9d6a20bb7 100644 --- a/tooling/check/check.go +++ b/tooling/check/check.go @@ -227,10 +227,15 @@ func (c CheckNot) Check(v string) CheckOutput { var _ Check[string] = CheckNot{} type CheckIsJSONEqual struct { - Value []byte + Value interface{} } -func IsJSONEqual(value []byte) Check[[]byte] { +func IsJSONEqual(value interface{}) Check[[]byte] { + value, err := json.Marshal(value) + if err != nil { + panic(err) // TODO: move a t.Testing around to `t.Fatal` this case + } + return &CheckIsJSONEqual{ Value: value, } @@ -251,15 +256,27 @@ func areJSONEqual(b1, b2 []byte) bool { } func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { - if areJSONEqual(v, c.Value) { + var o interface{} + err := json.Unmarshal(v, &o) + if err != nil { + panic(err) // TODO: move a t.Testing around to call `t.Fatal` on this case + } + + + if reflect.DeepEqual(o, c.Value) { return CheckOutput{ Success: true, } } + b, err := json.Marshal(c.Value) + if err != nil { + panic(err) // TODO: move a t.Testing around to call `t.Fatal` on this case + } + return CheckOutput{ Success: false, - Reason: fmt.Sprintf("expected '%s', got '%s'", string(c.Value), string(v)), + Reason: fmt.Sprintf("expected '%s', got '%s'", string(b), string(v)), } } diff --git a/tooling/test/sugar.go b/tooling/test/sugar.go index bd1c64dbc..85e14e7be 100644 --- a/tooling/test/sugar.go +++ b/tooling/test/sugar.go @@ -66,12 +66,12 @@ func (r RequestBuilder) Method(method string) RequestBuilder { return r } -func (r RequestBuilder) Header(k, v string) RequestBuilder { +func (r RequestBuilder) Header(k, v string, rest ...any) RequestBuilder { if r.Headers_ == nil { r.Headers_ = make(map[string]string) } - r.Headers_[k] = v + r.Headers_[k] = fmt.Sprintf(v, rest...) return r } @@ -259,3 +259,7 @@ func (h HeaderBuilder) Not() HeaderBuilder { h.Not_ = !h.Not_ return h } + +func (h HeaderBuilder) Exists() HeaderBuilder { + return h.Not().IsEmpty() +} diff --git a/tooling/test/test.go b/tooling/test/test.go index 6a8af3c22..02173295c 100644 --- a/tooling/test/test.go +++ b/tooling/test/test.go @@ -205,6 +205,16 @@ func Run(t *testing.T, tests []CTest) { if !output.Success { localReport(t, "Body %s (%s)", output.Reason, v.Hint) } + case check.Check[[]byte]: + output := v.Check(resBody) + if !output.Success { + localReport(t, "Body %s", output.Reason) + } + case check.CheckWithHint[[]byte]: + output := v.Check.Check(resBody) + if !output.Success { + localReport(t, "Body %s (%s)", output.Reason, v.Hint) + } case string: if string(resBody) != v { localReport(t, "Body is not '%s'. It is: '%s'", v, resBody) From a83737652e688b82e392a5371611b4a315bd6de2 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 29 Mar 2023 13:08:19 +0200 Subject: [PATCH 10/23] fix: 123 - load cids from fixtures --- tests/t0123_gateway_json_cbor_test.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 7835fedbb..bf0f4cbd7 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -413,24 +413,12 @@ func TestPlainCodec(t *testing.T) { // ## Pathing, traversal over DAG-JSON and DAG-CBOR func TestPathing(t *testing.T) { - /** - DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim" - DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq" - DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke" - */ - dagJSONTraversalCID := "baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq" // TODO: load from fixture - dagCBORTraversalCID := "bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim" // TODO: load from fixture - - /** - test_expect_success "Add CARs for path traversal and DAG-PB representation tests" ' - ipfs dag import ../t0123-gateway-json-cbor/dag-cbor-traversal.car > import_output && - test_should_contain $DAG_CBOR_TRAVERSAL_CID import_output && - ipfs dag import ../t0123-gateway-json-cbor/dag-json-traversal.car > import_output && - test_should_contain $DAG_JSON_TRAVERSAL_CID import_output && - ipfs dag import ../t0123-gateway-json-cbor/dag-pb.car > import_output && - test_should_contain $DAG_PB_CID import_output - ' - */ + dagJSONTraversal := car.MustOpenRawBlockFromCar("t0123/dag-json-traversal.car") + dagCBORTraversal := car.MustOpenRawBlockFromCar("t0123/dag-cbor-traversal.car") + + dagJSONTraversalCID := dagJSONTraversal.Cid() + dagCBORTraversalCID := dagCBORTraversal.Cid() + tests := SugarTests{ /** test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" ' From 8a1049932dfb8f88f6874b727cdd0b3b431978d9 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 29 Mar 2023 15:23:00 +0200 Subject: [PATCH 11/23] feat: test panic instead of exit --- tooling/car/unixfs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index c4ccde076..7523df390 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -80,8 +80,7 @@ func (d *UnixfsDag) getNode(names ...string) (format.Node, error) { func (d *UnixfsDag) mustGetNode(names ...string) format.Node { node, err := d.getNode(names...) if err != nil { - fmt.Println(err) - os.Exit(1) + panic(err) } return node } From 0cae6c26ddb417ef1c6094c530615674b123515c Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 29 Mar 2023 15:23:37 +0200 Subject: [PATCH 12/23] feat: t0123 - compare decoded dags --- tests/t0123_gateway_json_cbor_test.go | 14 +++++++--- tooling/car/unixfs.go | 37 ++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index bf0f4cbd7..d5745ea0e 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -92,6 +92,10 @@ func TestDAgPbConversion(t *testing.T) { } for _, row := range table { + // ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output + formatedFile := fixture.MustGetFormattedDagNode("dag-"+row.Format, "ą", "ę", "file-źł.txt") + formatedDir := fixture.MustGetFormattedDagNode("dag-"+row.Format) + tests := SugarTests{ /** test_expect_success "GET UnixFS file as $name with format=dag-$format converts to the expected Content-Type" ' @@ -116,8 +120,9 @@ func TestDAgPbConversion(t *testing.T) { Contains("%s; filename=\"%s.%s\"", row.Disposition, fileCID, row.Format), Header("Content-Type"). Not().Contains("application/%s", row.Format), - ), - // TODO: test body `ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output` + ).Body( + formatedFile, + ), }, /** test_expect_success "GET UnixFS directory as $name with format=dag-$format converts to the expected Content-Type" ' @@ -142,8 +147,9 @@ func TestDAgPbConversion(t *testing.T) { Contains("%s; filename=\"%s.%s\"", row.Disposition, dirCID, row.Format), Header("Content-Type"). Not().Contains("application/%s", row.Format), - ), - // TODO: test body `ipfs dag get --output-codec dag-$format $DIR_CID > ipfs_dag_get_output` + ).Body( + formatedDir, + ), }, /** test_expect_success "GET UnixFS as $name with 'Accept: application/vnd.ipld.dag-$format' converts to the expected Content-Type" ' diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 7523df390..9902455c3 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -1,6 +1,7 @@ package car import ( + "bytes" "context" "fmt" "os" @@ -15,8 +16,19 @@ import ( blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" format "github.com/ipfs/go-ipld-format" + "github.com/ipld/go-ipld-prime" + _ "github.com/ipld/go-ipld-prime/codec/dagcbor" + _ "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/multicodec" + mc "github.com/multiformats/go-multicodec" ) +func init() { + // Note we force imports of dagcbor and dagjson above. + // They are registering themselves with the multicodec package + // during their `init()`. +} + type UnixfsDag struct { dsvc format.DAGService cid cid.Cid @@ -93,6 +105,29 @@ func (d *UnixfsDag) MustGetRawData(names ...string) []byte { return d.mustGetNode(names...).RawData() } +func (d *UnixfsDag) MustGetFormattedDagNode(codecStr string, names ...string) []byte { + var codec mc.Code + if err := codec.Set(codecStr); err != nil { + panic(err) + } + + encoder, err := multicodec.LookupEncoder(uint64(codec)) + if err != nil { + panic(fmt.Errorf("invalid encoding: %s - %s", codec, err)) + } + + output := new(bytes.Buffer) + node := d.mustGetNode(names...).(ipld.Node) + + err = encoder(node, output) + + if err != nil { + panic(err) + } + + return output.Bytes() +} + func MustOpenUnixfsCar(file string) *UnixfsDag { fixturePath := path.Join(fixtures.Dir(), file) @@ -128,4 +163,4 @@ func MustOpenRawBlockFromCar(file string) blocks.Block { os.Exit(1) } return block -} \ No newline at end of file +} From d0fb055861a475608c6cca8f6af3ae80769e4c4d Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 29 Mar 2023 15:23:54 +0200 Subject: [PATCH 13/23] fix: t0123 - update notes --- tests/t0123_gateway_json_cbor_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index d5745ea0e..0b127ff34 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -577,10 +577,9 @@ func TestNativeDag(t *testing.T) { Request: Request(). Path("ipfs/%s", dagTraversalCID). Query("format", row.Format), - // TODO: implement two requests. Response: Expect(). Status(200), - // TODO: equalities between requests. + // TODO: equalities between requests => REPLACE WITH AN ACTUAL EXPECTED RESPONSES. }, /** test_expect_success "GET $name from /ipfs with application/vnd.ipld.dag-$format returns the same payload as the raw block" ' From ae81ddf26c8cca4696a63b4ccf6efdb073725568 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Thu, 30 Mar 2023 12:28:18 +0200 Subject: [PATCH 14/23] refactor: unify check API to simplif code --- tooling/check/check.go | 74 ++++++++++++++++++++++++++++++++++-------- tooling/test/sugar.go | 6 ++-- tooling/test/test.go | 60 ++++++++++++++-------------------- 3 files changed, 87 insertions(+), 53 deletions(-) diff --git a/tooling/check/check.go b/tooling/check/check.go index 9d6a20bb7..97515e5d3 100644 --- a/tooling/check/check.go +++ b/tooling/check/check.go @@ -1,6 +1,7 @@ package check import ( + "bytes" "encoding/json" "fmt" "reflect" @@ -14,6 +15,8 @@ import ( type CheckOutput struct { Success bool Reason string + Err error + Hint string } type Check[T any] interface { @@ -21,17 +24,31 @@ type Check[T any] interface { } type CheckWithHint[T any] struct { - Check Check[T] - Hint string + Check_ Check[T] + Hint string } func WithHint[T any](hint string, check Check[T]) CheckWithHint[T] { return CheckWithHint[T]{ - Hint: hint, - Check: check, + Hint: hint, + Check_: check, } } +func (c CheckWithHint[T]) Check(v T) CheckOutput { + output := c.Check_.Check(v) + + if output.Hint == "" { + output.Hint = c.Hint + } else { + output.Hint = fmt.Sprintf("%s (%s)", c.Hint, output.Hint) + } + + return output +} + +var _ Check[string] = CheckWithHint[string]{} + // Base // ==== @@ -89,17 +106,23 @@ func (c *CheckAnd[T]) Check(v T) CheckOutput { } } -type CheckIsEqual struct { - Value string +type CheckIsEqual[T comparable] struct { + Value T } -func IsEqual(value string, rest ...any) Check[string] { - return &CheckIsEqual{ +func IsEqual(value string, rest ...any) CheckIsEqual[string] { + return CheckIsEqual[string]{ Value: fmt.Sprintf(value, rest...), } } -func (c *CheckIsEqual) Check(v string) CheckOutput { +func IsEqualT[T comparable](value T) *CheckIsEqual[T] { + return &CheckIsEqual[T]{ + Value: value, + } +} + +func (c CheckIsEqual[T]) Check(v T) CheckOutput { if v == c.Value { return CheckOutput{ Success: true, @@ -108,14 +131,38 @@ func (c *CheckIsEqual) Check(v string) CheckOutput { return CheckOutput{ Success: false, - Reason: fmt.Sprintf("expected '%s', got '%s'", c.Value, v), + Reason: fmt.Sprintf("expected '%v', got '%v'", c.Value, v), + } +} + +var _ Check[string] = CheckIsEqual[string]{} + +type CheckIsEqualBytes struct { + Value []byte +} + +// golang doesn't support method overloading / generic specialization +func IsEqualBytes(value []byte) CheckIsEqualBytes { + return CheckIsEqualBytes{ + Value: value, } } -var _ Check[string] = &CheckIsEqual{} +func (c CheckIsEqualBytes) Check(v []byte) CheckOutput { + if bytes.Equal(v, c.Value) { + return CheckOutput{ + Success: true, + } + } + + return CheckOutput{ + Success: false, + Reason: fmt.Sprintf("expected '%v', got '%v'", c.Value, v), + } +} func IsEqualWithHint(hint string, value string, rest ...any) CheckWithHint[string] { - return WithHint(hint, IsEqual(value, rest...)) + return WithHint[string](hint, IsEqual(value, rest...)) } type CheckContains struct { @@ -262,7 +309,6 @@ func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { panic(err) // TODO: move a t.Testing around to call `t.Fatal` on this case } - if reflect.DeepEqual(o, c.Value) { return CheckOutput{ Success: true, @@ -280,4 +326,4 @@ func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { } } -var _ Check[[]byte] = &CheckIsJSONEqual{} \ No newline at end of file +var _ Check[[]byte] = &CheckIsJSONEqual{} diff --git a/tooling/test/sugar.go b/tooling/test/sugar.go index 85e14e7be..0a05ab393 100644 --- a/tooling/test/sugar.go +++ b/tooling/test/sugar.go @@ -158,16 +158,16 @@ func (e ExpectBuilder) Body(body interface{}) ExpectBuilder { func (e ExpectBuilder) BodyWithHint(hint string, body interface{}) ExpectBuilder { switch body := body.(type) { case string: - e.Body_ = check.WithHint( + e.Body_ = check.WithHint[string]( hint, check.IsEqual(body), ) case []byte: panic("body with hint for bytes is not implemented yet") - case check.Check[string]: - e.Body_ = check.WithHint(hint, body) case check.CheckWithHint[string]: panic("this check already has a hint") + case check.Check[string]: + e.Body_ = check.WithHint(hint, body) default: panic("body must be string, []byte, or a regular check") } diff --git a/tooling/test/test.go b/tooling/test/test.go index 02173295c..1225ed1a1 100644 --- a/tooling/test/test.go +++ b/tooling/test/test.go @@ -163,25 +163,24 @@ func Run(t *testing.T, tests []CTest) { actual := res.Header.Get(key) var output check.CheckOutput - var hint string switch v := value.(type) { case check.Check[string]: output = v.Check(actual) - case check.CheckWithHint[string]: - output = v.Check.Check(actual) - hint = v.Hint case string: output = check.IsEqual(v).Check(actual) default: - localReport(t, "Header check '%s' has an invalid type: %T", key, value) + output = check.CheckOutput{ + Success: false, + Reason: fmt.Sprintf("Header check '%s' has an invalid type: %T", key, value), + } } if !output.Success { - if hint == "" { + if output.Hint == "" { localReport(t, "Header '%s' %s", key, output.Reason) } else { - localReport(t, "Header '%s' %s (%s)", key, output.Reason, hint) + localReport(t, "Header '%s' %s (%s)", key, output.Reason, output.Hint) } } }) @@ -194,41 +193,30 @@ func Run(t *testing.T, tests []CTest) { localReport(t, err) } + var output check.CheckOutput + switch v := test.Response.Body.(type) { case check.Check[string]: - output := v.Check(string(resBody)) - if !output.Success { - localReport(t, "Body %s", output.Reason) - } - case check.CheckWithHint[string]: - output := v.Check.Check(string(resBody)) - if !output.Success { - localReport(t, "Body %s (%s)", output.Reason, v.Hint) - } + output = v.Check(string(resBody)) case check.Check[[]byte]: - output := v.Check(resBody) - if !output.Success { - localReport(t, "Body %s", output.Reason) - } - case check.CheckWithHint[[]byte]: - output := v.Check.Check(resBody) - if !output.Success { - localReport(t, "Body %s (%s)", output.Reason, v.Hint) - } + output = v.Check(resBody) case string: - if string(resBody) != v { - localReport(t, "Body is not '%s'. It is: '%s'", v, resBody) - } + output = check.IsEqual(v).Check(string(resBody)) case []byte: - if !bytes.Equal(resBody, v) { - if res.Header.Get("Content-Type") == "application/vnd.ipld.raw" { - localReport(t, "Body is not '%+v'. It is: '%+v'", test.Response.Body, resBody) - } else { - localReport(t, "Body is not '%s'. It is: '%s'", test.Response.Body, resBody) - } - } + output = check.IsEqualBytes(v).Check(resBody) default: - localReport(t, "Body check has an invalid type: %T", test.Response.Body) + output = check.CheckOutput{ + Success: false, + Reason: fmt.Sprintf("Body check has an invalid type: %T", test.Response.Body), + } + } + + if !output.Success { + if output.Hint == "" { + localReport(t, "Body %s", output.Reason) + } else { + localReport(t, "Body %s (%s)", output.Reason, output.Hint) + } } } }) From e88990eaa2b535ae3262782d7e93281791f54894 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Thu, 30 Mar 2023 13:06:20 +0200 Subject: [PATCH 15/23] feat: t0113 - implement missing listing --- tests/t0113_gateway_symlink_test.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/t0113_gateway_symlink_test.go b/tests/t0113_gateway_symlink_test.go index 65bf567a6..3b75b1309 100644 --- a/tests/t0113_gateway_symlink_test.go +++ b/tests/t0113_gateway_symlink_test.go @@ -4,33 +4,46 @@ import ( "testing" "github.com/ipfs/gateway-conformance/tooling/car" + . "github.com/ipfs/gateway-conformance/tooling/check" "github.com/ipfs/gateway-conformance/tooling/test" . "github.com/ipfs/gateway-conformance/tooling/test" ) func TestGatewaySymlink(t *testing.T) { fixture := car.MustOpenUnixfsCar("t0113-gateway-symlink.car") + rootDirCID := fixture.MustGetCid() - tests := []CTest{ + tests := SugarTests{ { Name: "Test the directory listing", Request: Request(). - Path("ipfs/%s?format=raw", fixture.MustGetCid()).Request(), + Path("ipfs/%s/", rootDirCID), + Response: Expect(). + Body( + And( + Contains(">foo<"), + Contains(">bar<"), + ), + ), + }, + { + Name: "Test the directory raw query", + Request: Request(). + Path("ipfs/%s", rootDirCID). + Query("format", "raw"), Response: Expect(). Status(200). - Body(fixture.MustGetRawData()). - Response(), + Body(fixture.MustGetRawData()), }, { Name: "Test the symlink", Request: Request(). - Path("ipfs/%s/bar", fixture.MustGetCid()).Request(), + Path("ipfs/%s/bar", rootDirCID), Response: Expect(). Status(200). - Bytes("foo"). - Response(), + Bytes("foo"), }, } - test.Run(t, tests) + test.Run(t, tests.Build()) } From e065f29f86bd54c3c0325b0a5826019f311056b8 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 31 Mar 2023 10:28:18 +0200 Subject: [PATCH 16/23] feat: 123 - loads raw fixtures + checkers --- tests/t0123_gateway_json_cbor_test.go | 27 ++++++++++++++++++++----- tooling/car/unixfs.go | 8 +++++++- tooling/check/check.go | 29 +++++++++++---------------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 0b127ff34..d972298b4 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -1,6 +1,7 @@ package tests import ( + "context" "fmt" "testing" @@ -8,6 +9,7 @@ import ( . "github.com/ipfs/gateway-conformance/tooling/check" "github.com/ipfs/gateway-conformance/tooling/test" . "github.com/ipfs/gateway-conformance/tooling/test" + legacy "github.com/ipfs/go-ipld-legacy" ) func TestGatewayJsonCbor(t *testing.T) { @@ -94,7 +96,7 @@ func TestDAgPbConversion(t *testing.T) { for _, row := range table { // ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output formatedFile := fixture.MustGetFormattedDagNode("dag-"+row.Format, "ą", "ę", "file-źł.txt") - formatedDir := fixture.MustGetFormattedDagNode("dag-"+row.Format) + formatedDir := fixture.MustGetFormattedDagNode("dag-" + row.Format) tests := SugarTests{ /** @@ -258,7 +260,6 @@ func TestDAgPbConversion(t *testing.T) { test.Run(t, tests.Build()) } - } // # Requesting CID with plain json (0x0200) and cbor (0x51) codecs @@ -268,9 +269,10 @@ func TestPlainCodec(t *testing.T) { Name string Format string Disposition string + Checker func(value []byte) Check[[]byte] }{ - {"plain JSON codec", "json", "inline"}, - {"plain CBOR codec", "cbor", "attachment"}, + {"plain JSON codec", "json", "inline", IsJSONEqual}, + {"plain CBOR codec", "cbor", "attachment", IsEqualBytes}, } for _, row := range table { @@ -280,6 +282,19 @@ func TestPlainCodec(t *testing.T) { plainCID := plainFixture.Cid() plainOrDagCID := plainOrDagFixture.Cid() + // We want to implement the equivalent of: + // CID=$(echo "{ \"test\": \"plain-json-that-can-also-be-dag-json\" }" | ipfs dag put --input-codec json --store-codec $format) && + // ipfs dag get --output-codec dag-$format $CID > ipfs_dag_get_output 2>&1 && + // test_cmp ipfs_dag_get_output curl_output_param && + g, err := legacy.DecodeNode(context.Background(), plainOrDagFixture) + if err != nil { + t.Fatal(err) + } + + d := car.FormatDagNode(g, "dag-"+row.Format) + + fmt.Println("d:", row.Format, d, string(d)) + tests := SugarTests{ /** # no explicit format, just codec in CID @@ -409,7 +424,9 @@ func TestPlainCodec(t *testing.T) { // We want to implement someting like: //).Body( // IsJSONEqual(plainOrDagFixture.RawData()), - ), + ).Body( + row.Checker(d), + ), }, } diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 9902455c3..dd597adb4 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -17,8 +17,10 @@ import ( "github.com/ipfs/go-cid" format "github.com/ipfs/go-ipld-format" "github.com/ipld/go-ipld-prime" + _ "github.com/ipld/go-ipld-prime/codec/cbor" _ "github.com/ipld/go-ipld-prime/codec/dagcbor" _ "github.com/ipld/go-ipld-prime/codec/dagjson" + _ "github.com/ipld/go-ipld-prime/codec/json" "github.com/ipld/go-ipld-prime/multicodec" mc "github.com/multiformats/go-multicodec" ) @@ -106,6 +108,11 @@ func (d *UnixfsDag) MustGetRawData(names ...string) []byte { } func (d *UnixfsDag) MustGetFormattedDagNode(codecStr string, names ...string) []byte { + node := d.mustGetNode(names...).(ipld.Node) + return FormatDagNode(node, codecStr) +} + +func FormatDagNode(node ipld.Node, codecStr string) []byte { var codec mc.Code if err := codec.Set(codecStr); err != nil { panic(err) @@ -117,7 +124,6 @@ func (d *UnixfsDag) MustGetFormattedDagNode(codecStr string, names ...string) [] } output := new(bytes.Buffer) - node := d.mustGetNode(names...).(ipld.Node) err = encoder(node, output) diff --git a/tooling/check/check.go b/tooling/check/check.go index 97515e5d3..91d5a8623 100644 --- a/tooling/check/check.go +++ b/tooling/check/check.go @@ -142,7 +142,7 @@ type CheckIsEqualBytes struct { } // golang doesn't support method overloading / generic specialization -func IsEqualBytes(value []byte) CheckIsEqualBytes { +func IsEqualBytes(value []byte) Check[[]byte] { return CheckIsEqualBytes{ Value: value, } @@ -161,6 +161,8 @@ func (c CheckIsEqualBytes) Check(v []byte) CheckOutput { } } +var _ Check[[]byte] = CheckIsEqualBytes{} + func IsEqualWithHint(hint string, value string, rest ...any) CheckWithHint[string] { return WithHint[string](hint, IsEqual(value, rest...)) } @@ -277,33 +279,26 @@ type CheckIsJSONEqual struct { Value interface{} } -func IsJSONEqual(value interface{}) Check[[]byte] { - value, err := json.Marshal(value) +func IsJSONEqual(value []byte) Check[[]byte] { + var result map[string]any + err := json.Unmarshal(value, &result) if err != nil { panic(err) // TODO: move a t.Testing around to `t.Fatal` this case } + fmt.Println("result:", result) + return &CheckIsJSONEqual{ Value: value, } } -func areJSONEqual(b1, b2 []byte) bool { - var o1, o2 interface{} - err := json.Unmarshal(b1, &o1) - if err != nil { - panic(err) // TODO: move a t.Testing around to `t.Fatal` this case - } - err = json.Unmarshal(b2, &o2) - if err != nil { - panic(err) // TODO: move a t.Testing around to `t.Fatal` this case - } +func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { + fmt.Println("checked value:", string(v)) - return reflect.DeepEqual(o1, o2) -} + fmt.Println("checking", string(v), "against", c.Value) -func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { - var o interface{} + var o map[string]any err := json.Unmarshal(v, &o) if err != nil { panic(err) // TODO: move a t.Testing around to call `t.Fatal` on this case From 6c7592b231feeb45b885d79bbf87cfb2062faf5d Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 31 Mar 2023 11:06:43 +0200 Subject: [PATCH 17/23] feat: 123 - missing decoding functions --- tests/t0123_gateway_json_cbor_test.go | 95 +++++++++++++++------------ tooling/car/fixture.go | 44 +++++++++++++ tooling/car/unixfs.go | 4 ++ tooling/check/check.go | 10 +-- 4 files changed, 103 insertions(+), 50 deletions(-) create mode 100644 tooling/car/fixture.go diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index d972298b4..50d4426b1 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -415,15 +415,6 @@ func TestPlainCodec(t *testing.T) { Contains("%s; filename=\"%s.%s\"", row.Disposition, plainOrDagCID, row.Format), Header("Content-Type"). Contains("application/vnd.ipld.dag-%s", row.Format), - // TODO: decoding the block as raw data doesn't return JSON. - // We have to port parts of the DAG get code from KUBO - // We might be able to reuse the `merkledag` module, if - // we come up with the `legacy.Register` and `format.Register` - // encoders to use for JSON and Dag JSON. - // - // We want to implement someting like: - //).Body( - // IsJSONEqual(plainOrDagFixture.RawData()), ).Body( row.Checker(d), ), @@ -473,9 +464,12 @@ func TestPathing(t *testing.T) { Path("ipfs/%s/foo/link/bar", dagJSONTraversalCID). Query("format", "dag-json"), Response: Expect(). - Status(200), - // TODO: fix loading blocks into JSON: - // Body(IsJSONEqual(`{"hello": "this is not a link"}`)), + Status(200). + Body( + // TODO: I like that this text is readable and easy to understand. + // but we might prefer matching abstract values, something like "IsJSONEqual(someFixture.formatedAsJSON))" + IsJSONEqual([]byte(`{"hello": "this is not a link"}`)), + ), }, /** test_expect_success "GET DAG-CBOR traversal returns 501 if there is path remainder" ' @@ -507,9 +501,12 @@ func TestPathing(t *testing.T) { Path("ipfs/%s/foo/link/bar", dagCBORTraversalCID). Query("format", "dag-json"), Response: Expect(). - Status(200), - // TODO: fix loading blocks into JSON: - // Body(IsJSONEqual(`{"hello": "this is not a link"}`)), + Status(200). + Body( + // TODO: I like that this text is readable and easy to understand. + // but we might prefer matching abstract values, something like "IsJSONEqual(someFixture.formatedAsJSON))" + IsJSONEqual([]byte(`{"hello": "this is not a link"}`)), + ), }, } @@ -519,15 +516,16 @@ func TestPathing(t *testing.T) { // ## NATIVE TESTS for DAG-JSON (0x0129) and DAG-CBOR (0x71): // ## DAG- regression tests for core behaviors when native DAG-(CBOR|JSON) is requested func TestNativeDag(t *testing.T) { - missingCID := "" // TODO: generate + missingCID := car.RandomCID() table := []struct { Name string Format string Disposition string + Checker func(value []byte) Check[[]byte] }{ - {"plain JSON codec", "json", "inline"}, - {"plain CBOR codec", "cbor", "attachment"}, + {"plain JSON codec", "json", "inline", IsJSONEqual}, + {"plain CBOR codec", "cbor", "attachment", IsEqualBytes}, } for _, row := range table { @@ -542,6 +540,12 @@ func TestNativeDag(t *testing.T) { // plainCID := plainFixture.Cid() // plainOrDagCID := plainOrDagFixture.Cid() + node, err := legacy.DecodeNode(context.Background(), dagTraversal) + if err != nil { + panic(err) + } + formatted := car.FormatDagNode(node, "dag-" + row.Format) + tests := SugarTests{ /** # GET without explicit format and Accept: text/html returns raw block @@ -558,9 +562,10 @@ func TestNativeDag(t *testing.T) { Request: Request(). Path("ipfs/%s", dagTraversalCID), Response: Expect(). - Status(200), - // TODO: make this work by loading the block with the right codec: - // Body(IsJSONEqual(dagTraversal.RawData())), + Status(200). + Body( + row.Checker(formatted), + ), }, /** # GET dag-cbor block via Accept and ?format and ensure both are the same as `ipfs block get` output @@ -578,9 +583,10 @@ func TestNativeDag(t *testing.T) { Path("ipfs/%s", dagTraversalCID). Query("format", fmt.Sprintf("dag-%s", row.Format)), Response: Expect(). - Status(200), - // TODO: make this work by loading the block with the right codec: - // Body(IsJSONEqual(dagTraversal.RawData())), + Status(200). + Body( + row.Checker(formatted), + ), }, /** test_expect_success "GET $name from /ipfs for application/$format returns the same payload as format=dag-$format" ' @@ -589,15 +595,7 @@ func TestNativeDag(t *testing.T) { test_cmp expected plain_output ' */ - { - Name: fmt.Sprintf("GET %s from /ipfs for application/%s returns the same payload as format=dag-%s", row.Name, row.Format, row.Format), - Request: Request(). - Path("ipfs/%s", dagTraversalCID). - Query("format", row.Format), - Response: Expect(). - Status(200), - // TODO: equalities between requests => REPLACE WITH AN ACTUAL EXPECTED RESPONSES. - }, + // TODO(lidel): Note we disable this test, we check the payloads above. /** test_expect_success "GET $name from /ipfs with application/vnd.ipld.dag-$format returns the same payload as the raw block" ' ipfs block get "/ipfs/$CID" > expected_block && @@ -611,9 +609,10 @@ func TestNativeDag(t *testing.T) { Path("ipfs/%s", dagTraversalCID). Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), Response: Expect(). - Status(200), - // TODO: make this work by loading the block with the right codec: - // Body(IsJSONEqual(dagTraversal.RawData())), + Status(200). + Body( + row.Checker(formatted), + ), }, /** # Make sure DAG-* can be requested as plain JSON or CBOR and response has plain Content-Type for interop purposes @@ -633,8 +632,10 @@ func TestNativeDag(t *testing.T) { Query("format", row.Format), Response: Expect(). Status(200). - Header(Header("Content-Type", "application/%s", row.Format)), - // TODO: equalities between requests. + Header(Header("Content-Type", "application/%s", row.Format)). + Body( + row.Checker(formatted), + ), }, /** test_expect_success "GET $name with Accept: application/$format returns same payload as application/vnd.ipld.dag-$format but with plain Content-Type" ' @@ -651,8 +652,10 @@ func TestNativeDag(t *testing.T) { Header("Accept", "application/%s", row.Format), Response: Expect(). Status(200). - Header(Header("Content-Type", "application/%s", row.Format)), - // TODO: equalities between requests. + Header(Header("Content-Type", "application/%s", row.Format)). + Body( + row.Checker(formatted), + ), }, /** # Make sure expected HTTP headers are returned with the dag- block @@ -699,7 +702,11 @@ func TestNativeDag(t *testing.T) { Query("filename", fmt.Sprintf("foobar.%s", row.Format)). Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), Response: Expect(). - Header(Header("Content-Disposition").Hint("includes Content-Disposition").Contains("%s; filename=\"foobar.%s\"", row.Disposition, row.Format)), + Headers( + Header("Content-Disposition"). + Hint("includes Content-Disposition"). + Contains("%s; filename=\"foobar.%s\"", row.Disposition, row.Format), + ), }, /** test_expect_success "GET for application/vnd.ipld.dag-$format with ?download=true forces Content-Disposition: attachment" ' @@ -715,7 +722,11 @@ func TestNativeDag(t *testing.T) { Query("download", "true"). Header("Accept", fmt.Sprintf("application/vnd.ipld.dag-%s", row.Format)), Response: Expect(). - Header(Header("Content-Disposition").Hint("includes Content-Disposition").Contains("attachment; filename=\"foobar.%s\"", row.Format)), + Headers( + Header("Content-Disposition"). + Hint("includes Content-Disposition"). + Contains("attachment; filename=\"foobar.%s\"", row.Format), + ), }, /** # Cache control HTTP headers diff --git a/tooling/car/fixture.go b/tooling/car/fixture.go new file mode 100644 index 000000000..ef2e4c1bc --- /dev/null +++ b/tooling/car/fixture.go @@ -0,0 +1,44 @@ +package car + +import ( + "time" + + "github.com/ipfs/go-cid" + format "github.com/ipfs/go-ipld-format" + "github.com/ipld/go-ipld-prime" + "github.com/multiformats/go-multihash" +) + +type FixtureNode struct { + node format.Node +} + +// get cid method +func (n *FixtureNode) Cid() cid.Cid { + return n.node.Cid() +} + +// get raw data method +func (n *FixtureNode) RawData() []byte { + return n.node.RawData() +} + +// get formated node (pass codec name as parameter) +func (n *FixtureNode) Formatted(codecStr string) []byte { + node := n.node.(ipld.Node) + return FormatDagNode(node, codecStr) +} + +func RandomCID() cid.Cid { + now := time.Now().UTC() + timeBytes := []byte(now.Format(time.RFC3339)) + + mh, err := multihash.Sum(timeBytes, multihash.SHA2_256, -1) + if err != nil { + panic(err) + } + + c := cid.NewCidV1(cid.Raw, mh) + + return c +} \ No newline at end of file diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index dd597adb4..9eb969eaa 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -99,6 +99,10 @@ func (d *UnixfsDag) mustGetNode(names ...string) format.Node { return node } +func (d *UnixfsDag) MustGetNode(names ...string) *FixtureNode { + return &FixtureNode{node: d.mustGetNode(names...)} +} + func (d *UnixfsDag) MustGetCid(names ...string) string { return d.mustGetNode(names...).Cid().String() } diff --git a/tooling/check/check.go b/tooling/check/check.go index 91d5a8623..2741f0d57 100644 --- a/tooling/check/check.go +++ b/tooling/check/check.go @@ -280,24 +280,18 @@ type CheckIsJSONEqual struct { } func IsJSONEqual(value []byte) Check[[]byte] { - var result map[string]any + var result interface{} err := json.Unmarshal(value, &result) if err != nil { panic(err) // TODO: move a t.Testing around to `t.Fatal` this case } - fmt.Println("result:", result) - return &CheckIsJSONEqual{ - Value: value, + Value: result, } } func (c *CheckIsJSONEqual) Check(v []byte) CheckOutput { - fmt.Println("checked value:", string(v)) - - fmt.Println("checking", string(v), "against", c.Value) - var o map[string]any err := json.Unmarshal(v, &o) if err != nil { From de1955211d174ac655fd5fa432b27f42b3d50442 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 31 Mar 2023 11:11:28 +0200 Subject: [PATCH 18/23] refactor: start cleaning the API usage --- tests/t0123_gateway_json_cbor_test.go | 13 ++++++++----- tooling/car/unixfs.go | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 50d4426b1..4d08147ed 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -80,9 +80,12 @@ func TestGatewayJsonCbor(t *testing.T) { func TestDAgPbConversion(t *testing.T) { fixture := car.MustOpenUnixfsCar("t0123-gateway-json-cbor.car") - dirCID := fixture.MustGetCid() // root dir - fileCID := fixture.MustGetCid("ą", "ę", "file-źł.txt") - fileData := fixture.MustGetRawData("ą", "ę", "file-źł.txt") + dir := fixture.MustGetRoot() + file := fixture.MustGetNode("ą", "ę", "file-źł.txt") + + dirCID := dir.Cid() + fileCID := file.Cid() + fileData := file.RawData() table := []struct { Name string @@ -95,8 +98,8 @@ func TestDAgPbConversion(t *testing.T) { for _, row := range table { // ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output - formatedFile := fixture.MustGetFormattedDagNode("dag-"+row.Format, "ą", "ę", "file-źł.txt") - formatedDir := fixture.MustGetFormattedDagNode("dag-" + row.Format) + formatedFile := file.Formatted("dag-"+row.Format) + formatedDir := dir.Formatted("dag-" + row.Format) tests := SugarTests{ /** diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 9eb969eaa..c44acd618 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -103,6 +103,10 @@ func (d *UnixfsDag) MustGetNode(names ...string) *FixtureNode { return &FixtureNode{node: d.mustGetNode(names...)} } +func (d *UnixfsDag) MustGetRoot() *FixtureNode { + return d.MustGetNode() +} + func (d *UnixfsDag) MustGetCid(names ...string) string { return d.mustGetNode(names...).Cid().String() } From 85f79432bd7c1d89a42b75f7aee2f8304c1b9e60 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 31 Mar 2023 11:17:49 +0200 Subject: [PATCH 19/23] refactor: continue simlif usage - drop raw block --- tests/t0123_gateway_json_cbor_test.go | 63 ++++++++------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 4d08147ed..7bdb304aa 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -1,7 +1,6 @@ package tests import ( - "context" "fmt" "testing" @@ -9,7 +8,6 @@ import ( . "github.com/ipfs/gateway-conformance/tooling/check" "github.com/ipfs/gateway-conformance/tooling/test" . "github.com/ipfs/gateway-conformance/tooling/test" - legacy "github.com/ipfs/go-ipld-legacy" ) func TestGatewayJsonCbor(t *testing.T) { @@ -98,7 +96,7 @@ func TestDAgPbConversion(t *testing.T) { for _, row := range table { // ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output - formatedFile := file.Formatted("dag-"+row.Format) + formatedFile := file.Formatted("dag-" + row.Format) formatedDir := dir.Formatted("dag-" + row.Format) tests := SugarTests{ @@ -279,24 +277,12 @@ func TestPlainCodec(t *testing.T) { } for _, row := range table { - plainFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain.%s.car", row.Format)) - plainOrDagFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain-that-can-be-dag.%s.car", row.Format)) - - plainCID := plainFixture.Cid() - plainOrDagCID := plainOrDagFixture.Cid() - - // We want to implement the equivalent of: - // CID=$(echo "{ \"test\": \"plain-json-that-can-also-be-dag-json\" }" | ipfs dag put --input-codec json --store-codec $format) && - // ipfs dag get --output-codec dag-$format $CID > ipfs_dag_get_output 2>&1 && - // test_cmp ipfs_dag_get_output curl_output_param && - g, err := legacy.DecodeNode(context.Background(), plainOrDagFixture) - if err != nil { - t.Fatal(err) - } - - d := car.FormatDagNode(g, "dag-"+row.Format) + plain := car.MustOpenUnixfsCar(fmt.Sprintf("t0123/plain.%s.car", row.Format)).MustGetRoot() + plainOrDag := car.MustOpenUnixfsCar(fmt.Sprintf("t0123/plain-that-can-be-dag.%s.car", row.Format)).MustGetRoot() + formatted := plainOrDag.Formatted("dag-" + row.Format) - fmt.Println("d:", row.Format, d, string(d)) + plainCID := plain.Cid() + plainOrDagCID := plainOrDag.Cid() tests := SugarTests{ /** @@ -325,7 +311,7 @@ func TestPlainCodec(t *testing.T) { Header("Content-Type"). Contains(fmt.Sprintf("application/%s", row.Format)), ).Body( - plainFixture.RawData(), + plain.RawData(), ), }, /** @@ -355,7 +341,7 @@ func TestPlainCodec(t *testing.T) { Header("Content-Type"). Contains("application/%s", row.Format), ).Body( - plainFixture.RawData(), + plain.RawData(), ), }, /** @@ -385,7 +371,7 @@ func TestPlainCodec(t *testing.T) { Header("Content-Type"). Contains("application/%s", row.Format), ).Body( - plainFixture.RawData(), + plain.RawData(), ), }, /** @@ -419,7 +405,7 @@ func TestPlainCodec(t *testing.T) { Header("Content-Type"). Contains("application/vnd.ipld.dag-%s", row.Format), ).Body( - row.Checker(d), + row.Checker(formatted), ), }, } @@ -430,8 +416,8 @@ func TestPlainCodec(t *testing.T) { // ## Pathing, traversal over DAG-JSON and DAG-CBOR func TestPathing(t *testing.T) { - dagJSONTraversal := car.MustOpenRawBlockFromCar("t0123/dag-json-traversal.car") - dagCBORTraversal := car.MustOpenRawBlockFromCar("t0123/dag-cbor-traversal.car") + dagJSONTraversal := car.MustOpenUnixfsCar("t0123/dag-json-traversal.car").MustGetRoot() + dagCBORTraversal := car.MustOpenUnixfsCar("t0123/dag-cbor-traversal.car").MustGetRoot() dagJSONTraversalCID := dagJSONTraversal.Cid() dagCBORTraversalCID := dagCBORTraversal.Cid() @@ -532,22 +518,9 @@ func TestNativeDag(t *testing.T) { } for _, row := range table { - dagTraversal := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/dag-%s-traversal.car", row.Format)) + dagTraversal := car.MustOpenUnixfsCar(fmt.Sprintf("t0123/dag-%s-traversal.car", row.Format)).MustGetRoot() dagTraversalCID := dagTraversal.Cid() - // using unix fs / merkledag loader: - // could not choose a decoder: no decoder registered for multicodec code 113 (0x71) - - // plainFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain.%s.car", row.Format)) - // plainOrDagFixture := car.MustOpenRawBlockFromCar(fmt.Sprintf("t0123/plain-that-can-be-dag.%s.car", row.Format)) - - // plainCID := plainFixture.Cid() - // plainOrDagCID := plainOrDagFixture.Cid() - - node, err := legacy.DecodeNode(context.Background(), dagTraversal) - if err != nil { - panic(err) - } - formatted := car.FormatDagNode(node, "dag-" + row.Format) + formatted := dagTraversal.Formatted("dag-" + row.Format) tests := SugarTests{ /** @@ -707,8 +680,8 @@ func TestNativeDag(t *testing.T) { Response: Expect(). Headers( Header("Content-Disposition"). - Hint("includes Content-Disposition"). - Contains("%s; filename=\"foobar.%s\"", row.Disposition, row.Format), + Hint("includes Content-Disposition"). + Contains("%s; filename=\"foobar.%s\"", row.Disposition, row.Format), ), }, /** @@ -727,8 +700,8 @@ func TestNativeDag(t *testing.T) { Response: Expect(). Headers( Header("Content-Disposition"). - Hint("includes Content-Disposition"). - Contains("attachment; filename=\"foobar.%s\"", row.Format), + Hint("includes Content-Disposition"). + Contains("attachment; filename=\"foobar.%s\"", row.Format), ), }, /** From 3b1e7172e3704ba9d7b8289a28ed7149149b6e6f Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 31 Mar 2023 11:20:27 +0200 Subject: [PATCH 20/23] refactor: done cleaning the API usage in 123 --- tests/t0123_gateway_json_cbor_test.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 7bdb304aa..935ac6b8c 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -13,17 +13,9 @@ import ( func TestGatewayJsonCbor(t *testing.T) { fixture := car.MustOpenUnixfsCar("t0123-gateway-json-cbor.car") - dirCID := fixture.MustGetCid() // root dir - fileJSONCID := fixture.MustGetCid("ą", "ę", "t.json") - fileJSONData := fixture.MustGetRawData("ą", "ę", "t.json") - fileCID := fixture.MustGetCid("ą", "ę", "file-źł.txt") - fileSize := len(fixture.MustGetRawData("ą", "ę", "file-źł.txt")) - - fmt.Println("rootDirCID:", dirCID) - fmt.Println("fileJSONCID:", fileJSONCID) - fmt.Println("fileJSONData:", fileJSONData) - fmt.Println("fileCID:", fileCID) - fmt.Println("fileSize:", fileSize) + fileJSON := fixture.MustGetNode("ą", "ę", "t.json") + fileJSONCID := fileJSON.Cid() + fileJSONData := fileJSON.RawData() tests := SugarTests{ { From fbd32ec3b5bc03460f2eb27100f094a0128a25c6 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 31 Mar 2023 11:21:12 +0200 Subject: [PATCH 21/23] fix: remove dead code --- tooling/car/unixfs.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index c44acd618..97286945f 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -13,7 +13,6 @@ import ( "github.com/ipfs/boxo/ipld/merkledag" "github.com/ipfs/boxo/ipld/unixfs/io" "github.com/ipfs/gateway-conformance/tooling/fixtures" - blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" format "github.com/ipfs/go-ipld-format" "github.com/ipld/go-ipld-prime" @@ -151,30 +150,4 @@ func MustOpenUnixfsCar(file string) *UnixfsDag { os.Exit(1) } return dag -} - -func newBlockFromCar(file string) (blocks.Block, error) { - bs, err := blockstore.OpenReadOnly(file) - if err != nil { - return nil, err - } - root, err := bs.Roots() - if err != nil { - return nil, err - } - if len(root) != 1 { - return nil, fmt.Errorf("expected 1 root, got %d", len(root)) - } - return bs.Get(context.Background(), root[0]) -} - -func MustOpenRawBlockFromCar(file string) blocks.Block { - fixturePath := path.Join(fixtures.Dir(), file) - - block, err := newBlockFromCar(fixturePath) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - return block -} +} \ No newline at end of file From 5955bd7cadc9ef3e4a590b20eac34692fb8f9e0c Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 3 Apr 2023 12:22:34 +0200 Subject: [PATCH 22/23] fix: t0123 - query usage --- tests/t0123_gateway_json_cbor_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/t0123_gateway_json_cbor_test.go b/tests/t0123_gateway_json_cbor_test.go index 935ac6b8c..67652a7ed 100644 --- a/tests/t0123_gateway_json_cbor_test.go +++ b/tests/t0123_gateway_json_cbor_test.go @@ -105,7 +105,8 @@ func TestDAgPbConversion(t *testing.T) { { Name: fmt.Sprintf("GET UnixFS file as %s with format=dag-%s converts to the expected Content-Type", row.Name, row.Format), Request: Request(). - Path("ipfs/%s?format=dag-%s", fileCID, row.Format), + Path("ipfs/%s", fileCID). + Query("format", "dag-"+row.Format), Response: Expect(). Status(200). Headers( From db7ee9ce7c5603a241c38fb4a1aef3e98dec7e67 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 3 Apr 2023 12:24:10 +0200 Subject: [PATCH 23/23] fix: t0123 - remove init --- tooling/car/unixfs.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tooling/car/unixfs.go b/tooling/car/unixfs.go index 97286945f..797889834 100644 --- a/tooling/car/unixfs.go +++ b/tooling/car/unixfs.go @@ -1,5 +1,8 @@ package car +// Note we force imports of dagcbor, dagjson, and other codecs below. +// They are registering themselves with the multicodec package +// during their `init()`. import ( "bytes" "context" @@ -24,12 +27,6 @@ import ( mc "github.com/multiformats/go-multicodec" ) -func init() { - // Note we force imports of dagcbor and dagjson above. - // They are registering themselves with the multicodec package - // during their `init()`. -} - type UnixfsDag struct { dsvc format.DAGService cid cid.Cid @@ -150,4 +147,4 @@ func MustOpenUnixfsCar(file string) *UnixfsDag { os.Exit(1) } return dag -} \ No newline at end of file +}