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

Create and test fromHexString and fromBytes for SszBitlist #8611

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

oceans404
Copy link

@oceans404 oceans404 commented Sep 17, 2024

PR Description

this PR adds 2 methods for working with SszBitlist

  • fromBytes: Create an SszBitlist directly from bytes
  • fromHexString: Create an SszBitlist from a hex string (wrapper around fromBytes)

These methods are now available on SszBitlistSchema, so you can do

SszBitlist myBitlist = schema.fromBytes(someBytes);
SszBitlist myOtherBitlist = schema.fromHexString("0x01020304");

Fixed Issue(s)

Issue #8505

@oceans404
Copy link
Author

hey @rolfyone! is it possible to rerun ci/circleci: acceptanceTests on this pr?

Copy link
Contributor

@gfukushima gfukushima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestion for the general edge case tests created. other than that I think it looks good!

}

@Test
public void testFromHexStringEdgeCases() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be even better if we break this general edge cases into individual tests?

public SszBitlist fromBytes(final Bytes bytes) {
checkArgument(bytes != null, "Input bytes cannot be null");
try (SszReader reader = SszReader.fromBytes(bytes)) {
TreeNode node = sszDeserializeTree(reader);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this can use the final modifier

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