Skip to content

Commit 347e995

Browse files
committed
[FAB-3413] Increase coverage for core/ledger/util
This CR increases coverage for util.go and txvalidationflag.go to 100%. Will remove filterbitarray.go and filterbitarray_test.go in a separate CR as these files are not being used. Change-Id: I2a6c9d97af0a4674a3b6a019da3a93f0a01468fb Signed-off-by: senthil <[email protected]>
1 parent 1dfdee5 commit 347e995

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright IBM Corp. 2017 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package util
18+
19+
import (
20+
"testing"
21+
22+
"github.com/hyperledger/fabric/protos/peer"
23+
"github.com/stretchr/testify/assert"
24+
)
25+
26+
func TestTransactionValidationFlags(t *testing.T) {
27+
txFlags := NewTxValidationFlags(10)
28+
assert.Equal(t, 10, len(txFlags))
29+
30+
txFlags.SetFlag(0, peer.TxValidationCode_VALID)
31+
assert.Equal(t, peer.TxValidationCode_VALID, txFlags.Flag(0))
32+
assert.Equal(t, true, txFlags.IsValid(0))
33+
34+
txFlags.SetFlag(1, peer.TxValidationCode_MVCC_READ_CONFLICT)
35+
assert.Equal(t, true, txFlags.IsInvalid(1))
36+
}

core/ledger/util/util_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright IBM Corp. 2017 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package util
18+
19+
import (
20+
"testing"
21+
22+
"github.com/stretchr/testify/assert"
23+
)
24+
25+
func TestGetSortedKeys(t *testing.T) {
26+
mapKeyValue := make(map[string]int)
27+
mapKeyValue["blue"] = 10
28+
mapKeyValue["apple"] = 15
29+
mapKeyValue["red"] = 12
30+
mapKeyValue["123"] = 22
31+
mapKeyValue["a"] = 33
32+
mapKeyValue[""] = 30
33+
assert.Equal(t, []string{"", "123", "a", "apple", "blue", "red"}, GetSortedKeys(mapKeyValue))
34+
}

0 commit comments

Comments
 (0)