コード例 #1
0
        public void TestNewChannel()
        {
            // Should be able to instantiate a new instance of "Channel" with the definition in the network configuration'
            JObject jsonConfig = GetJsonConfig(1, 0, 1);

            NetworkConfig config = NetworkConfig.FromJsonObject(jsonConfig);

            HFClient client = HFClient.Create();

            TestHFClient.SetupClient(client);

            Channel channel = client.LoadChannelFromConfig(CHANNEL_NAME, config);

            Assert.IsNotNull(channel);
            Assert.AreEqual(CHANNEL_NAME, channel.Name);
            Assert.AreEqual(channel.GetPeers(PeerRole.SERVICE_DISCOVERY).Count, 1);
        }
コード例 #2
0
        public void TestGetChannelNoPeers()
        {
            // Should not be able to instantiate a new instance of "Channel" with no peers configured
            JObject jsonConfig = GetJsonConfig(1, 1, 0);

            NetworkConfig config = NetworkConfig.FromJsonObject(jsonConfig);

            HFClient client = HFClient.Create();

            TestHFClient.SetupClient(client);

            client.LoadChannelFromConfig(CHANNEL_NAME, config);

            //HFClient client = HFClient.loadFromConfig(jsonConfig);
            //TestHFClient.setupClient(client);

            //client.getChannel(CHANNEL_NAME);
        }
コード例 #3
0
        public void TestGetChannel()
        {
            // Should be able to instantiate a new instance of "Channel" with orderer, org and peer defined in the network configuration
            JObject jsonConfig = GetJsonConfig(4, 1, 1);

            NetworkConfig config = NetworkConfig.FromJsonObject(jsonConfig);

            HFClient client = HFClient.Create();

            TestHFClient.SetupClient(client);

            Channel channel = client.LoadChannelFromConfig(CHANNEL_NAME, config);

            //HFClient client = HFClient.loadFromConfig(jsonConfig);
            //TestHFClient.setupClient(client);

            //Channel channel = client.getChannel(CHANNEL_NAME);
            Assert.IsNotNull(channel);
            Assert.AreEqual(CHANNEL_NAME, channel.Name);

            IReadOnlyList <Orderer> orderers = channel.Orderers;

            Assert.IsNotNull(orderers);
            Assert.AreEqual(1, orderers.Count);

            Orderer orderer = orderers.First();

            Assert.AreEqual("orderer1.example.com", orderer.Name);

            IReadOnlyList <Peer> peers = channel.Peers;

            Assert.IsNotNull(peers);
            Assert.AreEqual(1, peers.Count);

            Peer peer = peers.First();

            Assert.AreEqual("peer0.org1.example.com", peer.Name);
        }