Skip to content

Commit

Permalink
run go generate on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jan 17, 2022
1 parent 55e7133 commit 45bda9d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .github/actions/go-check-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
runs:
using: "composite"
steps:
- name: Install mockgen
shell: bash
run: go install github.com/golang/mock/mockgen@v1.6.0
3 changes: 3 additions & 0 deletions .github/workflows/go-check-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"gogenerate": true
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
github.com/golang/mock v1.6.0
github.com/ipfs/go-log/v2 v2.4.0
github.com/libp2p/go-libp2p-core v0.13.1-0.20220114101623-6b8d8bf59647
github.com/libp2p/go-libp2p-core v0.14.0
github.com/multiformats/go-multiaddr v0.4.1
go.uber.org/atomic v1.7.0
google.golang.org/grpc v1.31.1
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs=
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/libp2p/go-libp2p-core v0.13.1-0.20220114101623-6b8d8bf59647 h1:r72wIR0ywdBUSTodR3WyY1Fdb9FUCHcYGT8NWxQH7wY=
github.com/libp2p/go-libp2p-core v0.13.1-0.20220114101623-6b8d8bf59647/go.mod h1:KlkHsZ0nKerWsXLZJm3LfFQwusI5k3iN4BgtYTE4IYE=
github.com/libp2p/go-libp2p-core v0.14.0 h1:0kYSgiK/D7Eo28GTuRXo5YHsWwAisVpFCqCVPUd/vJs=
github.com/libp2p/go-libp2p-core v0.14.0/go.mod h1:tLasfcVdTXnixsLB0QYaT1syJOhsbrhG7q6pGrHtBg8=
github.com/libp2p/go-msgio v0.0.6/go.mod h1:4ecVB6d9f4BDSL5fqvPiC4A3KivjWn+Venn/1ALLMWA=
github.com/libp2p/go-openssl v0.0.7 h1:eCAzdLejcNVBzP/iZM9vqHnQm+XyCEbSSIheIPRGNsw=
github.com/libp2p/go-openssl v0.0.7/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc=
Expand Down Expand Up @@ -182,8 +182,9 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
40 changes: 20 additions & 20 deletions suites/mux/muxer_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
crand "crypto/rand"
mrand "math/rand"

"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-testing/ci"
)

Expand All @@ -43,7 +43,7 @@ func getFunctionName(i interface{}) string {
}

type Options struct {
tr mux.Multiplexer
tr network.Multiplexer
connNum int
streamNum int
msgNum int
Expand Down Expand Up @@ -74,7 +74,7 @@ func log(s string, v ...interface{}) {
}
}

