1+ /*
2+ Copyright IBM Corp. All Rights Reserved.
3+
4+ SPDX-License-Identifier: Apache-2.0
5+ */
16package serialization_test
27
38import (
49 "testing"
510
11+ "github.com/stretchr/testify/require"
12+
613 "github.com/hyperledger/fabric-protos-go-apiv2/common"
14+ "github.com/hyperledger/fabric/protoutil"
15+
716 "github.com/hyperledger/fabric-x-committer/utils/serialization"
817 "github.com/hyperledger/fabric-x-committer/utils/test"
9- "github.com/hyperledger/fabric/protoutil"
10- "github.com/stretchr/testify/require"
1118)
1219
13- // UnwrapEnvelope function with invalid inputs
20+ // TestUnwrapEnvelopeBadInput tests UnwrapEnvelope function with invalid inputs.
1421func TestUnwrapEnvelopeBadInput (t * testing.T ) {
1522 t .Run ("Not an envelope" , func (t * testing.T ) {
23+ t .Parallel ()
1624 _ , _ , err := serialization .UnwrapEnvelope ([]byte ("invalid input" ))
1725 require .Error (t , err )
1826 })
1927
2028 t .Run ("OK Header with an invalid payload" , func (t * testing.T ) {
29+ t .Parallel ()
2130 envelope := & common.Envelope {
2231 Payload : []byte ("not-a-payload" ),
2332 }
@@ -29,6 +38,7 @@ func TestUnwrapEnvelopeBadInput(t *testing.T) {
2938 })
3039
3140 t .Run (" OK Payload with a nil Header" , func (t * testing.T ) {
41+ t .Parallel ()
3242 payload := & common.Payload {
3343 Header : nil ,
3444 Data : []byte ("some data" ),
@@ -45,6 +55,7 @@ func TestUnwrapEnvelopeBadInput(t *testing.T) {
4555 })
4656
4757 t .Run ("OK payload but invalid ChannelHeader" , func (t * testing.T ) {
58+ t .Parallel ()
4859 header := & common.Header {
4960 ChannelHeader : []byte ("not-a-channel-header" ),
5061 }
@@ -64,9 +75,9 @@ func TestUnwrapEnvelopeBadInput(t *testing.T) {
6475 })
6576}
6677
67- // Test properly wrapped envelope is unwrapped correctly
78+ // TestUnwrapEnvelopeGoodInput Tests properly wrapped envelope is unwrapped correctly.
6879func TestUnwrapEnvelopeGoodInput (t * testing.T ) {
69-
80+ t . Parallel ()
7081 // -1- Check unwrap envelope has no error
7182 originalPayload := []byte ("test payload" )
7283 originalChannelHeader := & common.ChannelHeader {
@@ -75,7 +86,6 @@ func TestUnwrapEnvelopeGoodInput(t *testing.T) {
7586 originalHeader := & common.Header {
7687 ChannelHeader : protoutil .MarshalOrPanic (originalChannelHeader ),
7788 }
78-
7989 wrappedEnvelope := serialization .WrapEnvelope (originalPayload , originalHeader )
8090 payload , channelHeader , err := serialization .UnwrapEnvelope (wrappedEnvelope )
8191
0 commit comments