Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocumentId doesn't always convert down to String and back #108

Closed
heckj opened this issue May 23, 2024 · 2 comments · Fixed by #103
Closed

DocumentId doesn't always convert down to String and back #108

heckj opened this issue May 23, 2024 · 2 comments · Fixed by #103
Assignees
Labels
bug Something isn't working testing testing of existing code or functionality

Comments

@heckj
Copy link
Collaborator

heckj commented May 23, 2024

While digging on a flaky test (#104), I resolved that issue only to find that in some cases a DocumentId() generated and converted to a String (DocumentId().id) doesn't 100% of the time convert back to a valid DocumentId().

The code underneath is using BS58 encoding (Base58.base58CheckEncode(data.bytes) for data generated by UUID(). The reverse uses Base58.base58CheckDecode(stringValue) - so you'd think that would be 100%, but apparently not.

An iteration test going through 1000 of these, converting to string and trying to get back, shows a loss of 1 or 2 in 1000 (0.1 to 0.2% failure). Need to figure out why, and in the mean time I have some definite examples:

  • 1YNk8bmh2xxuNqeAjsuPy4JjnwF
  • 1Tf5GWML5KA18TJqUN9qKarxbhm
  • 1ZEbwfpSJxXascTx7sstBecFLky
  • 12mS52BJoU16LAzKmMdwgGW4tQQ
  • 1kVFyeTJ6WjUmMT8pGCEesQDVxa
@heckj heckj added bug Something isn't working testing testing of existing code or functionality labels May 23, 2024
@heckj heckj self-assigned this May 23, 2024
@heckj
Copy link
Collaborator Author

heckj commented May 23, 2024

XCTAssertNotNil failed - id: 1ezULPhgshBPYi4H2MTBoMKwc3S [00cf851bc4f4441d86d127c26774145e] doesn't back convert (try #71)

XCTAssertNotNil failed - id: 1Ui7LyCmx1vxgvdu2md5t8mcFsC [00975afb316a438ba1b5d9d54d80f113] doesn't back convert (try #293)

@heckj
Copy link
Collaborator Author

heckj commented May 23, 2024

Well, that's disappointing. It's a known issue in the upstream project (keefertaylor/Base58Swift#23, keefertaylor/Base58Swift#25), with a PR open to fix it (keefertaylor/Base58Swift#21)

On the plus side, the author appears to still be very active d on GitHub, so hoping that asking about this might get it moving and sorted so that it's an upstream fix we can directly consume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing testing of existing code or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant