Skip to content

Commit

Permalink
fix premature timeout of rpc connection during test
Browse files Browse the repository at this point in the history
fix premature timeout of rpc connection during test

fix premature timeout of rpc connection during test
  • Loading branch information
solo-daemon committed Apr 24, 2024
1 parent 50711a9 commit b6a43f7
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions common/deliverclient/blocksprovider/delivery_requester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"context"
"crypto/x509"
"fmt"
"log"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -95,13 +94,11 @@ func (ds *deliverServer) Deliver(stream orderer.AtomicBroadcast_DeliverServer) e
ds.Lock()
err := ds.err
ds.Unlock()

if err != nil {
return nil
}
seekInfo, channel, err := readSeekEnvelope(stream)
require.NoError(ds.t, err)

timer := time.NewTimer(1 * time.Minute)
defer timer.Stop()

Expand Down Expand Up @@ -217,7 +214,6 @@ func newClusterNodeWithTLS(t *testing.T) *deliverServer {
func TestDeliveryRequester_Connect(t *testing.T) {
osn := newClusterNode(t)
defer osn.stop()

fakeSigner := &fake.Signer{}
fakeSigner.SignReturns([]byte("good-sig"), nil)

Expand All @@ -228,23 +224,23 @@ func TestDeliveryRequester_Connect(t *testing.T) {
}
fakeDeliverStreamer := blocksprovider.DeliverAdapter{}

seekInfoEnv := &common.Envelope{}
endpoint := &orderers.Endpoint{
Address: osn.srv.Address(),
RootCerts: nil,
}

dr := blocksprovider.NewDeliveryRequester(
"channel-id",
fakeSigner,
nil,
&fakeDialer,
fakeDeliverStreamer,
)
deliverClient, cancelFunc, err := dr.Connect(seekInfoEnv, endpoint)
if err != nil {
log.Fatalf("error : %v", err)

seekInfoEnv, err := dr.SeekInfoBlocksFrom(100)
require.NoError(t, err)
endpoint := &orderers.Endpoint{
Address: osn.srv.Address(),
RootCerts: nil,
}

deliverClient, cancelFunc, err := dr.Connect(seekInfoEnv, endpoint)
time.Sleep(100 * time.Millisecond)
assert.Nil(t, err)
assert.NotNil(t, deliverClient)
assert.NotNil(t, cancelFunc)
Expand Down

0 comments on commit b6a43f7

Please sign in to comment.