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

Feat: remove circular dependencies in merkledag package tests #4704

Merged
merged 5 commits into from
Mar 23, 2018

Conversation

hsanjuan
Copy link
Contributor

This avoids using unixfs package and importer packages in
merkledag, which removes circular depedencies making it hard
to extract this module.

This comes pers @whyrusleeping suggestion on IRC:

22:20:28 <@whyrusleeping> hsanjuan: it would be great to work out those circular deps by using mocks of some sort
22:20:53 <@whyrusleeping> I think the merkledag_test stuff can be replaced with some code that just generates a dag manually
22:21:03 <@whyrusleeping> which is a little annoying, but needs to be done anyways

I'm very new here handling DAGs etc, so excuses in advance if something is terribly stupid.

This avoids using unixfs package and importer packages in
merkledag, which removes circular depedencies making it hard
to extract this module.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
@hsanjuan hsanjuan self-assigned this Feb 14, 2018
@ghost ghost added the status/in-progress In progress label Feb 14, 2018
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
// First, a node is created from each 512 bytes of data from the reader
// (like a the Size chunker would do). Then all nodes are added as children
// to a root node, which is returned.
func makeTestDAG(t *testing.T, read io.Reader, ds ipld.DAGService) ipld.Node {
Copy link
Member

Choose a reason for hiding this comment

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

This should be using io.ReadFull (Read isn't guaranteed to fill the buffer). It should probably also handle short reads. It may currently "work" but I'm worried that users will misuse it.

errs <- err
}
_ = firstpb
_ = expected
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't need these lines.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
for err == nil {
protoNode := NodeWithData(p)
nodes = append(nodes, protoNode)
_, err = read.Read(p)
Copy link
Member

Choose a reason for hiding this comment

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

Same. Needs a ReadFull. I'd just deduplicate the code and have a for { loop with a break/return.

License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 1, 2018

Thanks @Stebalien

@Stebalien
Copy link
Member

Sufficiently paranoid 😄. LGTM.

@whyrusleeping
Copy link
Member

@hsanjuan would you be offended if I don't merge this one until we ship 0.4.14?

@hsanjuan
Copy link
Contributor Author

hsanjuan commented Mar 3, 2018

@whyrusleeping when will that be?

@whyrusleeping
Copy link
Member

@hsanjuan as soon as #4751 is in

@Stebalien
Copy link
Member

@whyrusleeping FYI, this is just a test change.

@Kubuxu Kubuxu added RFM and removed status/in-progress In progress labels Mar 8, 2018
@Kubuxu Kubuxu added this to the go-ipfs 0.4.15 milestone Mar 8, 2018
@whyrusleeping whyrusleeping merged commit 61544ac into master Mar 23, 2018
@whyrusleeping
Copy link
Member

Thanks @hsanjuan!

@whyrusleeping whyrusleeping deleted the feat/merkledag-dag-mocks branch March 23, 2018 06:07
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Apr 7, 2022
License: MIT
Signed-off-by: Hector Sanjuan <hector@protocol.ai>
ariescodescream pushed a commit to ariescodescream/go-ipfs that referenced this pull request Apr 7, 2022
Feat: remove circular dependencies in merkledag package tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants