Example #1
0
        public void CanCreateChannelManager()
        {
            using var channelManager = PeerManagerTests.getTestPeerManager().ChannelManager;
            var nodeFeature    = FeatureBits.CreateUnsafe(0b000000100100000100000000);
            var channelFeature = FeatureBits.CreateUnsafe(0b000000100100000100000000);
            var hop1           = new RouteHopWithFeature(_nodeIds[0], nodeFeature, 1, channelFeature, 1000, 72);
            var hop2           = new RouteHopWithFeature(_nodeIds[1], nodeFeature, 2, channelFeature, 1000, 72);
            var route1         = new[] { hop1, hop2 };
            var routes         = new RoutesWithFeature(route1);

            var paymentHash = new uint256();
            var e           = Assert.Throws <PaymentSendException>(() => channelManager.SendPayment(routes, paymentHash.ToBytes()));

            Assert.Equal(PaymentSendFailureType.AllFailedRetrySafe, e.Kind);
            channelManager.Dispose();
        }
Example #2
0
        public void CanCreateAndCloseChannel()
        {
            using var channelManager = PeerManagerTests.getTestPeerManager().ChannelManager;
            var pk = _pubKeys[0];

            channelManager.CreateChannel(pk, Money.Satoshis(100000), LNMoney.MilliSatoshis(1000L), UInt64.MaxValue);
            var c = channelManager.ListChannels(_pool);

            Assert.Single(c);
            Assert.Equal(c[0].RemoteNetworkId, pk);
            Assert.Equal(100000U, c[0].ChannelValueSatoshis);
            Assert.Equal(1000U, c[0].InboundCapacityMSat);
            Assert.Equal(100000UL * 1000UL - 1000UL, c[0].OutboundCapacityMSat);

            Assert.False(c[0].IsLive);
            channelManager.CloseChannel(c[0].ChannelId);
            var events = channelManager.GetAndClearPendingEvents(_pool);

            Assert.Empty(events);
            channelManager.Dispose();
        }
        public void CanCreateAndCloseChannel()
        {
            using var channelManager = PeerManagerTests.getTestPeerManager().ChannelManager;
            var pk = _pubKeys[0];

            channelManager.CreateChannel(pk, 100000, 1000, UInt64.MaxValue);
            var c = channelManager.ListChannels(_pool);

            Assert.Single(c);
            Assert.Equal(c[0].RemoteNetworkId, pk);
            Assert.Equal(100000U, c[0].ChannelValueSatoshis);
            // Before fully open, It must be 0.
            Assert.Equal(0U, c[0].InboundCapacityMSat);
            Assert.Equal(0U, c[0].OutboundCapacityMSat);

            Assert.False(c[0].IsLive);
            channelManager.CloseChannel(c[0].ChannelId);
            var events = channelManager.GetAndClearPendingEvents(_pool);

            Assert.Empty(events);
            channelManager.Dispose();
        }