public void TestLoadFromConfigFileYamlBasic() { ChaincodeCollectionConfiguration config = ChaincodeCollectionConfiguration.FromYamlFile("Fixture/collectionProperties/testCollection.yaml".Locate()); Assert.IsNotNull(config); byte[] configAsBytes = config.GetAsBytes(); Assert.IsNotNull(configAsBytes); Assert.AreEqual(configAsBytes.Length, 137); CollectionConfigPackage collectionConfigPackage = CollectionConfigPackage.Parser.ParseFrom(configAsBytes); Assert.AreEqual(collectionConfigPackage.Config.Count, 1); CollectionConfig colConfig = collectionConfigPackage.Config.FirstOrDefault(); Assert.IsNotNull(colConfig); StaticCollectionConfig staticCollectionConfig = colConfig.StaticCollectionConfig; Assert.IsNotNull(staticCollectionConfig); Assert.AreEqual(staticCollectionConfig.BlockToLive, (ulong)3); Assert.AreEqual(staticCollectionConfig.Name, "rick"); Assert.AreEqual(staticCollectionConfig.MaximumPeerCount, 9); Assert.AreEqual(staticCollectionConfig.RequiredPeerCount, 7); CollectionPolicyConfig memberOrgsPolicy = staticCollectionConfig.MemberOrgsPolicy; Assert.IsNotNull(memberOrgsPolicy); SignaturePolicyEnvelope signaturePolicy = memberOrgsPolicy.SignaturePolicy; Assert.IsNotNull(signaturePolicy); Assert.AreEqual(signaturePolicy.Version, 0); SignaturePolicy rule = signaturePolicy.Rule; Assert.IsNotNull(rule); Assert.AreEqual(rule.TypeCase, SignaturePolicy.TypeOneofCase.NOutOf); SignaturePolicy.Types.NOutOf nOutOf = rule.NOutOf; Assert.IsNotNull(nOutOf); Assert.AreEqual(2, nOutOf.N); List <MSPPrincipal> identitiesList = signaturePolicy.Identities?.ToList(); Assert.IsNotNull(identitiesList); Assert.AreEqual(3, identitiesList.Count); }
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!"); }