Skip to content

Commit

Permalink
fix(peers): add default limit to peers, fix test
Browse files Browse the repository at this point in the history
- now that `page` and `page-size` have been disabled, add a DefaultPeerListLimit (200), that we can pull from when no limit or offset have been given

- ListPeers correctly returning limit and offset, fixing test to reflect
  • Loading branch information
ramfox committed Apr 29, 2019
1 parent 62d5da8 commit fe8f6d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions actions/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ import (
"github.com/qri-io/qri/repo/profile"
)

var DefaultPeerListLimit = 200

// ListPeers lists Peers on the qri network
func ListPeers(node *p2p.QriNode, limit, offset int, onlineOnly bool) ([]*config.ProfilePod, error) {

if limit <= 0 {
limit = DefaultPeerListLimit
}

r := node.Repo
user, err := r.Profile()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion actions/peers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestListPeers(t *testing.T) {

ctx := context.Background()
factory := p2ptest.NewTestNodeFactory(p2p.NewTestableQriNode)
testPeers, err := p2ptest.NewTestNetwork(ctx, factory, 5)
testPeers, err := p2ptest.NewTestNetwork(ctx, factory, 6)
if err != nil {
t.Fatalf("error creating network: %s", err.Error())
}
Expand Down

0 comments on commit fe8f6d8

Please sign in to comment.