Skip to content

Commit

Permalink
remove solo as a consensus type (#63)
Browse files Browse the repository at this point in the history
Signed-off-by: May Rosenbaum <[email protected]>
  • Loading branch information
MayRosenbaum authored Aug 22, 2024
1 parent 71a6407 commit cbee329
Show file tree
Hide file tree
Showing 6 changed files with 629 additions and 147 deletions.
28 changes: 22 additions & 6 deletions configtx/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"fmt"
"testing"

"github.com/hyperledger/fabric-config/configtx/orderer"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/protolator"
cb "github.com/hyperledger/fabric-protos-go/common"
Expand Down Expand Up @@ -430,7 +432,12 @@ func TestNewSystemChannelGenesisBlock(t *testing.T) {
profile, _, _ := baseSystemChannelProfile(t)

block, err := NewSystemChannelGenesisBlock(profile, "testsystemchannel")
gt.Expect(err).ToNot(HaveOccurred())
if profile.Orderer.OrdererType != orderer.ConsensusTypeSolo {
gt.Expect(err).ToNot(HaveOccurred())
} else {
gt.Expect(err.Error()).To(ContainSubstring("the solo consensus type is no longer supported"))
return
}
gt.Expect(block).ToNot(BeNil())
gt.Expect(block.Header.Number).To(Equal(uint64(0)))

Expand Down Expand Up @@ -1103,7 +1110,7 @@ func TestNewSystemChannelGenesisBlockFailure(t *testing.T) {
return profile
},
channelID: "testsystemchannel",
err: errors.New("creating system channel group: orderer endpoints are not defined for org OrdererOrg"),
err: errors.New("creating system channel group: the solo consensus type is no longer supported"),
},
{
testName: "When creating the default config template with empty capabilities",
Expand Down Expand Up @@ -1151,7 +1158,12 @@ func TestNewApplicationChannelGenesisBlock(t *testing.T) {
profile, _, _ := baseApplicationChannelProfile(t)

block, err := NewApplicationChannelGenesisBlock(profile, "testapplicationchannel")
gt.Expect(err).ToNot(HaveOccurred())
if profile.Orderer.OrdererType != orderer.ConsensusTypeSolo {
gt.Expect(err).ToNot(HaveOccurred())
} else {
gt.Expect(err.Error()).To(ContainSubstring("the solo consensus type is no longer supported"))
return
}
gt.Expect(block).ToNot(BeNil())
gt.Expect(block.Header.Number).To(Equal(uint64(0)))

Expand Down Expand Up @@ -1863,7 +1875,7 @@ func TestNewApplicationChannelGenesisBlockFailure(t *testing.T) {
return profile
},
channelID: "testapplicationchannel",
err: errors.New("creating application channel group: orderer endpoints are not defined for org OrdererOrg"),
err: errors.New("creating application channel group: the solo consensus type is no longer supported"),
},
{
testName: "When creating the default config template with empty capabilities",
Expand All @@ -1883,7 +1895,7 @@ func TestNewApplicationChannelGenesisBlockFailure(t *testing.T) {
return profile
},
channelID: "testapplicationchannel",
err: errors.New("creating application channel group: no policies defined"),
err: errors.New("creating application channel group: the solo consensus type is no longer supported"),
},
}

Expand Down Expand Up @@ -2084,7 +2096,7 @@ func TestChannelConfiguration(t *testing.T) {
ModPolicy: AdminsPolicyKey,
}
channelGroup, err := newSystemChannelGroup(channel)
gt.Expect(err).NotTo(HaveOccurred())
gt.Expect(err.Error()).To(ContainSubstring("the solo consensus type is no longer supported"))

return &cb.Config{
ChannelGroup: channelGroup,
Expand All @@ -2107,6 +2119,10 @@ func TestChannelConfiguration(t *testing.T) {

config := tt.configMod(gt)
c := New(config)
// when the consensus type is solo, the channelGroup is nil and an error is returned
if config.ChannelGroup == nil {
return
}

channel, err := c.Channel().Configuration()
gt.Expect(err).NotTo(HaveOccurred())
Expand Down
23 changes: 20 additions & 3 deletions configtx/consortiums_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"math/big"
"testing"

"github.com/hyperledger/fabric-config/configtx/orderer"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-config/protolator"
"github.com/hyperledger/fabric-config/protolator/protoext/commonext"
Expand Down Expand Up @@ -848,7 +850,12 @@ func TestGetConsortiums(t *testing.T) {
Consortium: "testconsortium",
}
channelGroup, err := newSystemChannelGroup(channel)
gt.Expect(err).NotTo(HaveOccurred())
if channel.Orderer.OrdererType != orderer.ConsensusTypeSolo {
gt.Expect(err).NotTo(HaveOccurred())
} else {
gt.Expect(err.Error()).To(ContainSubstring("the solo consensus type is no longer supported"))
return
}

config := &cb.Config{ChannelGroup: channelGroup}
c := New(config)
Expand Down Expand Up @@ -1426,7 +1433,12 @@ func TestConsortiumOrg(t *testing.T) {

channel, _, _ := baseSystemChannelProfile(t)
channelGroup, err := newSystemChannelGroup(channel)
gt.Expect(err).NotTo(HaveOccurred())
if channel.Orderer.OrdererType != orderer.ConsensusTypeSolo {
gt.Expect(err).NotTo(HaveOccurred())
} else {
gt.Expect(err.Error()).To(ContainSubstring("the solo consensus type is no longer supported"))
return
}

config := &cb.Config{
ChannelGroup: channelGroup,
Expand Down Expand Up @@ -1474,7 +1486,12 @@ func TestRemoveConsortiumOrg(t *testing.T) {

channel, _, _ := baseSystemChannelProfile(t)
channelGroup, err := newSystemChannelGroup(channel)
gt.Expect(err).NotTo(HaveOccurred())
if channel.Orderer.OrdererType != orderer.ConsensusTypeSolo {
gt.Expect(err).NotTo(HaveOccurred())
} else {
gt.Expect(err.Error()).To(ContainSubstring("the solo consensus type is no longer supported"))
return
}

config := &cb.Config{
ChannelGroup: channelGroup,
Expand Down
Loading

0 comments on commit cbee329

Please sign in to comment.