public void RunFabricTest(SampleStore sStore)
        {
            ////////////////////////////
            // Setup client

            //Create instance of client.
            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.Instance.GetCryptoSuite();

            ////////////////////////////
            //Reconstruct and run the channels
            SampleOrg sampleOrg  = testConfig.GetIntegrationTestsSampleOrg("peerOrg1");
            Channel   fooChannel = ReconstructChannel(FOO_CHANNEL_NAME, client, sampleOrg);

            RunChannel(client, fooChannel, sampleOrg, 0);
            Assert.IsFalse(fooChannel.IsShutdown);
            Assert.IsTrue(fooChannel.IsInitialized);
            fooChannel.Shutdown(true); //clean up resources no longer needed.
            Assert.IsTrue(fooChannel.IsShutdown);
            Util.COut("\n");

            sampleOrg = testConfig.GetIntegrationTestsSampleOrg("peerOrg2");
            Channel barChannel = ReconstructChannel(BAR_CHANNEL_NAME, client, sampleOrg);

            RunChannel(client, barChannel, sampleOrg, 100); //run a newly constructed foo channel with different b value!
            Assert.IsFalse(barChannel.IsShutdown);
            Assert.IsTrue(barChannel.IsInitialized);

            if (!testConfig.IsRunningAgainstFabric10())
            {
                //Peer eventing service support started with v1.1

                // Now test replay feature of V1.1 peer eventing services.
                string json = barChannel.Serialize();
                barChannel.Shutdown(true);

                Channel replayChannel = client.DeSerializeChannel(json);

                Util.COut("doing testPeerServiceEventingReplay,0,-1,false");
                TestPeerServiceEventingReplay(client, replayChannel, 0L, -1L, false);

                replayChannel = client.DeSerializeChannel(json);
                Util.COut("doing testPeerServiceEventingReplay,0,-1,true"); // block 0 is import to test
                TestPeerServiceEventingReplay(client, replayChannel, 0L, -1L, true);

                //Now do it again starting at block 1
                replayChannel = client.DeSerializeChannel(json);
                Util.COut("doing testPeerServiceEventingReplay,1,-1,false");
                TestPeerServiceEventingReplay(client, replayChannel, 1L, -1L, false);

                //Now do it again starting at block 2 to 3
                replayChannel = client.DeSerializeChannel(json);
                Util.COut("doing testPeerServiceEventingReplay,2,3,false");
                TestPeerServiceEventingReplay(client, replayChannel, 2L, 3L, false);
            }

            Util.COut("That's all folks!");
        }
Exemplo n.º 2
0
        /**
         * Will register and enroll users persisting them to samplestore.
         *
         * @param sampleStore
         * @throws Exception
         */
        public void SetupUsers(SampleStore sampleStore)
        {
            foreach (SampleOrg sampleOrg in testSampleOrgs)
            {
                string orgName = sampleOrg.Name;

                SampleUser admin = sampleStore.GetMember(TEST_ADMIN_NAME, orgName);
                sampleOrg.Admin = admin; // The admin of this org.

                sampleOrg.PeerAdmin = sampleStore.GetMember(orgName + "Admin", orgName);
            }

            EnrollIdemixUser(sampleStore);
        }
