diff --git a/internal/pkg/gateway/api_test.go b/internal/pkg/gateway/api_test.go index 6a03cbda8ee..e4ab6058e41 100644 --- a/internal/pkg/gateway/api_test.go +++ b/internal/pkg/gateway/api_test.go @@ -682,7 +682,7 @@ func TestEndorse(t *testing.T) { "g2": {{endorser: peer2Mock, height: 5}}, // msp2 }, localResponse: "different_response", - errString: "rpc error: code = Aborted desc = failed to assemble transaction: ProposalResponsePayloads do not match", + errString: "rpc error: code = Aborted desc = failed to assemble transaction: ProposalResponsePayloads do not match (base64): 'EhQaEgjIARoNbW9ja19yZXNwb25zZQ==' vs 'EhkaFwjIARoSZGlmZmVyZW50X3Jlc3BvbnNl'", }, { name: "discovery fails", diff --git a/protoutil/txutils.go b/protoutil/txutils.go index a19987dc9de..b3cbf2ac93c 100644 --- a/protoutil/txutils.go +++ b/protoutil/txutils.go @@ -9,6 +9,7 @@ package protoutil import ( "bytes" "crypto/sha256" + b64 "encoding/base64" "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric-protos-go/common" @@ -202,7 +203,8 @@ func createTx( } if !bytes.Equal(a1, r.Payload) { - return nil, errors.New("ProposalResponsePayloads do not match") + return nil, errors.Errorf("ProposalResponsePayloads do not match (base64): '%s' vs '%s'", + b64.StdEncoding.EncodeToString(r.Payload), b64.StdEncoding.EncodeToString(a1)) } } diff --git a/protoutil/txutils_test.go b/protoutil/txutils_test.go index a0e70e22d7e..37f09f4e4b9 100644 --- a/protoutil/txutils_test.go +++ b/protoutil/txutils_test.go @@ -10,6 +10,7 @@ import ( "encoding/hex" "errors" "strconv" + "strings" "testing" "github.com/golang/protobuf/proto" @@ -175,14 +176,6 @@ func TestCreateSignedTx(t *testing.T) { responses []*pb.ProposalResponse expectedError string }{ - // good responses, but different payloads - { - []*pb.ProposalResponse{ - {Payload: []byte("payload"), Response: &pb.Response{Status: int32(200)}}, - {Payload: []byte("payload2"), Response: &pb.Response{Status: int32(200)}}, - }, - "ProposalResponsePayloads do not match", - }, // good response followed by bad response { []*pb.ProposalResponse{ @@ -205,6 +198,16 @@ func TestCreateSignedTx(t *testing.T) { require.EqualErrorf(t, err, nonMatchingTest.expectedError, "Expected non-matching response error '%v' for test %d", nonMatchingTest.expectedError, i) } + // good responses, but different payloads + responses = []*pb.ProposalResponse{ + {Payload: []byte("payload"), Response: &pb.Response{Status: int32(200)}}, + {Payload: []byte("payload2"), Response: &pb.Response{Status: int32(200)}}, + } + _, err = protoutil.CreateSignedTx(prop, signID, responses...) + if err == nil || strings.HasPrefix(err.Error(), "ProposalResponsePayloads do not match (base64):") == false { + require.FailNow(t, "Error is expected when response payloads do not match") + } + // no endorsement responses = []*pb.ProposalResponse{{ Payload: []byte("payload"),