From 9de2cbc30c8b024fa419c6139f1bc5a85bc43b54 Mon Sep 17 00:00:00 2001 From: Oleg Lomaka Date: Sat, 13 Jan 2024 10:33:49 -0500 Subject: [PATCH 1/3] getting rid of the unsupported 'github.com/ipfs/go-ipfs-api' package and replacing it with an equivalent interface --- go.mod | 24 ---------------- go.sum | 57 -------------------------------------- loaders/document_loader.go | 9 ++++-- merklize/merklize.go | 5 ++-- merklize/merklize_test.go | 51 +++++++++++++--------------------- 5 files changed, 28 insertions(+), 118 deletions(-) diff --git a/go.mod b/go.mod index d03891d..a79d962 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/iden3/go-iden3-core/v2 v2.0.3 github.com/iden3/go-iden3-crypto v0.0.15 github.com/iden3/go-merkletree-sql/v2 v2.0.4 - github.com/ipfs/go-ipfs-api v0.7.0 // We require the `json-gold` bugfix which has not yet been included in the // stable version. After the release of version 0.5.1 or later, it will be // necessary to update to the stable version. @@ -20,33 +19,10 @@ require ( ) require ( - github.com/benbjohnson/clock v1.3.5 // indirect - github.com/blang/semver/v4 v4.0.0 // indirect - github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dchest/blake512 v1.0.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect - github.com/ipfs/boxo v0.12.0 // indirect - github.com/ipfs/go-cid v0.4.1 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-flow-metrics v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.26.3 // indirect - github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/go-homedir v1.1.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-multiaddr v0.9.0 // indirect - github.com/multiformats/go-multibase v0.2.0 // indirect - github.com/multiformats/go-multicodec v0.9.0 // indirect - github.com/multiformats/go-multihash v0.2.3 // indirect - github.com/multiformats/go-multistream v0.4.1 // indirect - github.com/multiformats/go-varint v0.0.7 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/spaolacci/murmur3 v1.1.0 // indirect golang.org/x/sys v0.8.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index 4f85326..baf7afd 100644 --- a/go.sum +++ b/go.sum @@ -1,63 +1,16 @@ -github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= -github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= -github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= -github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg= -github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE= 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/dchest/blake512 v1.0.0 h1:oDFEQFIqFSeuA34xLtXZ/rWxCXdSjirjzPhey5EUvmA= github.com/dchest/blake512 v1.0.0/go.mod h1:FV1x7xPPLWukZlpDpWQ88rF/SFwZ5qbskrzhLMB92JI= -github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/iden3/go-iden3-core/v2 v2.0.3 h1:ce9Jbw10zDsinWXFc05SiK2Hof/wu4zV4/ai5gQy29k= github.com/iden3/go-iden3-core/v2 v2.0.3/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= github.com/iden3/go-iden3-crypto v0.0.15 h1:4MJYlrot1l31Fzlo2sF56u7EVFeHHJkxGXXZCtESgK4= github.com/iden3/go-iden3-crypto v0.0.15/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/iden3/go-merkletree-sql/v2 v2.0.4 h1:Dp089P3YNX1BE8+T1tKQHWTtnk84Y/Kr7ZAGTqwscoY= github.com/iden3/go-merkletree-sql/v2 v2.0.4/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk= -github.com/ipfs/boxo v0.12.0 h1:AXHg/1ONZdRQHQLgG5JHsSC3XoE4DjCAMgK+asZvUcQ= -github.com/ipfs/boxo v0.12.0/go.mod h1:xAnfiU6PtxWCnRqu7dcXQ10bB5/kvI1kXRotuGqGBhg= -github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= -github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= -github.com/ipfs/go-ipfs-api v0.7.0 h1:CMBNCUl0b45coC+lQCXEVpMhwoqjiaCwUIrM+coYW2Q= -github.com/ipfs/go-ipfs-api v0.7.0/go.mod h1:AIxsTNB0+ZhkqIfTZpdZ0VR/cpX5zrXjATa3prSay3g= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= -github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= -github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.26.3 h1:6g/psubqwdaBqNNoidbRKSTBEYgaOuKBhHl8Q5tO+PM= -github.com/libp2p/go-libp2p v0.26.3/go.mod h1:x75BN32YbwuY0Awm2Uix4d4KOz+/4piInkp4Wr3yOo8= -github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= -github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= -github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= -github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= -github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= -github.com/multiformats/go-multiaddr v0.9.0 h1:3h4V1LHIk5w4hJHekMKWALPXErDfz/sggzwC/NcqbDQ= -github.com/multiformats/go-multiaddr v0.9.0/go.mod h1:mI67Lb1EeTOYb8GQfL/7wpIZwc46ElrvzhYnoJOmTT0= -github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= -github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= -github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= -github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= -github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= -github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= -github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= -github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= -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/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f h1:HlPa7RcxTCrva5izPfTEfvYecO7LTahgmMRD1Qp13xg= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -68,23 +21,13 @@ github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 h1:J9b7z+QKAm github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 h1:uIkTLo0AGRc8l7h5l9r+GcYi9qfVPt6lD4/bhmzfiKo= github.com/santhosh-tekuri/jsonschema/v5 v5.3.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= diff --git a/loaders/document_loader.go b/loaders/document_loader.go index 35ba4be..29ca484 100644 --- a/loaders/document_loader.go +++ b/loaders/document_loader.go @@ -9,7 +9,6 @@ import ( "strings" "time" - shell "github.com/ipfs/go-ipfs-api" "github.com/piprate/json-gold/ld" "github.com/pquerna/cachecontrol" ) @@ -31,8 +30,12 @@ type CacheEngine interface { Set(key string, doc *ld.RemoteDocument, expireTime time.Time) error } +type IPFSClient interface { + Cat(url string) (io.ReadCloser, error) +} + type documentLoader struct { - ipfsCli *shell.Shell + ipfsCli IPFSClient // @formatter:off : Goland bug ipfsGW string cacheEngine CacheEngine noCache bool @@ -60,7 +63,7 @@ func WithHTTPClient(httpClient *http.Client) DocumentLoaderOption { // NewDocumentLoader creates a new document loader with a cache for http. // ipfs cache is not implemented yet. -func NewDocumentLoader(ipfsCli *shell.Shell, ipfsGW string, +func NewDocumentLoader(ipfsCli IPFSClient, ipfsGW string, opts ...DocumentLoaderOption) ld.DocumentLoader { loader := &documentLoader{ ipfsCli: ipfsCli, diff --git a/merklize/merklize.go b/merklize/merklize.go index ed56833..9be7efb 100644 --- a/merklize/merklize.go +++ b/merklize/merklize.go @@ -18,7 +18,6 @@ import ( "github.com/iden3/go-merkletree-sql/v2" "github.com/iden3/go-merkletree-sql/v2/db/memory" "github.com/iden3/go-schema-processor/v2/loaders" - shell "github.com/ipfs/go-ipfs-api" "github.com/piprate/json-gold/ld" ) @@ -1462,7 +1461,7 @@ type Merklizer struct { entries map[string]RDFEntry hasher Hasher safeMode bool - ipfsCli *shell.Shell + ipfsCli loaders.IPFSClient // @formatter:off : Goland bug ipfsGW string documentLoader ld.DocumentLoader } @@ -1498,7 +1497,7 @@ func WithSafeMode(safeMode bool) MerklizeOption { // WithIPFSClient sets IPFS client option required to resolve ipfs:// contexts. // It works only if documentLoader is not set using WithDocumentLoader option. // Otherwise, it will be ignored. -func WithIPFSClient(ipfsCli *shell.Shell) MerklizeOption { +func WithIPFSClient(ipfsCli loaders.IPFSClient) MerklizeOption { return func(m *Merklizer) { m.ipfsCli = ipfsCli } diff --git a/merklize/merklize_test.go b/merklize/merklize_test.go index 5ca62e7..11a1a40 100644 --- a/merklize/merklize_test.go +++ b/merklize/merklize_test.go @@ -4,7 +4,9 @@ import ( "bytes" "context" "encoding/json" + "errors" "fmt" + "io" "math" "math/big" "os" @@ -21,7 +23,6 @@ import ( "github.com/iden3/go-merkletree-sql/v2/db/memory" "github.com/iden3/go-schema-processor/v2/loaders" tst "github.com/iden3/go-schema-processor/v2/testing" - shell "github.com/ipfs/go-ipfs-api" "github.com/piprate/json-gold/ld" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -1930,50 +1931,38 @@ const ipfsDocument = `{ ] }` -func uploadIPFSFile(t testing.TB, ipfsCli *shell.Shell, fName string) string { - f, err := os.Open(fName) - require.NoError(t, err) - // no need to close f - - // Context is a pure file (no directory) - cid, err := ipfsCli.Add(f) - require.NoError(t, err) +type mockIPFSLoader map[string]string - return cid +func (m mockIPFSLoader) Cat(url string) (io.ReadCloser, error) { + fName, ok := m[url] + if !ok { + return nil, errors.New("not found") + } + return os.Open(fName) } func TestIPFSContext(t *testing.T) { - ipfsURL := os.Getenv("IPFS_URL") - if ipfsURL == "" { - t.Skip("IPFS_URL is not set") - } + + citizenshipCtx := "Qmbp4kwoHULnmK71abrxdksjPH5sAjxSAXU5PEp2XRMFNw/dir2/bbs-v2.jsonld" + bbsCtx := "QmdP4MZkESEabRVB322r2xWm7TCi7LueMNWMJawYmSy7hp" defer tst.MockHTTPClient(t, testDocumentIPFSURLMaps, tst.IgnoreUntouchedURLs())() - ipfsCli := shell.NewShell(ipfsURL) - - // Context inside some directory - bbsCtx, err := ipfsCli.AddDir("testdata/ipfs/dir1") - require.NoError(t, err) - bbsCtx = "ipfs://" + bbsCtx + "/dir2/bbs-v2.jsonld" - - citizenshipCtx := uploadIPFSFile(t, ipfsCli, - "testdata/ipfs/citizenship-v1.jsonld") - citizenshipCtx = "ipfs://" + citizenshipCtx + ipfsCli := mockIPFSLoader{ + citizenshipCtx: "testdata/ipfs/dir1/dir2/bbs-v2.jsonld", + bbsCtx: "testdata/ipfs/citizenship-v1.jsonld", + "QmeMevwUeD7o6hjfmdaeFD1q4L84hSDiRjeXZLi1bZK1My": "testdata/ipfs/testNewType.jsonld", + } tmpl := template.Must(template.New("").Parse(ipfsDocument)) b := bytes.NewBuffer(nil) - err = tmpl.Execute(b, map[string]interface{}{ - "CitizenshipContext": citizenshipCtx, - "BBSContext": bbsCtx, + err := tmpl.Execute(b, map[string]interface{}{ + "CitizenshipContext": "ipfs://" + citizenshipCtx, + "BBSContext": "ipfs://" + bbsCtx, }) require.NoError(t, err) - cid := uploadIPFSFile(t, ipfsCli, "testdata/ipfs/testNewType.jsonld") - // CID should be equal to the on in `testDocumentIPFS` document - require.Equal(t, "QmeMevwUeD7o6hjfmdaeFD1q4L84hSDiRjeXZLi1bZK1My", cid) - ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel() From a67187d3d70601df3823fcfa1a27c9001a14fc11 Mon Sep 17 00:00:00 2001 From: Oleg Lomaka Date: Sat, 13 Jan 2024 10:36:17 -0500 Subject: [PATCH 2/3] fix linters: gofmt --- merklize/merklize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merklize/merklize.go b/merklize/merklize.go index 9be7efb..f1a1c59 100644 --- a/merklize/merklize.go +++ b/merklize/merklize.go @@ -1461,7 +1461,7 @@ type Merklizer struct { entries map[string]RDFEntry hasher Hasher safeMode bool - ipfsCli loaders.IPFSClient // @formatter:off : Goland bug + ipfsCli loaders.IPFSClient // @formatter:off : Goland bug ipfsGW string documentLoader ld.DocumentLoader } From 3567843d930e0daf0712a25b94b3e15d9ff717d6 Mon Sep 17 00:00:00 2001 From: Oleg Lomaka Date: Tue, 16 Jan 2024 02:28:11 -0500 Subject: [PATCH 3/3] rename swapped vars --- merklize/merklize_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/merklize/merklize_test.go b/merklize/merklize_test.go index 11a1a40..8477498 100644 --- a/merklize/merklize_test.go +++ b/merklize/merklize_test.go @@ -1889,7 +1889,7 @@ const ipfsDocument = `{ "@context": [ "https://www.w3.org/2018/credentials/v1", "{{ .CitizenshipContext }}", - "{{ .BBSContext }}" + "{{ .BBSContext }}" ], "id": "https://issuer.oidp.uscis.gov/credentials/83627465", "type": ["VerifiableCredential", "PermanentResidentCard"], @@ -1943,15 +1943,15 @@ func (m mockIPFSLoader) Cat(url string) (io.ReadCloser, error) { func TestIPFSContext(t *testing.T) { - citizenshipCtx := "Qmbp4kwoHULnmK71abrxdksjPH5sAjxSAXU5PEp2XRMFNw/dir2/bbs-v2.jsonld" - bbsCtx := "QmdP4MZkESEabRVB322r2xWm7TCi7LueMNWMJawYmSy7hp" + bbsCtx := "Qmbp4kwoHULnmK71abrxdksjPH5sAjxSAXU5PEp2XRMFNw/dir2/bbs-v2.jsonld" + citizenshipCtx := "QmdP4MZkESEabRVB322r2xWm7TCi7LueMNWMJawYmSy7hp" defer tst.MockHTTPClient(t, testDocumentIPFSURLMaps, tst.IgnoreUntouchedURLs())() ipfsCli := mockIPFSLoader{ - citizenshipCtx: "testdata/ipfs/dir1/dir2/bbs-v2.jsonld", - bbsCtx: "testdata/ipfs/citizenship-v1.jsonld", + bbsCtx: "testdata/ipfs/dir1/dir2/bbs-v2.jsonld", + citizenshipCtx: "testdata/ipfs/citizenship-v1.jsonld", "QmeMevwUeD7o6hjfmdaeFD1q4L84hSDiRjeXZLi1bZK1My": "testdata/ipfs/testNewType.jsonld", }