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

fix: fix a bug in c apis and add more tests #24

Merged
merged 4 commits into from
Apr 9, 2020

Conversation

yangby-cryptape
Copy link
Collaborator

@yangby-cryptape yangby-cryptape commented Mar 3, 2020

  • refactor(tests): split tests generators
  • fix(bindings/c): offsets are incorrect when all items in a Vector are None
  • test: test all test vectors in C apis
  • test: add proptest for both Rust and C

@yangby-cryptape
Copy link
Collaborator Author

Fix the follow test cases in C:

-
name: ByteOptVec
data:
- "0x"
expected: "0x08000000//08000000//"
-
name: ByteOptVec
data:
- "0x"
- "0x"
expected: "0x0c000000//0c000000_0c000000//"
-
name: ByteOptVec
data:
- "0x"
- "0x"
- "0x"
expected: "0x10000000//10000000_10000000_10000000//"

@yangby-cryptape yangby-cryptape marked this pull request as ready for review March 3, 2020 04:38
@yangby-cryptape yangby-cryptape requested review from a team and keroro520 and removed request for a team and keroro520 March 3, 2020 04:39
@yangby-cryptape yangby-cryptape requested review from a team and doitian and removed request for a team March 3, 2020 07:05
@doitian doitian added this to 👀 Awaiting review in CKB - Pull Requests Mar 9, 2020
@doitian doitian requested review from xxuejie and removed request for doitian March 9, 2020 03:19
@@ -262,15 +262,13 @@ MOLECULE_API_DECORATOR mol_seg_res_t mol_dynvec_builder_finalize(mol_builder_t b
res.seg.size = MOL_NUM_T_SIZE + builder.number_used + builder.data_used;
res.seg.ptr = (uint8_t*)malloc(res.seg.size);
mol_pack_number(res.seg.ptr, &res.seg.size);
if (builder.data_used > 0) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When N None were pushed into a Vector (N >= 1), the data_used is still 0, but N offsets have to be saved.

@xxuejie
Copy link
Contributor

xxuejie commented Mar 9, 2020

This is not a hard rule but next time I would suggest we split the test part and the bug fix into 2 PRs. So when I'm looking at a bug fix, I know exactly what the bug covers, while mixing 2 tasks in one PR like this makes it harder to read.

@yangby-cryptape
Copy link
Collaborator Author

This is not a hard rule but next time I would suggest we split the test part and the bug fix into 2 PRs. So when I'm looking at a bug fix, I know exactly what the bug covers, while mixing 2 tasks in one PR like this makes it harder to read.

OK, I'll pay attention next time.

I found the bug when I added tests. So I put them into one PR. The tests can approve the fix works.

For current PR, I split the commits for different sub-tasks, combine all sub-tasks is the main target: add more tests for C.
You can only review the commit for the fix.

@doitian
Copy link
Member

doitian commented Mar 19, 2020

🚢

@yangby-cryptape yangby-cryptape merged commit 1af8e26 into nervosnetwork:master Apr 9, 2020
CKB - Pull Requests automation moved this from 👀 Awaiting review to Done Apr 9, 2020
@yangby-cryptape yangby-cryptape deleted the pr/more-tests branch April 9, 2020 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants