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

Hit >80% code coverage on all libp2p packages #83

Closed
32 tasks
whyrusleeping opened this issue Aug 9, 2016 · 12 comments
Closed
32 tasks

Hit >80% code coverage on all libp2p packages #83

whyrusleeping opened this issue Aug 9, 2016 · 12 comments
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue status/ready Ready to be worked

Comments

@whyrusleeping
Copy link
Contributor

Similar to ipfs/kubo#3053 we want to have really good test coverage on libp2p. Its the core on which ipfs and other future applications rest, and if libp2p doesn't work, the apps on top of it don't stand much of a chance. Here is a list of all the libp2p package (in this repo and outside of this repo) that we need to have coverage for:

  • github.com/ipfs/go-libp2p/p2p/discovery
  • github.com/ipfs/go-libp2p/p2p/host
  • github.com/ipfs/go-libp2p/p2p/host/basic
  • github.com/ipfs/go-libp2p/p2p/host/routed
  • github.com/ipfs/go-libp2p/p2p/metrics
  • github.com/ipfs/go-libp2p/p2p/metrics/conn
  • github.com/ipfs/go-libp2p/p2p/metrics/stream
  • github.com/ipfs/go-libp2p/p2p/nat
  • github.com/ipfs/go-libp2p/p2p/net
  • github.com/ipfs/go-libp2p/p2p/net/conn
  • github.com/ipfs/go-libp2p/p2p/net/conreq
  • github.com/ipfs/go-libp2p/p2p/net/filter
  • github.com/ipfs/go-libp2p/p2p/net/mock
  • github.com/ipfs/go-libp2p/p2p/net/swarm
  • github.com/ipfs/go-libp2p/p2p/net/swarm/addr
  • github.com/ipfs/go-libp2p/p2p/protocol
  • github.com/ipfs/go-libp2p/p2p/protocol/identify
  • github.com/ipfs/go-libp2p/p2p/protocol/ping
  • github.com/ipfs/go-libp2p/p2p/protocol/relay
  • github.com/ipfs/go-libp2p/p2p/test/backpressure
  • github.com/ipfs/go-libp2p/p2p/test/reconnects
  • github.com/ipfs/go-libp2p/p2p/test/util
  • github.com/ipfs/go-libp2p/testutil
  • github.com/ipfs/go-libp2p/testutil/ci
  • github.com/ipfs/go-libp2p/testutil/ci/jenkins
  • github.com/ipfs/go-libp2p/testutil/ci/travis
  • github.com/ipfs/go-libp2p-peerstore
  • github.com/ipfs/go-libp2p-peer
  • github.com/ipfs/go-libp2p-loggables
  • github.com/ipfs/go-libp2p-crypto
  • github.com/ipfs/go-libp2p-secio
  • github.com/ipfs/go-libp2p-transport
@whyrusleeping whyrusleeping added help wanted Seeking public contribution on this issue exp/novice Someone with a little familiarity can pick up labels Aug 9, 2016
@zjiekai
Copy link
Contributor

zjiekai commented Aug 17, 2016

Hi, I'm trying to run test.

In the code package imports are prefixed with github.com/libp2p/go-libp2p. Why not github.com/libp2p/go-libp2p? What am I missing?

Here is what I am referring to https://github.com/libp2p/go-libp2p/blob/master/p2p/discovery/mdns.go#L18

@zjiekai
Copy link
Contributor

zjiekai commented Aug 17, 2016

There seems to be both github.com/ipfs/go-libp2p and github.com/libp2p/go-libp2p?

@whyrusleeping
Copy link
Contributor Author

We're in the middle of moving the libp2p code from the ipfs org to the new
libp2p org. Each package has to be moved manually and updated, we just
haven't gotten around to it yet. This doesn't currently cause any problems
for the code

On Wed, Aug 17, 2016, 07:10 zjiekai notifications@github.com wrote:

There seems to be both github.com/ipfs/go-libp2p and
github.com/libp2p/go-libp2p?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#83 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABL4HOJphZ6Y9VCeQsru3r960x9SwvB-ks5qgxZngaJpZM4JgUOS
.

@zjiekai
Copy link
Contributor

zjiekai commented Aug 17, 2016

It's probably my lack of experience with golang getting me really confused.

Should I wait for the transition settled? Or should I just make a copy and edit the code in $GOPATH/src/github.com/libp2p/go-libp2p? Or are there some magic that make the go command work? I'd really like to learn the trick to run the code if that's not too much trouble.

There will be a a talk about IPFS in devcon in China. I'm trying to get started so if I get a chance to meet the IPFS guys I can ask some meaningful questions

update: I see. I should run go get github.com/libp2p/go-libp2p in the first place.

@whyrusleeping
Copy link
Contributor Author

@zjiekai did you get it working? If you provide me with the error messages of things going wrong I can be more helpful

@whyrusleeping
Copy link
Contributor Author

@zjiekai also, an aside, i'm super excited for DEVCON 2 :)

@whyrusleeping
Copy link
Contributor Author

whyrusleeping commented Aug 17, 2016

To run the tests for go-libp2p, i would do the following:

First, get the code and deps:

go get -d github.com/libp2p/go-libp2p
cd $GOPATH/src/github.com/libp2p/go-libp2p
make deps
gx-go rewrite

Now, you're set to run the tests, to run all of them, do:

go test ./...

To run tests for a specific package, do:

go test ./p2p/net/swarm

You can add -v for more verbose information, and -cover for code coverage information:

go test -v -cover ./...
go test -v -cover ./p2p/net/mock

you can also generate html coverage reports by doing:

go test -v -coverprofile=cover.out ./p2p/net/swarm
go tool cover -html=cover.out

Then, before you commit anything, make sure to undo all the import path changes:

gx-go rewrite --undo

Let me know if i missed anything!

@zjiekai
Copy link
Contributor

zjiekai commented Aug 18, 2016

@whyrusleeping It's working now. Thank you for the detailed write up. Super helpful!

@whyrusleeping
Copy link
Contributor Author

@zjiekai awesome! Please let me know if you run into any other issues or have any questions

@ghost ghost added status/deferred Conscious decision to pause or backlog and removed status/deferred Conscious decision to pause or backlog labels Nov 12, 2016
@whyrusleeping whyrusleeping added the status/ready Ready to be worked label Nov 28, 2016
@daviddias daviddias added the exp/expert Having worked on the specific codebase is important label Aug 19, 2017
@Stebalien Stebalien removed the exp/novice Someone with a little familiarity can pick up label Aug 31, 2017
@petroav
Copy link
Contributor

petroav commented Dec 18, 2018

I'd like to contribute to this effort. Just opened libp2p/go-libp2p-loggables#21 to kick things off. Anything I should keep in mind while writing tests? Special mocking frameworks you use or general guidelines I should follow?

I'll start with the utilities/miscellaneous repos as they're generally less intimidating and I'll open issues in the respective repos if I have questions.

@Stebalien
Copy link
Member

We generally just use the standard go testing library without any additional testing frameworks. The best way to learn how we write tests is to look at the tests in go-libp2p-swarm, go-libp2p-kad-dht, and go-libp2p-transport.

@Stebalien
Copy link
Member

This issue hasn't really helped motivate us to improve test coverage, although test coverage has been steadily getting better. So I'm going to close it.

marten-seemann pushed a commit that referenced this issue Dec 20, 2021
marten-seemann pushed a commit that referenced this issue Apr 22, 2022
fix: avoid logging "invalid argument" errors when setting keepalive
marten-seemann pushed a commit that referenced this issue Apr 22, 2022
marten-seemann added a commit that referenced this issue Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

5 participants