Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/eth/client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,30 @@
result:
name: Network ID
value: '1'
- name: net_listening
summary: Returns true if the client is actively listening for network connections.
params: []
result:
name: Listening
schema:
title: Listening
type: boolean
examples:
- name: net_listening example
params: []
result:
name: Listening
value: true
- name: net_peerCount
summary: Returns the number of peers currently connected to the client.
params: []
result:
name: Peer count
schema:
$ref: '#/components/schemas/uint'
examples:
- name: net_peerCount example
params: []
result:
name: Peer count
value: '0x2'
3 changes: 3 additions & 0 deletions tests/net_listening/get-listening.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Calls net_listening to check whether the client is listening for network connections.
>> {"jsonrpc":"2.0","id":1,"method":"net_listening"}
<< {"jsonrpc":"2.0","id":1,"result":true}
3 changes: 3 additions & 0 deletions tests/net_peerCount/get-peer-count.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Calls net_peerCount to retrieve the number of connected peers. The test client runs without peers, so the expected value is zero.
>> {"jsonrpc":"2.0","id":1,"method":"net_peerCount"}
<< {"jsonrpc":"2.0","id":1,"result":"0x0"}
42 changes: 42 additions & 0 deletions tools/testgen/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ var AllMethods = []MethodTests{
EthConfig,
EthCapabilities,
NetVersion,
NetListening,
NetPeerCount,
TestingBuildBlockV1,
TxpoolStatus,
TxpoolContent,
Expand Down Expand Up @@ -2452,6 +2454,46 @@ var NetVersion = MethodTests{
},
}

var NetListening = MethodTests{
"net_listening",
[]Test{
{
Name: "get-listening",
About: "Calls net_listening to check whether the client is listening for network connections.",
Run: func(ctx context.Context, t *T) error {
var got bool
if err := t.rpc.CallContext(ctx, &got, "net_listening"); err != nil {
return err
}
if !got {
return fmt.Errorf("net_listening returned false, want true")
}
return nil
},
},
},
}

var NetPeerCount = MethodTests{
"net_peerCount",
[]Test{
{
Name: "get-peer-count",
About: "Calls net_peerCount to retrieve the number of connected peers. The test client runs without peers, so the expected value is zero.",
Run: func(ctx context.Context, t *T) error {
var got hexutil.Uint
if err := t.rpc.CallContext(ctx, &got, "net_peerCount"); err != nil {
return err
}
if got != 0 {
return fmt.Errorf("unexpected peer count (got: %d, want: 0)", got)
}
return nil
},
},
},
}

// validateBuildBlockV1Response validates the common parts of a testing_buildBlockV1 response.
func validateBuildBlockV1Response(
t *T,
Expand Down
Loading