fix(p2p): a few minor code inspection fixes #18393 (#2004)

This commit is contained in:
Daniel Liu 2026-02-06 15:53:01 +08:00 committed by GitHub
parent 5340ce712c
commit 9d79d44f1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 9 deletions

View file

@ -49,7 +49,7 @@ import (
// current binary as a child process.
//
// An init hook is used so that the child process executes the node services
// (rather than whataver the main() function would normally do), see the
// (rather than whatever the main() function would normally do), see the
// execP2PNode function for more information.
type ExecAdapter struct {
// BaseDir is the directory under which the data directories for each

View file

@ -281,6 +281,7 @@ var testServices = adapters.LifecycleConstructors{
}
func testHTTPServer(t *testing.T) (*Network, *httptest.Server) {
t.Helper()
adapter := adapters.NewSimAdapter(testServices)
network := NewNetwork(adapter, &NetworkConfig{
DefaultService: "test",

View file

@ -15,7 +15,7 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// Package simulations simulates p2p networks.
// A mokcer simulates starting and stopping real nodes in a network.
// A mocker simulates starting and stopping real nodes in a network.
package simulations
import (
@ -132,13 +132,13 @@ func TestMocker(t *testing.T) {
wg.Wait()
//check there are nodeCount number of nodes in the network
nodes_info, err := client.GetNodes()
nodesInfo, err := client.GetNodes()
if err != nil {
t.Fatalf("Could not get nodes list: %s", err)
}
if len(nodes_info) != nodeCount {
t.Fatalf("Expected %d number of nodes, got: %d", nodeCount, len(nodes_info))
if len(nodesInfo) != nodeCount {
t.Fatalf("Expected %d number of nodes, got: %d", nodeCount, len(nodesInfo))
}
//stop the mocker
@ -159,12 +159,12 @@ func TestMocker(t *testing.T) {
resp.Body.Close()
//now the number of nodes in the network should be zero
nodes_info, err = client.GetNodes()
nodesInfo, err = client.GetNodes()
if err != nil {
t.Fatalf("Could not get nodes list: %s", err)
}
if len(nodes_info) != 0 {
t.Fatalf("Expected empty list of nodes, got: %d", len(nodes_info))
if len(nodesInfo) != 0 {
t.Fatalf("Expected empty list of nodes, got: %d", len(nodesInfo))
}
}

View file

@ -457,7 +457,7 @@ func (net *Network) getConn(oneID, otherID discover.NodeID) *Conn {
return net.Conns[i]
}
// InitConn(one, other) retrieves the connectiton model for the connection between
// InitConn(one, other) retrieves the connection model for the connection between
// peers one and other, or creates a new one if it does not exist
// the order of nodes does not matter, i.e., Conn(i,j) == Conn(j, i)
// it checks if the connection is already up, and if the nodes are running