Skip to content

Commit

Permalink
[FAB-5511]Combine management client and resource client
Browse files Browse the repository at this point in the history
Change-Id: Ice6caebeab4d1dbc4f9276e977730fb6537225d8
Signed-off-by: biljana lukovic <biljana.lukovic@securekey.com>
Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
biljanaLukovic authored and troyronda committed Feb 16, 2018
1 parent 1f2274d commit 20be9f0
Show file tree
Hide file tree
Showing 27 changed files with 295 additions and 510 deletions.
35 changes: 0 additions & 35 deletions api/apitxn/chmgmtclient/chmgmt.go

This file was deleted.

15 changes: 0 additions & 15 deletions api/apitxn/chmgmtclient/opts.go

This file was deleted.

8 changes: 8 additions & 0 deletions api/apitxn/resmgmtclient/opts.go
Expand Up @@ -35,3 +35,11 @@ func WithTimeout(timeout time.Duration) Option {
return nil
}
}

//WithOrdererID encapsulates OrdererID to Option
func WithOrdererID(ordererID string) Option {
return func(opts *Opts) error {
opts.OrdererID = ordererID
return nil
}
}
14 changes: 14 additions & 0 deletions api/apitxn/resmgmtclient/resmgmt.go
Expand Up @@ -59,6 +59,17 @@ type Opts struct {
Targets []fab.Peer // target peers
TargetFilter TargetFilter // target filter
Timeout time.Duration //timeout options for instantiate and upgrade CC
OrdererID string // use specific orderer
}

//SaveChannelRequest used to save channel request
type SaveChannelRequest struct {
// Channel Name (ID)
ChannelID string
// Path to channel configuration file
ChannelConfig string
// User that signs channel configuration
SigningIdentity fab.IdentityContext
}

//Option func for each Opts argument
Expand All @@ -78,4 +89,7 @@ type ResourceMgmtClient interface {

// JoinChannel allows for peers to join existing channel with optional custom options (specific peers, filtered peers)
JoinChannel(channelID string, options ...Option) error

// SaveChannel creates or updates channel with optional Opts options
SaveChannel(req SaveChannelRequest, options ...Option) error
}
33 changes: 33 additions & 0 deletions pkg/fabric-client/resource/resource_test.go
Expand Up @@ -24,6 +24,39 @@ import (
"google.golang.org/grpc"
)

func TestExtractChannelConfig(t *testing.T) {
client := setupTestClient()

configTx, err := ioutil.ReadFile(path.Join("../../../", metadata.ChannelConfigPath, "mychannel.tx"))
if err != nil {
t.Fatalf(err.Error())
}

_, err = client.ExtractChannelConfig(configTx)
if err != nil {
t.Fatalf(err.Error())
}
}

func TestSignChannelConfig(t *testing.T) {
client := setupTestClient()

configTx, err := ioutil.ReadFile(path.Join("../../../", metadata.ChannelConfigPath, "mychannel.tx"))
if err != nil {
t.Fatalf(err.Error())
}

_, err = client.SignChannelConfig(nil, nil)
if err == nil {
t.Fatalf("Expected 'channel configuration required")
}

_, err = client.SignChannelConfig(configTx, nil)
if err != nil {
t.Fatalf("Expected 'channel configuration required %v", err)
}
}

func TestCreateChannel(t *testing.T) {
client := setupTestClient()

Expand Down
136 changes: 0 additions & 136 deletions pkg/fabric-txn/chmgmtclient/chmgmt.go

This file was deleted.

0 comments on commit 20be9f0

Please sign in to comment.