Skip to content

Commit

Permalink
[FAB-16957] Fix nil pointer panic flake in deliver_test (#704)
Browse files Browse the repository at this point in the history
* Seems like info.GetStart().GetSpecified() can somehow return nil on
subsequent calls. Let's just assign it before the first nil check and
use it for the rest of the assertion.

Signed-off-by: Danny Cao <dcao@us.ibm.com>
  • Loading branch information
caod123 committed Feb 24, 2020
1 parent b4c3766 commit cc3f58f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions orderer/common/cluster/deliver_test.go
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/onsi/gomega"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"google.golang.org/grpc"
Expand Down Expand Up @@ -271,8 +272,11 @@ func (ds *deliverServer) addExpectProbeAssert() {

func (ds *deliverServer) addExpectPullAssert(seq uint64) {
ds.seekAssertions <- func(info *orderer.SeekInfo, _ string) {
assert.NotNil(ds.t, info.GetStart().GetSpecified())
assert.Equal(ds.t, seq, info.GetStart().GetSpecified().Number)
seekPosition := info.GetStart()
require.NotNil(ds.t, seekPosition)
seekSpecified := seekPosition.GetSpecified()
require.NotNil(ds.t, seekSpecified)
assert.Equal(ds.t, seq, seekSpecified.Number)
assert.Equal(ds.t, info.ErrorResponse, orderer.SeekInfo_BEST_EFFORT)
}
}
Expand Down

0 comments on commit cc3f58f

Please sign in to comment.