Skip to content

Add Swift DAG-CBOR Library - #16

Open
thecoolwinter wants to merge 2 commits into
hyphacoop:mainfrom
thecoolwinter:add-swift
Open

thecoolwinter wants to merge 2 commits into
hyphacoop:mainfrom
thecoolwinter:add-swift

Conversation

@thecoolwinter

@thecoolwinter thecoolwinter commented Oct 22, 2025

Copy link
Copy Markdown

Adds my Swift CBOR library to the test suite. Only requires a Swift installation, works on Linux so it won't restrict the run script to macOS. The test harness is a simple Swift executable, and I wrote it so it should be very easy to add more Swift implementations if needed. I also quick updated the README to reference the update_libs.sh script instead of instructions for npm install.

I've also gone ahead and added Swift to the CI jobs to ensure there's no extra work on y'alls side to get that set up!

  • Updated the update_libs.sh script.
  • Updated the super_harness.sh script.

@makew0rld

Copy link
Copy Markdown
Collaborator

Sorry for the delay on this. LGTM, thanks for adding. Note your library does fail one important test, "valid CID with short tag". That's not a blocker for the test suite but it might be something you want to look into.

One thing I am concerned about is the lack of error messages, for example clicking a passing invalid_in test shows this:

{
  "error": null,
  "output": null,
  "pass": true
}

But ideally it would show the nature of the error.

image

Not a blocker, but if you could improve this in a future PR that would be great.

@makew0rld

Copy link
Copy Markdown
Collaborator

Ok additionally, I think some of the implementation is wrong.

  • invalidDecode should only test the decoder
  • invalidEncode should decode the data using a third-party neutral (not dag-cbor or DASL) CBOR decoder, and then try to encode that object
  • Your roundtrip function looks right

Also the library version shouldn't be hardcoded.

A good reference harness for you to look at is harnesses/go-dasl/main.go, but you can look at any you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants