Skip to content

Commit

Permalink
rpc: close Clients in tests (ethereum#29512)
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush authored and xiaochangbai committed Apr 18, 2024
1 parent 06f93f5 commit 86d0046
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func TestClientBatchRequestLimit(t *testing.T) {
defer server.Stop()
server.SetBatchLimits(2, 100000)
client := DialInProc(server)
defer client.Close()

batch := []BatchElem{
{Method: "foo"},
Expand Down Expand Up @@ -342,6 +343,7 @@ func testClientCancel(transport string, t *testing.T) {
default:
panic("unknown transport: " + transport)
}
defer client.Close()

// The actual test starts here.
var (
Expand Down Expand Up @@ -592,6 +594,7 @@ func TestClientSubscriptionChannelClose(t *testing.T) {

srv.RegisterName("nftest", new(notificationTestService))
client, _ := Dial(wsURL)
defer client.Close()

for i := 0; i < 100; i++ {
ch := make(chan int, 100)
Expand Down Expand Up @@ -708,7 +711,6 @@ func TestClientHTTP(t *testing.T) {
errc = make(chan error, len(results))
wantResult = echoResult{"a", 1, new(echoArgs)}
)
defer client.Close()
for i := range results {
i := i
go func() {
Expand Down
2 changes: 2 additions & 0 deletions rpc/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func TestWebsocketPeerInfo(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer c.Close()

// Request peer information.
var connInfo PeerInfo
Expand Down Expand Up @@ -273,6 +274,7 @@ func TestClientWebsocketLargeMessage(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer c.Close()

var r string
if err := c.Call(&r, "test_largeResp"); err != nil {
Expand Down

0 comments on commit 86d0046

Please sign in to comment.