-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
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>
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 { |
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.
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.
merkledag/merkledag_test.go
Outdated
errs <- err | ||
} | ||
_ = firstpb | ||
_ = expected |
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.
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>
merkledag/merkledag_test.go
Outdated
for err == nil { | ||
protoNode := NodeWithData(p) | ||
nodes = append(nodes, protoNode) | ||
_, err = read.Read(p) |
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.
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>
Thanks @Stebalien |
Sufficiently paranoid 😄. LGTM. |
@hsanjuan would you be offended if I don't merge this one until we ship 0.4.14? |
@whyrusleeping when will that be? |
@whyrusleeping FYI, this is just a test change. |
Thanks @hsanjuan! |
License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
Feat: remove circular dependencies in merkledag package tests
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:
I'm very new here handling DAGs etc, so excuses in advance if something is terribly stupid.