Exemplo n.º 3
0
        public void Setup()
        {
            try
            {
                sampleStore = new SampleStore(sampleStoreFile);

                SetupUsers(sampleStore);
                RunFabricTest(sampleStore);
            }
            catch (System.Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 4
0
        public void EnrollIdemixUser(SampleStore sampleStore)
        {
            foreach (SampleOrg sampleOrg in testSampleOrgs)
            {
                HFCAClient ca = sampleOrg.CAClient;

                string orgName = sampleOrg.Name;
                string mspid   = sampleOrg.MSPID;
                ca.CryptoSuite = Factory.GetCryptoSuite();

                if (testConfig.IsRunningFabricTLS())
                {
                    //This shows how to get a client TLS certificate from Fabric CA
                    // we will use one client TLS certificate for orderer peers etc.
                    EnrollmentRequest enrollmentRequestTLS = new EnrollmentRequest();
                    enrollmentRequestTLS.AddHost("localhost");
                    enrollmentRequestTLS.Profile = "tls";
                    IEnrollment enroll     = ca.Enroll("admin", "adminpw", enrollmentRequestTLS);
                    string      tlsCertPEM = enroll.Cert;
                    string      tlsKeyPEM  = enroll.Key;

                    Properties tlsProperties = new Properties();

                    tlsProperties["clientKeyBytes"]  = tlsKeyPEM;
                    tlsProperties["clientCertBytes"] = tlsCertPEM;

                    clientTLSProperties[sampleOrg.Name] = tlsProperties;
                    //Save in samplestore for follow on tests.
                    sampleStore.StoreClientPEMTLCertificate(sampleOrg, tlsCertPEM);
                    sampleStore.StoreClientPEMTLSKey(sampleOrg, tlsKeyPEM);
                }

                HFCAInfo info = ca.Info(); //just check if we connect at all.
                Assert.IsNotNull(info);
                string infoName = info.CAName;
                if (infoName != null && infoName.Length > 0)
                {
                    Assert.AreEqual(ca.CAName, infoName);
                }

                SampleUser admin      = sampleStore.GetMember(TEST_ADMIN_NAME, orgName);
                SampleUser idemixUser = sampleStore.GetMember(testUser1, sampleOrg.Name);



                EnrollIdemixUser(sampleOrg, idemixUser, admin);
                sampleOrg.AddUser(idemixUser);
            }
        }
Exemplo n.º 5
0
        public SampleUser(string name, string org, SampleStore fs, ICryptoSuite cryptoSuite)
        {
            this.Name        = name;
            this.cryptoSuite = cryptoSuite;

            keyValStore     = fs;
            Organization    = org;
            KeyValStoreName = ToKeyValStoreName(Name, org);
            string memberStr = keyValStore.GetValue(KeyValStoreName);

            if (null == memberStr)
            {
                SaveState();
            }
            else
            {
                RestoreState();
            }
        }
Exemplo n.º 6
0
        /**
         * Will register and enroll users persisting them to samplestore.
         *
         * @param sampleStore
         * @throws Exception
         */
        public void SetupUsers(SampleStore sStore)
        {
            //SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface

            ////////////////////////////
            // get users for all orgs
            foreach (SampleOrg sampleOrg in testSampleOrgs)
            {
                string orgName = sampleOrg.Name;

                SampleUser admin = sStore.GetMember(TEST_ADMIN_NAME, orgName);
                sampleOrg.Admin = admin; // The admin of this org.

                // No need to enroll or register all done in End2endIt !
                SampleUser user = sStore.GetMember(TESTUSER_1_NAME, orgName);
                sampleOrg.AddUser(user); //Remember user belongs to this Org
                sampleOrg.PeerAdmin = sStore.GetMember(orgName + "Admin", orgName);
            }
        }
        public virtual void Setup()
        {
            try
            {
                // client.setMemberServices(peerOrg1FabricCA);

                //Persistence is not part of SDK. Sample file store is for demonstration purposes only!
                //   MUST be replaced with more robust application implementation  (Database, LDAP)

//            if (sampleStoreFile.exists()) { //For testing start fresh
//                sampleStoreFile.delete();
//            }
                sampleStore = new SampleStore(sampleStoreFile);

                SetupUsers(sampleStore);
                RunFabricTest(sampleStore);
            }
            catch (System.Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
Exemplo n.º 8
0
        public void RunFabricTest(SampleStore sStore)
        {
            ////////////////////////////
            // Setup client

            //Create instance of client.
            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.GetCryptoSuite();
            client.UserContext = sStore.GetMember(TEST_ADMIN_NAME, "peerOrg2");

            SampleOrg sampleOrg = testConfig.GetIntegrationTestsSampleOrg("peerOrg2");

            Channel barChannel = sStore.GetChannel(client, BAR_CHANNEL_NAME);

            barChannel.Initialize();
            RunChannel(client, barChannel, sampleOrg, 10);
            Assert.IsFalse(barChannel.IsShutdown);
            Assert.IsTrue(barChannel.IsInitialized);

            if (testConfig.IsFabricVersionAtOrAfter("1.3"))
            {
                HashSet <string> expect = new HashSet <string>(new [] { "COLLECTION_FOR_A", "COLLECTION_FOR_B" });
                HashSet <string> got    = new HashSet <string>();

                CollectionConfigPackage queryCollectionsConfig = barChannel.QueryCollectionsConfig(CHAIN_CODE_NAME, barChannel.Peers.First(), sampleOrg.PeerAdmin);
                foreach (CollectionConfig collectionConfig in queryCollectionsConfig.CollectionConfigs)
                {
                    got.Add(collectionConfig.Name);
                }
                CollectionAssert.AreEqual(expect.ToList(), got.ToList());
            }


            Util.COut("That's all folks!");
        }
Exemplo n.º 9
0
 public override void Setup()
 {
     sampleStore = new SampleStore(sampleStoreFile);
     EnrollUsersSetup(sampleStore);
     RunFabricTest(sampleStore); // just run fabric tests.
 }
Exemplo n.º 10
0
        [Ignore] //Hostnames reported by service discovery won't work unless you edit hostfile
        public void Setup()
        {
            //Persistence is not part of SDK. Sample file store is for demonstration purposes only!
            //   MUST be replaced with more robust application implementation  (Database, LDAP)
            Util.COut("\n\n\nRUNNING: %s.\n", "ServiceDiscoveryIT");

            SampleStore sampleStore = new SampleStore(sampleStoreFile);

            //  SampleUser peerAdmin = sampleStore.getMember("admin", "peerOrg1");
            SampleUser user1  = sampleStore.GetMember("user1", "peerOrg1");
            HFClient   client = HFClient.Create();

            testConfig.GetIntegrationTestsSampleOrg("peerOrg1");
            client.CryptoSuite = Factory.GetCryptoSuite();
            client.UserContext = user1;
            Properties properties = testConfig.GetPeerProperties("peer0.org1.example.com");

            string protocol = testConfig.IsRunningFabricTLS() ? "grpcs:" : "grpc:";

            Properties sdprops = new Properties();

            //Create initial discovery peer.

            Peer    discoveryPeer = client.NewPeer("peer0.org1.example.com", protocol + "//localhost:7051", properties);
            Channel foo           = client.NewChannel("foo"); //create channel that will be discovered.

            foo.AddPeer(discoveryPeer, PeerOptions.CreatePeerOptions().SetPeerRoles(PeerRole.SERVICE_DISCOVERY, PeerRole.LEDGER_QUERY, PeerRole.EVENT_SOURCE, PeerRole.CHAINCODE_QUERY));

            // Need to provide client TLS certificate and key files when running mutual tls.
            if (testConfig.IsRunningFabricTLS())
            {
                sdprops.Add("org.hyperledger.fabric.sdk.discovery.default.clientCertFile", "fixture/sdkintegration/e2e-2Orgs/v1.2/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/tls/client.crt".Locate());
                sdprops.Add("org.hyperledger.fabric.sdk.discovery.default.clientKeyFile", "fixture/sdkintegration/e2e-2Orgs/v1.2/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/tls/client.key".Locate());

                // Need to do host name override for true tls in testing environment
                sdprops.Add("org.hyperledger.fabric.sdk.discovery.endpoint.hostnameOverride.localhost:7050", "orderer.example.com");
                sdprops.Add("org.hyperledger.fabric.sdk.discovery.endpoint.hostnameOverride.localhost:7051", "peer0.org1.example.com");
                sdprops.Add("org.hyperledger.fabric.sdk.discovery.endpoint.hostnameOverride.localhost:7056", "peer1.org1.example.com");
            }
            else
            {
                sdprops.Add("org.hyperledger.fabric.sdk.discovery.default.protocol", "grpc:");
            }

            foo.ServiceDiscoveryProperties = sdprops;

            string channel = foo.Serialize();

            // Next 3 lines are for testing purposes only!
            foo.Shutdown(false);
            foo = client.DeSerializeChannel(channel);
            foo.Initialize(); // initialize the channel.
            List <string> expect = new List <string>()
            {
                protocol + "//orderer.example.com:7050"
            };                                                                                  //discovered orderer

            foreach (Orderer orderer in foo.Orderers)
            {
                expect.Remove(orderer.Url);
            }

            Assert.IsTrue(expect.Count == 0);

            List <string> discoveredChaincodeNames = foo.GetDiscoveredChaincodeNames();

            Assert.IsTrue(discoveredChaincodeNames.Contains(CHAIN_CODE_NAME));

            ChaincodeID chaincodeID = new ChaincodeID();

            chaincodeID.Name = CHAIN_CODE_NAME;


            ///////////////
            // Send transaction proposal to all peers
            TransactionProposalRequest transactionProposalRequest = client.NewTransactionProposalRequest();

            transactionProposalRequest.SetChaincodeID(chaincodeID);
            transactionProposalRequest.SetChaincodeLanguage(CHAIN_CODE_LANG);
            transactionProposalRequest.SetFcn("move");
            transactionProposalRequest.SetProposalWaitTime(testConfig.GetProposalWaitTime());
            transactionProposalRequest.SetArgs("a", "b", "1");

            //Send proposal request discovering the what endorsers (peers) are needed.

            List <ProposalResponse> transactionPropResp = foo.SendTransactionProposalToEndorsers(transactionProposalRequest, DiscoveryOptions.CreateDiscoveryOptions().SetEndorsementSelector(ServiceDiscovery.ENDORSEMENT_SELECTION_RANDOM).SetForceDiscovery(true));

            Assert.IsFalse(transactionPropResp.Count == 0);

            transactionProposalRequest = client.NewTransactionProposalRequest();
            transactionProposalRequest.SetChaincodeID(chaincodeID);
            transactionProposalRequest.SetChaincodeLanguage(CHAIN_CODE_LANG);
            transactionProposalRequest.SetFcn("move");
            transactionProposalRequest.SetProposalWaitTime(testConfig.GetProposalWaitTime());
            transactionProposalRequest.SetArgs("a", "b", "1");

            //Send proposal request discovering the what endorsers (peers) are needed.
            transactionPropResp = foo.SendTransactionProposalToEndorsers(transactionProposalRequest, DiscoveryOptions.CreateDiscoveryOptions().IgnoreEndpoints("blah.blah.blah.com:90", "blah.com:80",
                                                                         // aka peer0.org1.example.com our discovery peer. Lets ignore it in endorsers selection and see if other discovered peer endorses.
                                                                                                                                                               "peer0.org1.example.com:7051")
                                                                         // if chaincode makes additional chaincode calls or uses collections you should add them with setServiceDiscoveryChaincodeInterests
                                                                         //         .setServiceDiscoveryChaincodeInterests(Channel.ServiceDiscoveryChaincodeCalls.createServiceDiscoveryChaincodeCalls("someOtherChaincodeName").addCollections("collection1", "collection2"))
                                                                         );
            Assert.AreEqual(transactionPropResp.Count, 1);
            ProposalResponse proposalResponse = transactionPropResp.First();
            Peer             peer             = proposalResponse.Peer;

            Assert.AreEqual(protocol + "//peer1.org1.example.com:7056", peer.Url); // not our discovery peer but the discovered one.

            string expectedTransactionId = null;

            StringBuilder evenTransactionId = new StringBuilder();

            foreach (ProposalResponse response in transactionPropResp)
            {
                expectedTransactionId = response.TransactionID;
                if (response.Status != ChaincodeResponse.ChaincodeResponseStatus.SUCCESS || !response.IsVerified)
                {
                    Assert.Fail("Failed status bad endorsement");
                }
            }

            //Send it to the orderer that was discovered.
            try
            {
                TransactionEvent transactionEvent = foo.SendTransaction(transactionPropResp);

                evenTransactionId.Length = 0;

                evenTransactionId.Append(transactionEvent.TransactionID);
            }
            catch (TransactionEventException e)
            {
                TransactionEvent te = e.TransactionEvent;
                if (te != null)
                {
                    throw new System.Exception($"Transaction with txid {te.TransactionID} failed. {e.Message}");
                }
            }
            catch (System.Exception e)
            {
                throw new System.Exception($"Test failed with {e.Message} exception {e}");
            }


            Assert.AreEqual(expectedTransactionId, evenTransactionId.ToString());
            Util.COut("That's all folks!");
        }
Exemplo n.º 11
0
        public void Setup()
        {
            try
            {
                ////////////////////////////
                // Setup client

                //Create instance of client.
                HFClient client = HFClient.Create();

                client.CryptoSuite = Factory.Instance.GetCryptoSuite();

                ////////////////////////////
                //Set up USERS

                //Persistence is not part of SDK. Sample file store is for demonstration purposes only!
                //   MUST be replaced with more robust application implementation  (Database, LDAP)
                string sampleStoreFile = Path.Combine(Path.GetTempPath(), "HFCSampletest.properties");

                SampleStore sampleStore = new SampleStore(sampleStoreFile);

                //SampleUser can be any implementation that implements org.hyperledger.fabric.sdk.User Interface

                ////////////////////////////
                // get users for all orgs

                foreach (SampleOrg sampleOrgs in testSampleOrgs)
                {
                    string orgName = sampleOrgs.Name;
                    sampleOrgs.PeerAdmin = sampleStore.GetMember(orgName + "Admin", orgName);
                }

                ////////////////////////////
                //Reconstruct and run the channels
                SampleOrg sampleOrg  = testConfig.GetIntegrationTestsSampleOrg("peerOrg1");
                Channel   fooChannel = ReconstructChannel(FOO_CHANNEL_NAME, client, sampleOrg);

                // Getting foo channels current configuration bytes.
                byte[] channelConfigurationBytes = fooChannel.GetChannelConfigurationBytes();

                string responseAsString = ConfigTxlatorDecode(channelConfigurationBytes);


                //responseAsString is JSON but use just string operations for this test.

                if (!responseAsString.Contains(ORIGINAL_BATCH_TIMEOUT))
                {
                    Assert.Fail($"Did not find expected batch timeout '{ORIGINAL_BATCH_TIMEOUT}', in:{responseAsString}");
                }

                //Now modify the batch timeout
                string updateString = responseAsString.Replace(ORIGINAL_BATCH_TIMEOUT, UPDATED_BATCH_TIMEOUT);
                (int statuscode, byte[] data) = HttpPost(CONFIGTXLATOR_LOCATION + "/protolator/encode/common.Config", updateString.ToBytes());
                Util.COut("Got {0} status for encoding the new desired channel config bytes", statuscode);
                Assert.AreEqual(200, statuscode);
                byte[] newConfigBytes = data;

                // Now send to configtxlator multipart form post with original config bytes, updated config bytes and channel name.
                List <(string Name, byte[] Body, string Mime, string FName)> parts = new List <(string Name, byte[] Body, string Mime, string FName)>();
                parts.Add(("original", channelConfigurationBytes, "application/octet-stream", "originalFakeFilename"));
                parts.Add(("updated", newConfigBytes, "application/octet-stream", "updatedFakeFilename"));
                parts.Add(("channel", fooChannel.Name.ToBytes(), null, null));
                (statuscode, data) = HttpPostMultiPart(CONFIGTXLATOR_LOCATION + "/configtxlator/compute/update-from-configs", parts);
                Util.COut("Got {0} status for updated config bytes needed for updateChannelConfiguration ", statuscode);
                Assert.AreEqual(200, statuscode);
                byte[] updateBytes = data;

                UpdateChannelConfiguration updateChannelConfiguration = new UpdateChannelConfiguration(updateBytes);

                //To change the channel we need to sign with orderer admin certs which crypto gen stores:

                // private key: src/test/fixture/sdkintegration/e2e-2Orgs/channel/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/keystore/f1a9a940f57419a18a83a852884790d59b378281347dd3d4a88c2b820a0f70c9_sk
                //certificate:  src/test/fixture/sdkintegration/e2e-2Orgs/channel/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/signcerts/[email protected]

                string     sampleOrgName = sampleOrg.Name;
                SampleUser ordererAdmin  = sampleStore.GetMember(sampleOrgName + "OrderAdmin", sampleOrgName, "OrdererMSP", Util.FindFileSk("fixture/sdkintegration/e2e-2Orgs/" + TestConfig.Instance.FAB_CONFIG_GEN_VERS + "/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/keystore/"), ("fixture/sdkintegration/e2e-2Orgs/" + TestConfig.Instance.FAB_CONFIG_GEN_VERS + "/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/signcerts/[email protected]").Locate());

                client.UserContext = ordererAdmin;

                //Ok now do actual channel update.
                fooChannel.UpdateChannelConfiguration(updateChannelConfiguration, client.GetUpdateChannelConfigurationSignature(updateChannelConfiguration, ordererAdmin));

                Thread.Sleep(3000); // give time for events to happen

                //Let's add some additional verification...

                client.UserContext = sampleOrg.PeerAdmin;

                byte[] modChannelBytes = fooChannel.GetChannelConfigurationBytes();

                //Now decode the new channel config bytes to json...
                responseAsString = ConfigTxlatorDecode(modChannelBytes);


                if (!responseAsString.Contains(UPDATED_BATCH_TIMEOUT))
                {
                    //If it doesn't have the updated time out it failed.
                    Assert.Fail($"Did not find updated expected batch timeout '{UPDATED_BATCH_TIMEOUT}', in:{responseAsString}");
                }

                if (responseAsString.Contains(ORIGINAL_BATCH_TIMEOUT))
                {
                    //Should not have been there anymore!

                    Assert.Fail($"Found original batch timeout '{ORIGINAL_BATCH_TIMEOUT}', when it was not expected in:{responseAsString}");
                }


                Assert.IsTrue(eventCountFilteredBlock > 0); // make sure we got blockevent that were tested.
                Assert.IsTrue(eventCountBlock > 0);         // make sure we got blockevent that were tested.

                //Should be no anchor peers defined.
                Assert.IsFalse(new Regex(REGX_S_HOST_PEER_0_ORG_1_EXAMPLE_COM).Match(responseAsString).Success);
                Assert.IsFalse(new Regex(REGX_S_ANCHOR_PEERS).Match(responseAsString).Success);

                // Get config update for adding an anchor peer.
                Channel.AnchorPeersConfigUpdateResult configUpdateAnchorPeers = fooChannel.GetConfigUpdateAnchorPeers(fooChannel.Peers.First(), sampleOrg.PeerAdmin, new List <string> {
                    PEER_0_ORG_1_EXAMPLE_COM_7051
                }, null);

                Assert.IsNotNull(configUpdateAnchorPeers.UpdateChannelConfiguration);
                Assert.IsTrue(configUpdateAnchorPeers.PeersAdded.Contains(PEER_0_ORG_1_EXAMPLE_COM_7051));

                //Now add anchor peer to channel configuration.
                fooChannel.UpdateChannelConfiguration(configUpdateAnchorPeers.UpdateChannelConfiguration, client.GetUpdateChannelConfigurationSignature(configUpdateAnchorPeers.UpdateChannelConfiguration, sampleOrg.PeerAdmin));

                Thread.Sleep(3000); // give time for events to happen

                // Getting foo channels current configuration bytes to check with configtxlator
                channelConfigurationBytes = fooChannel.GetChannelConfigurationBytes();
                responseAsString          = ConfigTxlatorDecode(channelConfigurationBytes);

                // Check is anchor peer in config block?
                Assert.IsTrue(new Regex(REGX_S_HOST_PEER_0_ORG_1_EXAMPLE_COM).Match(responseAsString).Success);
                Assert.IsTrue(new Regex(REGX_S_ANCHOR_PEERS).Match(responseAsString).Success);

                //Should see what's there.
                configUpdateAnchorPeers = fooChannel.GetConfigUpdateAnchorPeers(fooChannel.Peers.First(), sampleOrg.PeerAdmin, null, null);

                Assert.IsNull(configUpdateAnchorPeers.UpdateChannelConfiguration);                           // not updating anything.
                Assert.IsTrue(configUpdateAnchorPeers.CurrentPeers.Contains(PEER_0_ORG_1_EXAMPLE_COM_7051)); // peer should   be there.
                Assert.IsTrue(configUpdateAnchorPeers.PeersRemoved.Count == 0);                              // not removing any
                Assert.IsTrue(configUpdateAnchorPeers.PeersAdded.Count == 0);                                // not adding anything.
                Assert.IsTrue(configUpdateAnchorPeers.UpdatedPeers.Count == 0);                              // not updating anyting.

                //Now remove the anchor peer -- get the config update block.
                configUpdateAnchorPeers = fooChannel.GetConfigUpdateAnchorPeers(fooChannel.Peers.First(), sampleOrg.PeerAdmin, null, new List <string> {
                    PEER_0_ORG_1_EXAMPLE_COM_7051
                });

                Assert.IsNotNull(configUpdateAnchorPeers.UpdateChannelConfiguration);
                Assert.IsTrue(configUpdateAnchorPeers.CurrentPeers.Contains(PEER_0_ORG_1_EXAMPLE_COM_7051)); // peer should still be there.
                Assert.IsTrue(configUpdateAnchorPeers.PeersRemoved.Contains(PEER_0_ORG_1_EXAMPLE_COM_7051)); // peer to remove.
                Assert.IsTrue(configUpdateAnchorPeers.PeersAdded.Count == 0);                                // not adding anything.
                Assert.IsTrue(configUpdateAnchorPeers.UpdatedPeers.Count == 0);                              // no peers should be left.

                // Now do the actual update.
                fooChannel.UpdateChannelConfiguration(configUpdateAnchorPeers.UpdateChannelConfiguration, client.GetUpdateChannelConfigurationSignature(configUpdateAnchorPeers.UpdateChannelConfiguration, sampleOrg.PeerAdmin));
                Thread.Sleep(3000); // give time for events to happen
                // Getting foo channels current configuration bytes to check with configtxlator.
                channelConfigurationBytes = fooChannel.GetChannelConfigurationBytes();
                responseAsString          = ConfigTxlatorDecode(channelConfigurationBytes);

                Assert.IsFalse(new Regex(REGX_S_HOST_PEER_0_ORG_1_EXAMPLE_COM).Match(responseAsString).Success); // should be gone!
                Assert.IsTrue(new Regex(REGX_S_ANCHOR_PEERS).Match(responseAsString).Success);                   //ODDLY we still want this even if it's empty!

                //Should see what's there.
                configUpdateAnchorPeers = fooChannel.GetConfigUpdateAnchorPeers(fooChannel.Peers.First(), sampleOrg.PeerAdmin, null, null);

                Assert.IsNull(configUpdateAnchorPeers.UpdateChannelConfiguration); // not updating anything.
                Assert.IsTrue(configUpdateAnchorPeers.CurrentPeers.Count == 0);    // peer should be now gone.
                Assert.IsTrue(configUpdateAnchorPeers.PeersRemoved.Count == 0);    // not removing any
                Assert.IsTrue(configUpdateAnchorPeers.PeersAdded.Count == 0);      // not adding anything.
                Assert.IsTrue(configUpdateAnchorPeers.UpdatedPeers.Count == 0);    // no peers should be left


                Util.COut("That's all folks!");
            }
            catch (System.Exception e)
            {
                Assert.Fail(e.Message);
            }
        }
 public override void Setup()
 {
     sampleStore = new SampleStore(sampleStoreFile);
     SetupUsers(sampleStore);
     RunFabricTest(sampleStore);
 }