func echoStream(s mux.MuxedStream) {
func echoStream(s network.MuxedStream) {
defer s.Close()
log("accepted stream")
io.Copy(&LogWriter{s}, s) // echo everything
Expand All @@ -92,7 +92,7 @@ func (lw *LogWriter) Write(buf []byte) (int, error) {
return lw.W.Write(buf)
}

func GoServe(t *testing.T, tr mux.Multiplexer, l net.Listener) (done func()) {
func GoServe(t *testing.T, tr network.Multiplexer, l net.Listener) (done func()) {
closed := make(chan struct{}, 1)

go func() {
Expand Down Expand Up @@ -127,7 +127,7 @@ func GoServe(t *testing.T, tr mux.Multiplexer, l net.Listener) (done func()) {
}
}

func SubtestSimpleWrite(t *testing.T, tr mux.Multiplexer) {
func SubtestSimpleWrite(t *testing.T, tr network.Multiplexer) {
l, err := net.Listen("tcp", "localhost:0")
checkErr(t, err)
log("listening at %s", l.Addr().String())
Expand Down Expand Up @@ -185,7 +185,7 @@ func SubtestStress(t *testing.T, opt Options) {
rateLimitChan <- struct{}{}
}

writeStream := func(s mux.MuxedStream, bufs chan<- []byte) {
writeStream := func(s network.MuxedStream, bufs chan<- []byte) {
log("writeStream %p, %d msgNum", s, opt.msgNum)

for i := 0; i < opt.msgNum; i++ {
Expand All @@ -199,7 +199,7 @@ func SubtestStress(t *testing.T, opt Options) {
}
}

readStream := func(s mux.MuxedStream, bufs <-chan []byte) {
readStream := func(s network.MuxedStream, bufs <-chan []byte) {
log("readStream %p, %d msgNum", s, opt.msgNum)

buf2 := make([]byte, msgsize)
Expand All @@ -219,7 +219,7 @@ func SubtestStress(t *testing.T, opt Options) {
}
}

openStreamAndRW := func(c mux.MuxedConn) {
openStreamAndRW := func(c network.MuxedConn) {
log("openStreamAndRW %p, %d opt.msgNum", c, opt.msgNum)

s, err := c.OpenStream(context.Background())
Expand Down Expand Up @@ -329,7 +329,7 @@ func tcpPipe(t *testing.T) (net.Conn, net.Conn) {
return con1, con2
}

func SubtestStreamOpenStress(t *testing.T, tr mux.Multiplexer) {
func SubtestStreamOpenStress(t *testing.T, tr network.Multiplexer) {
wg := new(sync.WaitGroup)

a, b := tcpPipe(t)
Expand Down Expand Up @@ -418,7 +418,7 @@ func SubtestStreamOpenStress(t *testing.T, tr mux.Multiplexer) {
}
}

func SubtestStreamReset(t *testing.T, tr mux.Multiplexer) {
func SubtestStreamReset(t *testing.T, tr network.Multiplexer) {
wg := new(sync.WaitGroup)
defer wg.Wait()

Expand All @@ -442,7 +442,7 @@ func SubtestStreamReset(t *testing.T, tr mux.Multiplexer) {
time.Sleep(time.Millisecond * 50)

_, err = s.Write([]byte("foo"))
if err != mux.ErrReset {
if err != network.ErrReset {
t.Error("should have been stream reset")
}

Expand All @@ -462,7 +462,7 @@ func SubtestStreamReset(t *testing.T, tr mux.Multiplexer) {
}

// check that Close also closes the underlying net.Conn
func SubtestWriteAfterClose(t *testing.T, tr mux.Multiplexer) {
func SubtestWriteAfterClose(t *testing.T, tr network.Multiplexer) {
a, b := tcpPipe(t)

muxa, err := tr.NewConn(a, true, nil)
Expand All @@ -485,7 +485,7 @@ func SubtestWriteAfterClose(t *testing.T, tr mux.Multiplexer) {
}
}

func SubtestStress1Conn1Stream1Msg(t *testing.T, tr mux.Multiplexer) {
func SubtestStress1Conn1Stream1Msg(t *testing.T, tr network.Multiplexer) {
SubtestStress(t, Options{
tr: tr,
connNum: 1,
Expand All @@ -496,7 +496,7 @@ func SubtestStress1Conn1Stream1Msg(t *testing.T, tr mux.Multiplexer) {
})
}

func SubtestStress1Conn1Stream100Msg(t *testing.T, tr mux.Multiplexer) {
func SubtestStress1Conn1Stream100Msg(t *testing.T, tr network.Multiplexer) {
SubtestStress(t, Options{
tr: tr,
connNum: 1,
Expand All @@ -507,7 +507,7 @@ func SubtestStress1Conn1Stream100Msg(t *testing.T, tr mux.Multiplexer) {
})
}

func SubtestStress1Conn100Stream100Msg(t *testing.T, tr mux.Multiplexer) {
func SubtestStress1Conn100Stream100Msg(t *testing.T, tr network.Multiplexer) {
SubtestStress(t, Options{
tr: tr,
connNum: 1,
Expand All @@ -518,7 +518,7 @@ func SubtestStress1Conn100Stream100Msg(t *testing.T, tr mux.Multiplexer) {
})
}

func SubtestStress10Conn10Stream50Msg(t *testing.T, tr mux.Multiplexer) {
func SubtestStress10Conn10Stream50Msg(t *testing.T, tr network.Multiplexer) {
SubtestStress(t, Options{
tr: tr,
connNum: 10,
Expand All @@ -529,7 +529,7 @@ func SubtestStress10Conn10Stream50Msg(t *testing.T, tr mux.Multiplexer) {
})
}

func SubtestStress1Conn1000Stream10Msg(t *testing.T, tr mux.Multiplexer) {
func SubtestStress1Conn1000Stream10Msg(t *testing.T, tr network.Multiplexer) {
SubtestStress(t, Options{
tr: tr,
connNum: 1,
Expand All @@ -540,7 +540,7 @@ func SubtestStress1Conn1000Stream10Msg(t *testing.T, tr mux.Multiplexer) {
})
}

func SubtestStress1Conn100Stream100Msg10MB(t *testing.T, tr mux.Multiplexer) {
func SubtestStress1Conn100Stream100Msg10MB(t *testing.T, tr network.Multiplexer) {
SubtestStress(t, Options{
tr: tr,
connNum: 1,
Expand All @@ -567,7 +567,7 @@ var subtests = []TransportTest{

// SubtestAll runs all the stream multiplexer tests against the target
// transport.
func SubtestAll(t *testing.T, tr mux.Multiplexer) {
func SubtestAll(t *testing.T, tr network.Multiplexer) {
for name, f := range Subtests {
t.Run(name, func(t *testing.T) {
f(t, tr)
Expand All @@ -576,4 +576,4 @@ func SubtestAll(t *testing.T, tr mux.Multiplexer) {
}

// TransportTest is a stream multiplex transport test case
type TransportTest func(t *testing.T, tr mux.Multiplexer)
type TransportTest func(t *testing.T, tr network.Multiplexer)
12 changes: 6 additions & 6 deletions suites/transport/stream_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
crand "crypto/rand"
mrand "math/rand"

"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport"
"github.com/libp2p/go-libp2p-testing/race"
Expand Down Expand Up @@ -53,7 +53,7 @@ type Options struct {
MsgMax int
}

func fullClose(t *testing.T, s mux.MuxedStream) {
func fullClose(t *testing.T, s network.MuxedStream) {
if err := s.CloseWrite(); err != nil {
t.Error(err)
s.Reset()
Expand Down Expand Up @@ -87,7 +87,7 @@ func debugLog(t *testing.T, s string, args ...interface{}) {
}
}

func echoStream(t *testing.T, s mux.MuxedStream) {
func echoStream(t *testing.T, s network.MuxedStream) {
// echo everything
var err error
if VerboseDebugging {
Expand Down Expand Up @@ -164,7 +164,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
rateLimitChan <- struct{}{}
}

writeStream := func(s mux.MuxedStream, bufs chan<- []byte) {
writeStream := func(s network.MuxedStream, bufs chan<- []byte) {
debugLog(t, "writeStream %p, %d MsgNum", s, opt.MsgNum)

for i := 0; i < opt.MsgNum; i++ {
Expand All @@ -178,7 +178,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
}
}

readStream := func(s mux.MuxedStream, bufs <-chan []byte) {
readStream := func(s network.MuxedStream, bufs <-chan []byte) {
debugLog(t, "readStream %p, %d MsgNum", s, opt.MsgNum)

buf2 := make([]byte, msgsize)
Expand All @@ -198,7 +198,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
}
}

openStreamAndRW := func(c mux.MuxedConn) {
openStreamAndRW := func(c network.MuxedConn) {
debugLog(t, "openStreamAndRW %p, %d opt.MsgNum", c, opt.MsgNum)

s, err := c.OpenStream(context.Background())
Expand Down

0 comments on commit 45bda9d

Please sign in to comment.