diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9569d2..4b2e7f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,8 @@ jobs: - uses: actions/setup-go@v2 with: go-version: '^1.15.6' + - name: Running test suite + run: make test - name: Building release binaries run: make release - name: Creating Release diff --git a/Makefile b/Makefile index cc7476b..d3e1c75 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BINARY=pcp -VERSION=0.3.0 +VERSION=0.3.1 BUILD=`git rev-parse HEAD` PLATFORMS=darwin linux windows ARCHITECTURES=386 amd64 arm @@ -11,6 +11,9 @@ default: build all: clean release install +test: + go test ./... + build: go build ${LDFLAGS} -o out/${BINARY} cmd/pcp/pcp.go diff --git a/pkg/dht/discoverer_test.go b/pkg/dht/discoverer_test.go index 10a94fe..ec9d54c 100644 --- a/pkg/dht/discoverer_test.go +++ b/pkg/dht/discoverer_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" + "github.com/golang/mock/gomock" "github.com/ipfs/go-cid" "github.com/libp2p/go-libp2p-core/peer" @@ -182,7 +184,10 @@ func TestDiscoverer_Discover_restartAsSoonAsCurrentTimeSlotIsExpired(t *testing. } func TestDiscoverer_SetOffset(t *testing.T) { - d := NewDiscoverer(nil, nil) + net := mocknet.New(context.Background()) + local, err := net.GenPeer() + require.NoError(t, err) + d := NewDiscoverer(local, nil) id1 := d.DiscoveryID(333) d.SetOffset(TruncateDuration * 3) id2 := d.DiscoveryID(333)