Skip to content

Commit

Permalink
[FAB-17743] Rename ConfigTx accessors
Browse files Browse the repository at this point in the history
Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
  • Loading branch information
stephyee authored and mastersingh24 committed Apr 17, 2020
1 parent 21816cb commit 65d3817
Show file tree
Hide file tree
Showing 18 changed files with 179 additions and 179 deletions.
2 changes: 1 addition & 1 deletion integration/configtx/configtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var _ = Describe("Config", func() {

By("ensuring the active channel config matches the submitted config")
finalChannelConfig := nwo.GetConfig(network, peer, orderer, "testchannel")
Expect(c.Updated()).To(Equal(finalChannelConfig))
Expect(c.UpdatedConfig()).To(Equal(finalChannelConfig))
}
})
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/configtx/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Application struct {
// transaction as an Application type. This can be used to retrieve existing values for the application
// prior to updating the application configuration.
func (c *ConfigTx) ApplicationConfiguration() (Application, error) {
applicationGroup, ok := c.base.ChannelGroup.Groups[ApplicationGroupKey]
applicationGroup, ok := c.original.ChannelGroup.Groups[ApplicationGroupKey]
if !ok {
return Application{}, errors.New("config does not contain application group")
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func (c *ConfigTx) RemoveACLs(acls []string) error {

// ApplicationACLs returns a map of application acls from a config transaction.
func (c *ConfigTx) ApplicationACLs() (map[string]string, error) {
return getACLs(c.base)
return getACLs(c.original)
}

// getACLs returns a map of ACLS for given config application.
Expand All @@ -222,7 +222,7 @@ func getACLs(config *cb.Config) (map[string]string, error) {

// AnchorPeers retrieves existing anchor peers from a application organization.
func (c *ConfigTx) AnchorPeers(orgName string) ([]Address, error) {
applicationOrgGroup, ok := c.base.ChannelGroup.Groups[ApplicationGroupKey].Groups[orgName]
applicationOrgGroup, ok := c.original.ChannelGroup.Groups[ApplicationGroupKey].Groups[orgName]
if !ok {
return nil, fmt.Errorf("application org %s does not exist in channel config", orgName)
}
Expand Down
54 changes: 27 additions & 27 deletions pkg/configtx/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ func TestAddAnchorPeer(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

newOrg1AnchorPeer := Address{
Expand Down Expand Up @@ -429,8 +429,8 @@ func TestAddAnchorPeerFailure(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

if tt.configMod != nil {
Expand Down Expand Up @@ -464,8 +464,8 @@ func TestRemoveAnchorPeer(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

expectedUpdatedConfigJSON := `
Expand Down Expand Up @@ -622,8 +622,8 @@ func TestRemoveAnchorPeerFailure(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

err = c.RemoveAnchorPeer(tt.orgName, tt.anchorPeerToRemove)
Expand All @@ -649,8 +649,8 @@ func TestAnchorPeer(t *testing.T) {

expectedAnchorPeer := Address{Host: "host1", Port: 123}
c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

err = c.AddAnchorPeer("Org1", expectedAnchorPeer)
Expand Down Expand Up @@ -687,8 +687,8 @@ func TestAnchorPeerFailures(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

for _, test := range []struct {
Expand Down Expand Up @@ -763,8 +763,8 @@ func TestAddACL(t *testing.T) {
tt.configMod(config)
}
c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

err = c.AddACLs(tt.newACL)
Expand Down Expand Up @@ -837,8 +837,8 @@ func TestRemoveACL(t *testing.T) {
tt.configMod(config)
}
c := &ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

err = c.RemoveACLs(tt.removeACL)
Expand Down Expand Up @@ -871,8 +871,8 @@ func TestAddApplicationOrg(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

org := Organization{
Expand Down Expand Up @@ -1058,8 +1058,8 @@ func TestAddApplicationOrgFailures(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

org := Organization{
Expand Down Expand Up @@ -1087,8 +1087,8 @@ func TestApplicationConfiguration(t *testing.T) {
}

c := &ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}
for _, org := range baseApplicationConf.Organizations {
err = c.AddApplicationOrg(org)
Expand All @@ -1114,7 +1114,7 @@ func TestApplicationConfigurationFailure(t *testing.T) {
{
testName: "When the application group does not exist",
configMod: func(ct *ConfigTx, appOrg Application, gt *GomegaWithT) {
delete(ct.base.ChannelGroup.Groups, ApplicationGroupKey)
delete(ct.original.ChannelGroup.Groups, ApplicationGroupKey)
},
expectedErr: "config does not contain application group",
},
Expand Down Expand Up @@ -1152,8 +1152,8 @@ func TestApplicationConfigurationFailure(t *testing.T) {
}

c := &ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}
if tt.configMod != nil {
tt.configMod(c, baseApplicationConf, gt)
Expand Down Expand Up @@ -1183,7 +1183,7 @@ func TestApplicationACLs(t *testing.T) {
}

c := &ConfigTx{
base: config,
original: config,
}

applicationACLs, err := c.ApplicationACLs()
Expand All @@ -1203,7 +1203,7 @@ func TestApplicationACLsFailure(t *testing.T) {
}

c := &ConfigTx{
base: config,
original: config,
}

applicationACLs, err := c.ApplicationACLs()
Expand Down
6 changes: 3 additions & 3 deletions pkg/configtx/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// ChannelCapabilities returns a map of enabled channel capabilities
// from a config transaction.
func (c *ConfigTx) ChannelCapabilities() ([]string, error) {
capabilities, err := getCapabilities(c.base.ChannelGroup)
capabilities, err := getCapabilities(c.original.ChannelGroup)
if err != nil {
return nil, fmt.Errorf("retrieving channel capabilities: %v", err)
}
Expand All @@ -28,7 +28,7 @@ func (c *ConfigTx) ChannelCapabilities() ([]string, error) {
// OrdererCapabilities returns a map of enabled orderer capabilities
// from a config transaction.
func (c *ConfigTx) OrdererCapabilities() ([]string, error) {
orderer, ok := c.base.ChannelGroup.Groups[OrdererGroupKey]
orderer, ok := c.original.ChannelGroup.Groups[OrdererGroupKey]
if !ok {
return nil, errors.New("orderer missing from config")
}
Expand All @@ -44,7 +44,7 @@ func (c *ConfigTx) OrdererCapabilities() ([]string, error) {
// ApplicationCapabilities returns a map of enabled application capabilities
// from a config transaction.
func (c *ConfigTx) ApplicationCapabilities() ([]string, error) {
application, ok := c.base.ChannelGroup.Groups[ApplicationGroupKey]
application, ok := c.original.ChannelGroup.Groups[ApplicationGroupKey]
if !ok {
return nil, errors.New("application missing from config")
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/configtx/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestChannelCapabilities(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

err := setValue(config.ChannelGroup, capabilitiesValue(expectedCapabilities), AdminsPolicyKey)
Expand Down Expand Up @@ -69,8 +69,8 @@ func TestOrdererCapabilities(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

ordererCapabilities, err := c.OrdererCapabilities()
Expand All @@ -96,8 +96,8 @@ func TestOrdererCapabilitiesFailure(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

ordererCapabilities, err := c.OrdererCapabilities()
Expand All @@ -123,8 +123,8 @@ func TestApplicationCapabilities(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

applicationCapabilities, err := c.ApplicationCapabilities()
Expand All @@ -150,8 +150,8 @@ func TestApplicationCapabilitiesFailure(t *testing.T) {
}

c := ConfigTx{
base: config,
updated: config,
original: config,
updated: config,
}

applicationCapabilities, err := c.ApplicationCapabilities()
Expand Down
20 changes: 10 additions & 10 deletions pkg/configtx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ type standardConfigPolicy struct {
value *cb.Policy
}

// ConfigTx wraps a config transaction
// ConfigTx wraps a config transaction.
type ConfigTx struct {
// original state of the config
base *cb.Config
original *cb.Config
// modified state of the config
updated *cb.Config
}

// New returns an config.
func New(config *cb.Config) ConfigTx {
return ConfigTx{
base: config,
original: config,
// Clone the base config for processing updates
updated: proto.Clone(config).(*cb.Config),
}
}

// Base returns the base config
func (c *ConfigTx) Base() *cb.Config {
return c.base
// OriginalConfig returns the original unedited config.
func (c *ConfigTx) OriginalConfig() *cb.Config {
return c.original
}

// Updated returns the updated config
func (c *ConfigTx) Updated() *cb.Config {
// UpdatedConfig returns the modified config.
func (c *ConfigTx) UpdatedConfig() *cb.Config {
return c.updated
}

Expand All @@ -107,7 +107,7 @@ func (c *ConfigTx) ComputeUpdate(channelID string) (*cb.ConfigUpdate, error) {
return nil, errors.New("channel ID is required")
}

updt, err := computeConfigUpdate(c.base, c.updated)
updt, err := computeConfigUpdate(c.original, c.updated)
if err != nil {
return nil, fmt.Errorf("failed to compute update: %v", err)
}
Expand All @@ -119,7 +119,7 @@ func (c *ConfigTx) ComputeUpdate(channelID string) (*cb.ConfigUpdate, error) {

// ChannelConfiguration returns a channel configuration value from a config transaction.
func (c *ConfigTx) ChannelConfiguration() (Channel, error) {
channelGroup := c.base.ChannelGroup
channelGroup := c.original.ChannelGroup
var (
err error
consortium string
Expand Down
8 changes: 4 additions & 4 deletions pkg/configtx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,8 @@ func TestComputeUpdate(t *testing.T) {
}

c := ConfigTx{
base: base,
updated: updated,
original: base,
updated: updated,
}

channelID := "testChannel"
Expand Down Expand Up @@ -1314,8 +1314,8 @@ func TestComputeUpdateFailures(t *testing.T) {
updated := &cb.Config{}

c := ConfigTx{
base: base,
updated: updated,
original: base,
updated: updated,
}

for _, test := range []struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/configtx/consortiums.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (c *ConfigTx) AddOrgToConsortium(org Organization, consortium string) error
// Consortiums returns a list of consortiums for the channel configuration.
// Consortiums is only defined for the ordering system channel.
func (c *ConfigTx) Consortiums() ([]Consortium, error) {
consortiumsGroup, ok := c.base.ChannelGroup.Groups[ConsortiumsGroupKey]
consortiumsGroup, ok := c.original.ChannelGroup.Groups[ConsortiumsGroupKey]
if !ok {
return nil, errors.New("channel configuration does not have consortiums")
}
Expand Down
Loading

0 comments on commit 65d3817

Please sign in to comment.