Skip to content

Commit 8670c56

Browse files
committed
[FAB-3485] improve test coverage for msp
Test output for msp now is coverage: 86.1% of statements ok github.com/hyperledger/fabric/msp 0.054s Change-Id: Ic6fb239df31074224bd150d24305cb098dcc13d8 Signed-off-by: Alessandro Sorniotti <[email protected]>
1 parent a97886a commit 8670c56

File tree

4 files changed

+422
-6
lines changed

4 files changed

+422
-6
lines changed

msp/configbuilder_test.go

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 msp
18+
19+
import (
20+
"testing"
21+
22+
"github.com/hyperledger/fabric/core/config"
23+
"github.com/stretchr/testify/assert"
24+
)
25+
26+
func TestGetLocalMspConfig(t *testing.T) {
27+
mspDir, err := config.GetDevMspDir()
28+
assert.NoError(t, err)
29+
_, err = GetLocalMspConfig(mspDir, nil, "DEFAULT")
30+
assert.NoError(t, err)
31+
}
32+
33+
func TestGetLocalMspConfigFails(t *testing.T) {
34+
_, err := GetLocalMspConfig("/tmp/", nil, "DEFAULT")
35+
assert.Error(t, err)
36+
}
37+
38+
func TestReadFileUtils(t *testing.T) {
39+
// test that reading a file with an empty path doesn't crash
40+
_, err := readPemFile("")
41+
assert.Error(t, err)
42+
43+
// test that reading an existing file which is not a PEM file doesn't crash
44+
_, err = readPemFile("/dev/null")
45+
assert.Error(t, err)
46+
}

msp/identities.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ func (id *identity) Verify(msg []byte, sig []byte) error {
144144

145145
func (id *identity) VerifyOpts(msg []byte, sig []byte, opts SignatureOpts) error {
146146
// TODO
147-
return nil
147+
return errors.New("This method is unimplemented")
148148
}
149149

150150
func (id *identity) VerifyAttributes(proof []byte, spec *AttributeProofSpec) error {
151151
// TODO
152-
return nil
152+
return errors.New("This method is unimplemented")
153153
}
154154

155155
// Serialize returns a byte array representation of this identity
@@ -225,12 +225,12 @@ func (id *signingidentity) Sign(msg []byte) ([]byte, error) {
225225

226226
func (id *signingidentity) SignOpts(msg []byte, opts SignatureOpts) ([]byte, error) {
227227
// TODO
228-
return nil, nil
228+
return nil, errors.New("This method is unimplemented")
229229
}
230230

231231
func (id *signingidentity) GetAttributeProof(spec *AttributeProofSpec) (proof []byte, err error) {
232232
// TODO
233-
return nil, nil
233+
return nil, errors.New("This method is unimplemented")
234234
}
235235

236236
func (id *signingidentity) GetPublicVersion() Identity {
@@ -239,5 +239,5 @@ func (id *signingidentity) GetPublicVersion() Identity {
239239

240240
func (id *signingidentity) Renew() error {
241241
// TODO
242-
return nil
242+
return errors.New("This method is unimplemented")
243243
}

0 commit comments

Comments
 (0)