rpc/server: use dynamic port for P2P service

Fix running tests alongside regular testnet node.

panic: TCP listen error

goroutine 4634 [running]:
go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc0008540c0, 0xc001a4df80, 0x1, 0x1)
        /home/rik/go/pkg/mod/go.uber.org/zap@v1.18.1/zapcore/entry.go:234 +0x532
go.uber.org/zap.(*Logger).Panic(0xc002399ce0, 0xecd669, 0x10, 0xc001a4df80, 0x1, 0x1)
        /home/rik/go/pkg/mod/go.uber.org/zap@v1.18.1/logger.go:230 +0x85
github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Accept(0xc000fd6960)
        /home/rik/dev/neo-go/pkg/network/tcp_transport.go:49 +0x216
created by github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start
        /home/rik/dev/neo-go/pkg/network/server.go:292 +0x2bb
FAIL    github.com/nspcc-dev/neo-go/pkg/rpc/server      1.095s
This commit is contained in:
Roman Khimov 2021-11-15 12:18:34 +03:00
parent 7fa58a4dc8
commit cc4a63e454

View file

@ -101,6 +101,7 @@ func initClearServerWithServices(t testing.TB, needOracle bool, needNotary bool)
chain, orc, cfg, logger := getUnitTestChain(t, needOracle, needNotary)
serverConfig := network.NewServerConfig(cfg)
serverConfig.Port = 0
server, err := network.NewServer(serverConfig, chain, logger)
require.NoError(t, err)
rpcServer := New(chain, cfg.ApplicationConfiguration.RPC, server, orc, logger)