missing unmarshalling of content bytes before encoding and generation… #86

Closed
ABastionOfSanity wants to merge 4 commits from fix_cid_generation into main
ABastionOfSanity commented 2023-01-19 22:10:42 +00:00 (Migrated from github.com)

This is to address
https://github.com/cerc-io/laconic-sdk/issues/7
for improperly generated CID in SetRecord endpoint.

This is to address https://github.com/cerc-io/laconic-sdk/issues/7 for improperly generated CID in SetRecord endpoint.
codecov-commenter commented 2023-01-19 22:23:57 +00:00 (Migrated from github.com)

Codecov Report

Merging #86 (7db19ee) into main (ab2ea51) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #86   +/-   ##
=======================================
  Coverage   66.57%   66.57%           
=======================================
  Files         145      145           
  Lines       15953    15953           
=======================================
  Hits        10620    10620           
  Misses       4859     4859           
  Partials      474      474           
Impacted Files Coverage Δ
x/registry/keeper/keeper.go 48.92% <100.00%> (ø)
# [Codecov](https://codecov.io/gh/cerc-io/laconicd/pull/86?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report > Merging [#86](https://codecov.io/gh/cerc-io/laconicd/pull/86?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (7db19ee) into [main](https://codecov.io/gh/cerc-io/laconicd/commit/ab2ea51aac6e3c26a41dd4028d8d5d8884e13b50?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (ab2ea51) will **not change** coverage. > The diff coverage is `100.00%`. <details><summary>Additional details and impacted files</summary> [![Impacted file tree graph](https://codecov.io/gh/cerc-io/laconicd/pull/86/graphs/tree.svg?width=650&height=150&src=pr&token=5tWmn7LxfO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)](https://codecov.io/gh/cerc-io/laconicd/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) ```diff @@ Coverage Diff @@ ## main #86 +/- ## ======================================= Coverage 66.57% 66.57% ======================================= Files 145 145 Lines 15953 15953 ======================================= Hits 10620 10620 Misses 4859 4859 Partials 474 474 ``` | [Impacted Files](https://codecov.io/gh/cerc-io/laconicd/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [x/registry/keeper/keeper.go](https://codecov.io/gh/cerc-io/laconicd/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9yZWdpc3RyeS9rZWVwZXIva2VlcGVyLmdv) | `48.92% <100.00%> (ø)` | | </details>
0xmuralik (Migrated from github.com) approved these changes 2023-01-23 04:51:13 +00:00
0xmuralik (Migrated from github.com) left a comment

LGTM

LGTM
i-norden reviewed 2023-01-25 02:14:50 +00:00
i-norden left a comment
Member

Thanks! Please add a unit test that shows that CIDFromJSONBytesUsingIpldPrime and CIDFromJSONBytes both match expected output(s)

Thanks! Please add a unit test that shows that `CIDFromJSONBytesUsingIpldPrime` and `CIDFromJSONBytes` both match expected output(s)
Member

Let's remove this left over comment

Let's remove this left over comment
Member

Nice this simplifies things. In a separate PR we can simplify things further by getting rid of the linksystem and doing https://github.com/cerc-io/laconicd/issues/85.

In this context we don't need to pull in an entire linksystem, we can encode as dag-cbor using this, hash the output, and convert the hash into a CID using this.

Nice this simplifies things. In a separate PR we can simplify things further by getting rid of the linksystem and doing https://github.com/cerc-io/laconicd/issues/85. In this context we don't need to pull in an entire linksystem, we can encode as dag-cbor using [this](https://github.com/ipld/go-ipld-prime/blob/master/codec/dagcbor/marshal.go#L36), hash the output, and convert the hash into a CID using [this](https://github.com/ipld/go-ipld-prime/blob/master/linking/cid/cidLink.go#L41).
i-norden requested changes 2023-01-27 18:44:15 +00:00
i-norden left a comment
Member

Thanks for adding the test, just one small modification.

Thanks for adding the test, just one small modification.
@ -0,0 +23,4 @@
}
for _, tc := range testCases {
deprecatedAndCorrect, _ := CIDFromJSONBytes([]byte(tc.content))
Member

We should either catch any errors returned by these functions or make sure the returned result isn't nil/empty, because if both functions were to error out and return a nil/empty result it would evaluate them as equal and the test would pass.

We should either catch any errors returned by these functions or make sure the returned result isn't `nil`/empty, because if both functions were to error out and return a `nil`/empty result it would evaluate them as equal and the test would pass.
ABastionOfSanity commented 2023-01-30 22:08:56 +00:00 (Migrated from github.com)
closed by: https://github.com/cerc-io/laconicd/pull/88

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cerc-io/laconicd-deprecated#86
No description provided.