-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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]>
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/protos/peer" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestTransactionValidationFlags(t *testing.T) { | ||
txFlags := NewTxValidationFlags(10) | ||
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetSortedKeys(t *testing.T) { | ||
mapKeyValue := make(map[string]int) | ||
mapKeyValue["blue"] = 10 | ||
mapKeyValue["apple"] = 15 | ||
mapKeyValue["red"] = 12 | ||
mapKeyValue["123"] = 22 | ||
mapKeyValue["a"] = 33 | ||
mapKeyValue[""] = 30 | ||
assert.Equal(t, []string{"", "123", "a", "apple", "blue", "red"}, GetSortedKeys(mapKeyValue)) | ||
} |