github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/internal/pkg/txflags/validation_flags_test.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package txflags
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/hyperledger/fabric-protos-go/peer"
    13  	"github.com/stretchr/testify/require"
    14  )
    15  
    16  func TestTransactionValidationFlags(t *testing.T) {
    17  	txFlags := NewWithValues(10, peer.TxValidationCode_VALID)
    18  	require.Equal(t, 10, len(txFlags))
    19  
    20  	txFlags.SetFlag(0, peer.TxValidationCode_VALID)
    21  	require.Equal(t, peer.TxValidationCode_VALID, txFlags.Flag(0))
    22  	require.Equal(t, true, txFlags.IsValid(0))
    23  
    24  	txFlags.SetFlag(1, peer.TxValidationCode_MVCC_READ_CONFLICT)
    25  	require.Equal(t, true, txFlags.IsInvalid(1))
    26  }