@@ -2170,6 +2170,134 @@ var _ = Describe("EndToEnd Smart BFT configuration test", func() {
21702170 invokeQuery (network , peer , network .Orderers [0 ], channel , 80 )
21712171 assertBlockReception (map [string ]int {channel : 6 }, network .Orderers , peer , network )
21722172 })
2173+
2174+ It ("remove channel from all orderers and add channel back" , func () {
2175+ networkConfig := nwo .MultiNodeSmartBFT ()
2176+ networkConfig .Channels = nil
2177+
2178+ network = nwo .New (networkConfig , testDir , client , StartPort (), components )
2179+ network .GenerateConfigTree ()
2180+ network .Bootstrap ()
2181+
2182+ network .EventuallyTimeout *= 2
2183+
2184+ var ordererRunners []* ginkgomon.Runner
2185+ for _ , orderer := range network .Orderers {
2186+ runner := network .OrdererRunner (orderer )
2187+ runner .Command .Env = append (runner .Command .Env , "FABRIC_LOGGING_SPEC=orderer.common.cluster=debug:orderer.consensus.smartbft=debug:policies.ImplicitOrderer=debug" )
2188+ ordererRunners = append (ordererRunners , runner )
2189+ proc := ifrit .Invoke (runner )
2190+ ordererProcesses = append (ordererProcesses , proc )
2191+ Eventually (proc .Ready (), network .EventuallyTimeout ).Should (BeClosed ())
2192+ }
2193+
2194+ peer := network .Peer ("Org1" , "peer0" )
2195+
2196+ sess , err := network .ConfigTxGen (commands.OutputBlock {
2197+ ChannelID : "testchannel1" ,
2198+ Profile : network .Profiles [0 ].Name ,
2199+ ConfigPath : network .RootDir ,
2200+ OutputBlock : network .OutputBlockPath ("testchannel1" ),
2201+ })
2202+ Expect (err ).NotTo (HaveOccurred ())
2203+ Eventually (sess , network .EventuallyTimeout ).Should (gexec .Exit (0 ))
2204+
2205+ genesisBlockBytes , err := os .ReadFile (network .OutputBlockPath ("testchannel1" ))
2206+ Expect (err ).NotTo (HaveOccurred ())
2207+
2208+ genesisBlock := & common.Block {}
2209+ err = proto .Unmarshal (genesisBlockBytes , genesisBlock )
2210+ Expect (err ).NotTo (HaveOccurred ())
2211+
2212+ expectedChannelInfoPT := channelparticipation.ChannelInfo {
2213+ Name : "testchannel1" ,
2214+ URL : "/participation/v1/channels/testchannel1" ,
2215+ Status : "active" ,
2216+ ConsensusRelation : "consenter" ,
2217+ Height : 1 ,
2218+ }
2219+
2220+ for _ , o := range network .Orderers {
2221+ By ("joining " + o .Name + " to channel as a consenter" )
2222+ channelparticipation .Join (network , o , "testchannel1" , genesisBlock , expectedChannelInfoPT )
2223+ channelInfo := channelparticipation .ListOne (network , o , "testchannel1" )
2224+ Expect (channelInfo ).To (Equal (expectedChannelInfoPT ))
2225+ }
2226+
2227+ By ("Waiting for followers to see the leader" )
2228+ Eventually (ordererRunners [1 ].Err (), network .EventuallyTimeout , time .Second ).Should (gbytes .Say ("Message from 1" ))
2229+ Eventually (ordererRunners [2 ].Err (), network .EventuallyTimeout , time .Second ).Should (gbytes .Say ("Message from 1" ))
2230+ Eventually (ordererRunners [3 ].Err (), network .EventuallyTimeout , time .Second ).Should (gbytes .Say ("Message from 1" ))
2231+
2232+ assertBlockReception (map [string ]int {"testchannel1" : 0 }, network .Orderers , peer , network )
2233+
2234+ By ("Removing channel from all orderers" )
2235+ for _ , o := range network .Orderers {
2236+ ready := make (chan struct {})
2237+ go func () {
2238+ defer GinkgoRecover ()
2239+ channelparticipation .Remove (network , o , "testchannel" )
2240+ close (ready )
2241+ }()
2242+ Eventually (ready , network .EventuallyTimeout ).Should (BeClosed ())
2243+
2244+ Eventually (func () int { // Removal is async
2245+ channelList := channelparticipation .List (network , o )
2246+ return len (channelList .Channels )
2247+ }()).Should (BeZero ())
2248+ }
2249+
2250+ By ("Re-create the genesis block" )
2251+ sess , err = network .ConfigTxGen (commands.OutputBlock {
2252+ ChannelID : "testchannel1" ,
2253+ Profile : network .Profiles [0 ].Name ,
2254+ ConfigPath : network .RootDir ,
2255+ OutputBlock : network .OutputBlockPath ("testchannel1" ),
2256+ })
2257+ Expect (err ).NotTo (HaveOccurred ())
2258+ Eventually (sess , network .EventuallyTimeout ).Should (gexec .Exit (0 ))
2259+
2260+ genesisBlockBytes , err = os .ReadFile (network .OutputBlockPath ("testchannel1" ))
2261+ Expect (err ).NotTo (HaveOccurred ())
2262+
2263+ genesisBlock = & common.Block {}
2264+ err = proto .Unmarshal (genesisBlockBytes , genesisBlock )
2265+ Expect (err ).NotTo (HaveOccurred ())
2266+
2267+ expectedChannelInfoPT = channelparticipation.ChannelInfo {
2268+ Name : "testchannel1" ,
2269+ URL : "/participation/v1/channels/testchannel1" ,
2270+ Status : "active" ,
2271+ ConsensusRelation : "consenter" ,
2272+ Height : 1 ,
2273+ }
2274+
2275+ for _ , o := range network .Orderers {
2276+ By ("joining " + o .Name + " to channel as a consenter" )
2277+ channelparticipation .Join (network , o , "testchannel1" , genesisBlock , expectedChannelInfoPT )
2278+ channelInfo := channelparticipation .ListOne (network , o , "testchannel1" )
2279+ Expect (channelInfo ).To (Equal (expectedChannelInfoPT ))
2280+ }
2281+
2282+ By ("Waiting for followers to see the leader" )
2283+ Eventually (ordererRunners [1 ].Err (), network .EventuallyTimeout , time .Second ).Should (gbytes .Say ("Message from 1" ))
2284+ Eventually (ordererRunners [2 ].Err (), network .EventuallyTimeout , time .Second ).Should (gbytes .Say ("Message from 1" ))
2285+ Eventually (ordererRunners [3 ].Err (), network .EventuallyTimeout , time .Second ).Should (gbytes .Say ("Message from 1" ))
2286+
2287+ assertBlockReception (map [string ]int {
2288+ "testchannel" : 0 ,
2289+ }, network .Orderers , peer , network )
2290+
2291+ By ("Submitting tx" )
2292+ env := ordererclient .CreateBroadcastEnvelope (network , network .Orderers [0 ], "testchannel" , []byte ("foo" ))
2293+ resp , err := ordererclient .Broadcast (network , network .Orderers [0 ], env )
2294+ Expect (err ).NotTo (HaveOccurred ())
2295+ Expect (resp .Status ).To (Equal (common .Status_SUCCESS ))
2296+
2297+ assertBlockReception (map [string ]int {
2298+ "testchannel" : 1 ,
2299+ }, network .Orderers , peer , network )
2300+ })
21732301 })
21742302})
21752303
0 commit comments