github.com/kchristidis/fabric@v1.0.4-0.20171028114726-837acd08cde1/protos/common/configuration_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package common
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestConfiguration(t *testing.T) {
    16  	var h *HashingAlgorithm
    17  	var b *BlockDataHashingStructure
    18  	var o *OrdererAddresses
    19  	var c *Consortium
    20  
    21  	h = nil
    22  	assert.Equal(t, "", h.GetName())
    23  	h = &HashingAlgorithm{Name: "SHA256"}
    24  	assert.Equal(t, "SHA256", h.GetName())
    25  	h.Reset()
    26  	_ = h.String()
    27  	_, _ = h.Descriptor()
    28  	h.ProtoMessage()
    29  	assert.Equal(t, "", h.GetName())
    30  
    31  	b = nil
    32  	assert.Equal(t, uint32(0), b.GetWidth())
    33  	b = &BlockDataHashingStructure{Width: uint32(1)}
    34  	assert.Equal(t, uint32(1), b.GetWidth())
    35  	b.Reset()
    36  	_ = b.String()
    37  	_, _ = b.Descriptor()
    38  	b.ProtoMessage()
    39  	assert.Equal(t, uint32(0), b.GetWidth())
    40  
    41  	o = nil
    42  	assert.Nil(t, o.GetAddresses())
    43  	o = &OrdererAddresses{Addresses: []string{"address"}}
    44  	assert.Equal(t, "address", o.GetAddresses()[0])
    45  	o.Reset()
    46  	_ = o.String()
    47  	_, _ = o.Descriptor()
    48  	o.ProtoMessage()
    49  	assert.Nil(t, o.GetAddresses())
    50  
    51  	c = nil
    52  	assert.Equal(t, "", c.GetName())
    53  	c = &Consortium{Name: "consortium"}
    54  	assert.Equal(t, "consortium", c.GetName())
    55  	c.Reset()
    56  	_ = c.String()
    57  	_, _ = c.Descriptor()
    58  	c.ProtoMessage()
    59  	assert.Equal(t, "", c.GetName())
    60  
    61  }