txvalidationflags_test.go 633 Bytes
Newer Older
1
/*
2
Copyright IBM Corp. All Rights Reserved.
3

4
SPDX-License-Identifier: Apache-2.0
5
6
7
8
9
10
11
12
13
14
15
16
*/

package util

import (
	"testing"

	"github.com/hyperledger/fabric/protos/peer"
	"github.com/stretchr/testify/assert"
)

func TestTransactionValidationFlags(t *testing.T) {
17
	txFlags := NewTxValidationFlagsSetValue(10, peer.TxValidationCode_VALID)
18
19
20
21
22
23
24
25
26
	assert.Equal(t, 10, len(txFlags))

	txFlags.SetFlag(0, peer.TxValidationCode_VALID)
	assert.Equal(t, peer.TxValidationCode_VALID, txFlags.Flag(0))
	assert.Equal(t, true, txFlags.IsValid(0))

	txFlags.SetFlag(1, peer.TxValidationCode_MVCC_READ_CONFLICT)
	assert.Equal(t, true, txFlags.IsInvalid(1))
}