github.com/osdi23p228/fabric@v0.0.0-20221218062954-77808885f5db/internal/pkg/txflags/validation_flags_test.go (about)

     1  /*
     2  Copyright IBM Corp. 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/assert"
    14  )
    15  
    16  func TestTransactionValidationFlags(t *testing.T) {
    17  	txFlags := NewWithValues(10, peer.TxValidationCode_VALID)
    18  	assert.Equal(t, 10, len(txFlags))
    19  
    20  	txFlags.SetFlag(0, peer.TxValidationCode_VALID)
    21  	assert.Equal(t, peer.TxValidationCode_VALID, txFlags.Flag(0))
    22  	assert.Equal(t, true, txFlags.IsValid(0))
    23  
    24  	txFlags.SetFlag(1, peer.TxValidationCode_MVCC_READ_CONFLICT)
    25  	assert.Equal(t, true, txFlags.IsInvalid(1))
    26  }