-
Notifications
You must be signed in to change notification settings - Fork 102
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
Tests confusing #2
Comments
Just to add to the discussion: I found it strange too but I simply ported it as there would be no way to confirm my port implemented properly the algorithm (as done by @alizain). Anyway, the algorithm looks like a proof-of-concept. Binary implementation should be the "production" one, IMO. I agree ULID must settle to fixed lengths to avoid your scenario. |
@RobThree Yes that's true. I was trying to figure out the number of bits to allocate to the timestamp to ensure we don't run into a Y2K problem whilst keeping the entropy high enough 😛
@imdario Agreed
@RobThree While I do understand, it makes me somewhat more comfortable in the correctness of the implementation if I can change the length and get the expected output, purely from a testability perspective. That being said, I have moved the length declarations up top as suggested! |
What would be the use of these tests?
The specs clearly read:
So there would (should?) never be a need for any other length than 10? I see others implement the same test:
Also the
len
argument toencodeRandom()
andencodeTime()
pop up in all other implementations; again: since these are fixed per the spec they don't make sense since they will/should never be called with any other argument.Don't get me wrong, I understand completely that the (original?) intent probably is/was "you may want to 'vary' with, for example 12 chars timestamp and 14 chars randomness" but then it wouldn't be a ulid anymore, would it? Then it (and a ulid) would simply be a base32 encoded representation of 128 bits of data.
I propose the referred tests are dropped, the arguments ditto and the lengths either hardcoded in their respective methods, or, for readability be put in some sort of
const
(likeconst TIMEPARTLENGTH = 10, RANDOMPARTLENGTH = 16
).If a ulid is to become as widespread as UUID/GUID's then, IMHO, it would be better to start off with people not 'tweaking' their ulid's to their need causing a 'proliferation' of all sorts of 'sorta compatible' ulids.
But that's just my $0.02
The text was updated successfully, but these errors were encountered: