Skip to content

Commit

Permalink
[FAB-3485] improve test coverage for msp/mgmt
Browse files Browse the repository at this point in the history
Test output for msp/mgmt now is

coverage: 87.8% of statements
ok		github.com/hyperledger/fabric/msp/mgmt	0.033s

Change-Id: I6d34b9cf914d970b9a57de214cb4881c95fdbf13
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Apr 29, 2017
1 parent fa389de commit edd26e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 0 additions & 9 deletions msp/mgmt/mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,6 @@ func GetDeserializers() map[string]msp.IdentityDeserializer {
return clone
}

// GetManagerForChainIfExists returns the MSPManager associated to ChainID
// it it exists
func GetManagerForChainIfExists(ChainID string) msp.MSPManager {
m.Lock()
defer m.Unlock()

return mspMap[ChainID]
}

// XXXSetMSPManager is a stopgap solution to transition from the custom MSP config block
// parsing to the configtx.Manager interface, while preserving the problematic singleton
// nature of the MSP manager
Expand Down
14 changes: 14 additions & 0 deletions msp/mgmt/mgmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

configvaluesmsp "github.com/hyperledger/fabric/common/config/msp"
"github.com/hyperledger/fabric/msp"
"github.com/stretchr/testify/assert"
)

func TestGetManagerForChains(t *testing.T) {
Expand Down Expand Up @@ -54,3 +55,16 @@ func TestGetManagerForChains_usingMSPConfigHandlers(t *testing.T) {
t.FailNow()
}
}

func TestGetIdentityDeserializer(t *testing.T) {
XXXSetMSPManager("baz", &configvaluesmsp.MSPConfigHandler{MSPManager: msp.NewMSPManager()})
ids := GetIdentityDeserializer("baz")
assert.NotNil(t, ids)
ids = GetIdentityDeserializer("")
assert.NotNil(t, ids)
}

func TestGetLocalSigningIdentityOrPanic(t *testing.T) {
sid := GetLocalSigningIdentityOrPanic()
assert.NotNil(t, sid)
}

0 comments on commit edd26e1

Please sign in to comment.