- Notifications
You must be signed in to change notification settings - Fork 483
make block encodable #763
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
make block encodable #763
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, only tests are required.
| | ||
| try container.encode(uncles.map { $0.hexString }, forKey: .uncles) | ||
| | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, write test cases for that feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest the following:
- a test case where you create a Block manually, encode, decode it back and compare it with the original;
- a test case where you will have a JSON string, decode it and check that the decoding didn't throw. That should be something like
XCTAssertNoThrow(try JSONDecoder().decode(jsonString, Block.self)).
To produce a JSON string use the first test and String.init(data: try! JSONEncoder().encode(block), encoding: .utf8)! and print it out to the console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good for me.
@zhangliugang FYI: We have 2 weeks release schedule here, not so much strict thou. So this enhancement will be released somewhere within February. It will be released as patch (e.g. 3.1.2) despite that it's an enhancement (e.g. 3.2.0) actually.
| @zhangliugang why? |
| Well, folks. Depending on a new data as in #772 said. It's actually are not so clear whether this PR are has to be merged or not. I mean, So the use case of @zhangliugang is to erase this type and treat it like a dictionary on its JS level implementation. As for me i wonder the whole stack of your project @zhangliugang.
The answers would quite helpful to better understand your flow and to keep it in mind in future lib improvements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#772 PR related questions arisen.
My first reaction to reading the PR's title was also why does |
Summary of Changes
make
Block,TransactionInBlockencodableTest Data or Screenshots
By submitting this pull request, you are confirming the following:
developbranch.