forked from hyperledger/fabric-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mocklocal.go
42 lines (33 loc) · 1.02 KB
/
mocklocal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package mocks
import (
"fmt"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
)
// LocalContext supplies the configuration for channel context client
type LocalContext struct {
*MockContext
localDiscovery fab.DiscoveryService
}
// LocalDiscoveryService returns the local discovery service
func (c *LocalContext) LocalDiscoveryService() fab.DiscoveryService {
return c.localDiscovery
}
// NewMockLocalContext creates new mock local context
func NewMockLocalContext(client *MockContext, discoveryProvider fab.LocalDiscoveryProvider) *LocalContext {
var localDiscovery fab.DiscoveryService
if discoveryProvider != nil {
var err error
localDiscovery, err = discoveryProvider.CreateLocalDiscoveryService(client.Identifier().MSPID)
if err != nil {
panic(fmt.Sprintf("error creating local discovery service: %s", err))
}
}
return &LocalContext{
MockContext: client,
localDiscovery: localDiscovery,
}
}