All test stuff #88

Merged
ABastionOfSanity merged 29 commits from all_test_stuff into main 2023-01-30 21:59:14 +00:00
Showing only changes of commit cac9fe327c - Show all commits

View File

@ -7,6 +7,7 @@ package utils
import ( import (
"bytes" "bytes"
"errors" "errors"
canonicalJson "github.com/gibson042/canonicaljson-go" canonicalJson "github.com/gibson042/canonicaljson-go"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
@ -66,10 +67,9 @@ func GetAttributeAsString(obj map[string]interface{}, attr string) (string, erro
} }
// CIDFromJSONBytesUsingIpldPrime returns CID (dagcbor) for json (as bytes). // CIDFromJSONBytesUsingIpldPrime returns CID (dagcbor) for json (as bytes).
// This is combination of samples for unmarshalling and linking
// see: https://pkg.go.dev/github.com/ipld/go-ipld-prime
func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) { func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
//This is combination of samples for unmarshalling and linking
//see: https://pkg.go.dev/github.com/ipld/go-ipld-prime
np := basicnode.Prototype.Any // Pick a stle for the in-memory data. np := basicnode.Prototype.Any // Pick a stle for the in-memory data.
nb := np.NewBuilder() // Create a builder. nb := np.NewBuilder() // Create a builder.
err := dagjson.Decode(nb, bytes.NewReader(content)) // Hand the builder to decoding -- decoding will fill it in! err := dagjson.Decode(nb, bytes.NewReader(content)) // Hand the builder to decoding -- decoding will fill it in!
@ -105,6 +105,6 @@ func CIDFromJSONBytesUsingIpldPrime(content []byte) (string, error) {
if err != nil { if err != nil {
return "", err return "", err
} }
//return cborcid.String(), nil // return cborcid.String(), nil
return lnk.String(), nil return lnk.String(), nil
} }