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