-
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.
Merge "Fix peer panic at initiate proposal with no MSPs"
- Loading branch information
Showing
3 changed files
with
115 additions
and
38 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
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,56 @@ | ||
/* | ||
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 mgmt | ||
|
||
import ( | ||
"testing" | ||
|
||
configvaluesmsp "github.com/hyperledger/fabric/common/configvalues/msp" | ||
"github.com/hyperledger/fabric/msp" | ||
) | ||
|
||
func TestGetManagerForChains(t *testing.T) { | ||
// MSPManager for channel does not exist prior to this call | ||
mspMgr1 := GetManagerForChain("test") | ||
// ensure MSPManager is set | ||
if mspMgr1 == nil { | ||
t.FailNow() | ||
} | ||
|
||
// MSPManager for channel now exists | ||
mspMgr2 := GetManagerForChain("test") | ||
// ensure MSPManager returned matches the first result | ||
if mspMgr2 != mspMgr1 { | ||
t.FailNow() | ||
} | ||
} | ||
|
||
func TestGetManagerForChains_usingMSPConfigHandlers(t *testing.T) { | ||
XXXSetMSPManager("test", &configvaluesmsp.MSPConfigHandler{MSPManager: nil}) | ||
msp1 := GetManagerForChain("test") | ||
// return value should be nil because the MSPManager was not initialized | ||
if msp1 != nil { | ||
t.Fatalf("MSPManager should have been nil") | ||
} | ||
|
||
XXXSetMSPManager("foo", &configvaluesmsp.MSPConfigHandler{MSPManager: msp.NewMSPManager()}) | ||
msp2 := GetManagerForChain("foo") | ||
// return value should be set because the MSPManager was initialized | ||
if msp2 == nil { | ||
t.FailNow() | ||
} | ||
} |
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