ceramicnetwork / go-dag-jose Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I've attempted to bump the go-ipld-prime
version in the go.mod file to v0.12.0
and found one test failure.
It appears to be related to stability of order of contents encoded by using dag-cbor. This changed in [email protected]
: the dag-cbor codec now forces map key sorting when encoding. (Some people consider this a regression, and I frankly even agree, but have been out-voted on it.)
I suspect this isn't a major behavioural problem, and doesn't affect any downstreams, but a test failure is a test failure :)
The fulltext of the test failure is below:
--- FAIL: TestRoundTripArbitraryJOSE (1.70s)
dagjose_test.go:463: [rapid] failed after 0 tests: (*T).FailNow() called
To reproduce, specify -run="TestRoundTripArbitraryJOSE" -rapid.seed=1629884721185674694
Failed test output:
dagjose_test.go:464: [rapid] draw An arbitrary JOSE object: &dagjose.DagJOSE{payload:(*cid.Cid)(nil), signatures:[]dagjose.jwsSignature(nil), protected:[]uint8{}, unprotected:[]uint8{}, iv:[]uint8{}, aad:[]uint8(nil), ciphertext:[]uint8{}, tag:[]uint8(nil), recipients:[]dagjose.jweRecipient{dagjose.jweRecipient{header:map[string]ipld.Node{"":(*basicnode.plainMap)(0xc000c0da20)}, encrypted_key:[]uint8(nil)}}}
dagjose_test.go:466:
Error Trace: dagjose_test.go:466
engine.go:203
engine.go:124
engine.go:74
dagjose_test.go:463
Error: Not equal:
expected: &dagjose.DagJOSE{payload:(*cid.Cid)(nil), signatures:[]dagjose.jwsSignature(nil), protected:[]uint8{}, unprotected:[]uint8{}, iv:[]uint8{}, aad:[]uint8(nil), ciphertext:[]uint8{}, tag:[]uint8(nil), recipients:[]dagjose.jweRecipient{dagjose.jweRecipient{header:map[string]ipld.Node{"":(*basicnode.plainMap)(0xc000c0da20)}, encrypted_key:[]uint8(nil)}}}
actual : &dagjose.DagJOSE{payload:(*cid.Cid)(nil), signatures:[]dagjose.jwsSignature(nil), protected:[]uint8{}, unprotected:[]uint8{}, iv:[]uint8{}, aad:[]uint8(nil), ciphertext:[]uint8{}, tag:[]uint8(nil), recipients:[]dagjose.jweRecipient{dagjose.jweRecipient{header:map[string]ipld.Node{"":(*basicnode.plainMap)(0xc000c0dec0)}, encrypted_key:[]uint8(nil)}}}
Diff:
--- Expected
+++ Actual
@@ -23,8 +23,8 @@
(basicnode.plainMap__Entry) {
+ k: (basicnode.plainString) "",
+ v: (*basicnode.plainString)("")
+ },
+ (basicnode.plainMap__Entry) {
k: (basicnode.plainString) (len=1) "?",
v: (*basicnode.plainString)(<already shown>)
- },
- (basicnode.plainMap__Entry) {
- k: (basicnode.plainString) "",
- v: (*basicnode.plainString)("")
}
Test: TestRoundTripArbitraryJOSE
I suspect the correct action to do here is patch the test expectations to just have content which is in the canonical order that dag-cbor will now sort things into.
As per:
#4 (comment)
It would be nice to have this code export some functions called Encode
and Decode
that match https://pkg.go.dev/github.com/ipld/[email protected]/codec#Encoder and https://pkg.go.dev/github.com/ipld/[email protected]/codec#Decoder.
This would be a prerequisite for getting this to land as a plugin in go-ipfs, because there, things need to conform to those function interfaces so they can be put in a registry map keyed by their multicodec indicator code. (The git plugin is an example of what gets wired up: https://github.com/ipfs/go-ipfs/blob/ae09459e3926d687599638abdb379e8627b53509/plugin/plugins/git/git.go#L40-L41 )
I think the StoreJOSE and LoadJOSE functions are probably close, so all the right logic exists somewhere, but the interfaces don't quite line up.
Hi expert,
this is a good repo, and I want to use it as plugin to installed in go-ipfs.
can you direct me how to convert it to go plugin?
thanks
Manual testing:
Fetch dag-jose objects from js-ipfs to go-ipfs and the inverse.
If it doesn't work tell ipfs team.
That tests creating and retrieving dag-jose objects from ipfs using the ipfs-http-client. Tests should be configurable to point either to a js-ipfs or go-ipfs daemon.
Make a simple js script that tests the functionality.
We need to confirm the following properties:
We should run the tests with the latest 0.9.0 go-ipfs release. We need to manually compile the go plugin.
We need to make sure that go-ipfs with a go-dag-jose plugin works the same as js-ipfs from the perspective of the ipfs-http-client. We should also make sure that some basic commands in go-ipfs works as expected.
We should have a basic script that creates a dag-jose object, puts it into the dag (ipfs.dag.put), retrieves it from the dag (ipfs.dag.get), and confirms that the retrived object is correctly formatted, and the same JWS object get's the same CID in both cases.
Run the tests:
We want to be able to retrieve a dag-jose object from the ipfs cli and have it outputted in the console. When
ipfs dag get <dag-jose-cid>
is exectued we should see the dag-jose object outputted in json format.
Note that this is not a strict requirement for js-ceramic to work properly.
As per:
ipfs/kubo#8364 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.