< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Channels.Models.ChannelModel
Assembly: NLightning.Domain
File(s): /home/runner/work/NLightning/NLightning/src/NLightning.Domain/Channels/Models/ChannelModel.cs
Tag: 57_24045730253
Line coverage
46%
Covered lines: 52
Uncovered lines: 60
Coverable lines: 112
Total lines: 170
Line coverage: 46.4%
Branch coverage
27%
Covered branches: 12
Total branches: 44
Branch coverage: 27.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ChannelConfig()100%11100%
get_ChannelId()100%11100%
get_ShortChannelId()100%210%
get_CommitmentNumber()100%11100%
get_FundingCreatedAtBlockHeight()100%210%
get_FundingOutput()100%11100%
get_IsInitiator()100%11100%
get_RemoteNodeId()100%210%
get_State()100%11100%
get_Version()100%210%
get_ChangeAddress()100%210%
get_LastSentSignature()100%210%
get_LastReceivedSignature()100%210%
get_LastSentSignature()100%11100%
get_LastReceivedSignature()100%11100%
get_LocalAliases()100%210%
get_LocalBalance()100%210%
get_LocalAliases()100%210%
get_LocalKeySet()100%210%
get_LocalBalance()100%11100%
get_LocalNextHtlcId()100%210%
get_LocalKeySet()100%11100%
get_LocalOfferedHtlcs()100%210%
get_LocalNextHtlcId()100%210%
get_LocalFulfilledHtlcs()100%210%
get_LocalOfferedHtlcs()100%11100%
get_LocalOldHtlcs()100%210%
get_LocalFulfilledHtlcs()100%210%
get_LocalRevocationNumber()100%210%
get_LocalOldHtlcs()100%210%
get_LocalUpfrontShutdownScript()100%210%
get_LocalRevocationNumber()100%210%
get_LocalUpfrontShutdownScript()100%210%
get_RemoteAlias()100%210%
get_RemoteBalance()100%210%
get_RemoteAlias()100%210%
get_RemoteKeySet()100%210%
get_RemoteBalance()100%11100%
get_RemoteNextHtlcId()100%210%
get_RemoteKeySet()100%11100%
get_RemoteRevocationNumber()100%210%
get_RemoteNextHtlcId()100%210%
get_RemoteFulfilledHtlcs()100%210%
get_RemoteRevocationNumber()100%210%
get_RemoteOfferedHtlcs()100%210%
get_RemoteFulfilledHtlcs()100%210%
get_RemoteOldHtlcs()100%210%
get_RemoteOfferedHtlcs()100%11100%
get_RemoteUpfrontShutdownScript()100%210%
get_RemoteOldHtlcs()100%210%
get_RemoteUpfrontShutdownScript()100%210%
.ctor(...)0%156120%
.ctor(...)100%1212100%
UpdateState(...)0%110100%
UpdateState(...)0%110100%
UpdateChannelId(...)0%620%
UpdateChannelId(...)0%620%
GetSigningInfo()100%210%
UpdateChannelConfig(...)100%210%
AddRemoteKeySet(...)0%620%
AddCommitmentNumber(...)0%620%
AddFundingOutput(...)0%620%
UpdateLastSentSignature(...)100%210%
UpdateLastReceivedSignature(...)100%210%
GetSigningInfo()100%210%

File(s)

/home/runner/work/NLightning/NLightning/src/NLightning.Domain/Channels/Models/ChannelModel.cs

#LineLine coverage
 1namespace NLightning.Domain.Channels.Models;
 2
 3using Bitcoin.Transactions.Outputs;
 4using Bitcoin.ValueObjects;
 5using Crypto.ValueObjects;
 6using Domain.Bitcoin.Wallet.Models;
 7using Domain.Protocol.Models;
 8using Enums;
 9using Money;
 10using ValueObjects;
 11
 12public class ChannelModel
 13{
 14    #region Base Properties
 15
 84416    public ChannelConfig ChannelConfig { get; private set; }
 6817    public ChannelId ChannelId { get; private set; }
 018    public ShortChannelId ShortChannelId { get; set; }
 20419    public CommitmentNumber? CommitmentNumber { get; private set; }
 020    public uint FundingCreatedAtBlockHeight { get; set; }
 20421    public FundingOutputInfo? FundingOutput { get; private set; }
 6822    public bool IsInitiator { get; }
 023    public CompactPubKey RemoteNodeId { get; }
 6824    public ChannelState State { get; private set; }
 025    public ChannelVersion Version { get; }
 026    public WalletAddressModel? ChangeAddress { get; set; }
 27
 28    #endregion
 29
 30    #region Signatures
 031
 6832    public CompactSignature? LastSentSignature { get; private set; }
 6833    public CompactSignature? LastReceivedSignature { get; private set; }
 34
 35    #endregion
 36
 37    #region Local Information
 038
 039    public ICollection<ShortChannelId>? LocalAliases { get; set; }
 6840    public LightningMoney LocalBalance { get; }
 20441    public ChannelKeySetModel LocalKeySet { get; }
 042    public ulong LocalNextHtlcId { get; }
 6843    public ICollection<Htlc>? LocalOfferedHtlcs { get; }
 044    public ICollection<Htlc>? LocalFulfilledHtlcs { get; }
 045    public ICollection<Htlc>? LocalOldHtlcs { get; }
 046    public ulong LocalRevocationNumber { get; }
 047    public BitcoinScript? LocalUpfrontShutdownScript { get; }
 48
 49    #endregion
 50
 51    #region Remote Information
 052
 053    public ShortChannelId? RemoteAlias { get; set; }
 6854    public LightningMoney RemoteBalance { get; }
 54455    public ChannelKeySetModel? RemoteKeySet { get; private set; }
 056    public ulong RemoteNextHtlcId { get; }
 057    public ulong RemoteRevocationNumber { get; }
 058    public ICollection<Htlc>? RemoteFulfilledHtlcs { get; }
 6859    public ICollection<Htlc>? RemoteOfferedHtlcs { get; }
 060    public ICollection<Htlc>? RemoteOldHtlcs { get; }
 061    public BitcoinScript? RemoteUpfrontShutdownScript { get; }
 62
 63    #endregion
 064
 6865    public ChannelModel(ChannelConfig channelConfig, ChannelId channelId, CommitmentNumber? commitmentNumber,
 6866                        FundingOutputInfo? fundingOutput, bool isInitiator, CompactSignature? lastSentSignature,
 6867                        CompactSignature? lastReceivedSignature, LightningMoney localBalance,
 6868                        ChannelKeySetModel localKeySet, ulong localNextHtlcId, ulong localRevocationNumber,
 6869                        LightningMoney remoteBalance, ChannelKeySetModel? remoteKeySet, ulong remoteNextHtlcId,
 6870                        CompactPubKey remoteNodeId, ulong remoteRevocationNumber, ChannelState state,
 6871                        ChannelVersion version, ICollection<Htlc>? localOfferedHtlcs = null,
 6872                        ICollection<Htlc>? localFulfilledHtlcs = null, ICollection<Htlc>? localOldHtlcs = null,
 6873                        BitcoinScript? localUpfrontShutdownScript = null, ICollection<Htlc>? remoteOfferedHtlcs = null,
 6874                        ICollection<Htlc>? remoteFulfilledHtlcs = null, ICollection<Htlc>? remoteOldHtlcs = null,
 6875                        BitcoinScript? remoteUpfrontShutdownScript = null)
 076    {
 6877        ChannelConfig = channelConfig;
 6878        ChannelId = channelId;
 6879        CommitmentNumber = commitmentNumber;
 6880        FundingOutput = fundingOutput;
 6881        IsInitiator = isInitiator;
 6882        LastSentSignature = lastSentSignature;
 6883        LastReceivedSignature = lastReceivedSignature;
 6884        LocalBalance = localBalance;
 6885        LocalKeySet = localKeySet;
 6886        LocalNextHtlcId = localNextHtlcId;
 6887        LocalRevocationNumber = localRevocationNumber;
 6888        RemoteBalance = remoteBalance;
 6889        RemoteKeySet = remoteKeySet;
 6890        RemoteNextHtlcId = remoteNextHtlcId;
 6891        RemoteRevocationNumber = remoteRevocationNumber;
 6892        State = state;
 6893        Version = version;
 6894        RemoteNodeId = remoteNodeId;
 6895        LocalOfferedHtlcs = localOfferedHtlcs ?? new List<Htlc>();
 6896        LocalFulfilledHtlcs = localFulfilledHtlcs ?? new List<Htlc>();
 6897        LocalOldHtlcs = localOldHtlcs ?? new List<Htlc>();
 6898        RemoteOfferedHtlcs = remoteOfferedHtlcs ?? new List<Htlc>();
 6899        RemoteFulfilledHtlcs = remoteFulfilledHtlcs ?? new List<Htlc>();
 68100        RemoteOldHtlcs = remoteOldHtlcs ?? new List<Htlc>();
 68101        LocalUpfrontShutdownScript = localUpfrontShutdownScript;
 68102        RemoteUpfrontShutdownScript = remoteUpfrontShutdownScript;
 68103    }
 104
 105    public void UpdateState(ChannelState newState)
 0106    {
 0107        if (State == ChannelState.V2Opening && newState < ChannelState.V2Opening
 0108         || State >= ChannelState.V1Opening && newState == ChannelState.V2Opening)
 0109            throw new ArgumentOutOfRangeException(nameof(newState), "Invalid channel state for update.");
 0110
 0111        if (newState <= State)
 0112            throw new ArgumentOutOfRangeException(nameof(newState), "New state must be greater than current state.");
 0113
 0114        State = newState;
 0115    }
 116
 117    public void UpdateChannelId(ChannelId newChannelId)
 0118    {
 0119        if (newChannelId == ChannelId.Zero)
 0120            throw new ArgumentException("New channel ID cannot be empty.", nameof(newChannelId));
 0121
 0122        ChannelId = newChannelId;
 0123    }
 124
 125    public void UpdateChannelConfig(ChannelConfig channelConfig)
 0126    {
 0127        ChannelConfig = channelConfig;
 0128    }
 129
 130    public void AddRemoteKeySet(ChannelKeySetModel remoteKeySet)
 131    {
 0132        if (RemoteKeySet is not null)
 0133            throw new InvalidOperationException("Remote key set already set");
 134
 0135        RemoteKeySet = remoteKeySet;
 0136    }
 137
 138    public void AddCommitmentNumber(CommitmentNumber commitmentNumber)
 139    {
 0140        if (CommitmentNumber is not null)
 0141            throw new InvalidOperationException("Commitment number already set");
 142
 0143        CommitmentNumber = commitmentNumber;
 0144    }
 145
 146    public void AddFundingOutput(FundingOutputInfo fundingOutput)
 147    {
 0148        if (FundingOutput is not null)
 0149            throw new InvalidOperationException("Funding output already set");
 150
 0151        FundingOutput = fundingOutput;
 0152    }
 153
 154    public void UpdateLastSentSignature(CompactSignature lastSentSignature)
 155    {
 0156        LastSentSignature = lastSentSignature;
 0157    }
 158
 159    public void UpdateLastReceivedSignature(CompactSignature lastReceivedSignature)
 160    {
 0161        LastReceivedSignature = lastReceivedSignature;
 0162    }
 163
 164    public ChannelSigningInfo GetSigningInfo()
 165    {
 0166        return new ChannelSigningInfo(FundingOutput!.TransactionId!.Value, FundingOutput.Index!.Value,
 0167                                      FundingOutput.Amount, LocalKeySet.FundingCompactPubKey,
 0168                                      RemoteKeySet!.FundingCompactPubKey, LocalKeySet.KeyIndex);
 169    }
 170}

Methods/Properties

get_ChannelConfig()
get_ChannelId()
get_ShortChannelId()
get_CommitmentNumber()
get_FundingCreatedAtBlockHeight()
get_FundingOutput()
get_IsInitiator()
get_RemoteNodeId()
get_State()
get_Version()
get_ChangeAddress()
get_LastSentSignature()
get_LastReceivedSignature()
get_LastSentSignature()
get_LastReceivedSignature()
get_LocalAliases()
get_LocalBalance()
get_LocalAliases()
get_LocalKeySet()
get_LocalBalance()
get_LocalNextHtlcId()
get_LocalKeySet()
get_LocalOfferedHtlcs()
get_LocalNextHtlcId()
get_LocalFulfilledHtlcs()
get_LocalOfferedHtlcs()
get_LocalOldHtlcs()
get_LocalFulfilledHtlcs()
get_LocalRevocationNumber()
get_LocalOldHtlcs()
get_LocalUpfrontShutdownScript()
get_LocalRevocationNumber()
get_LocalUpfrontShutdownScript()
get_RemoteAlias()
get_RemoteBalance()
get_RemoteAlias()
get_RemoteKeySet()
get_RemoteBalance()
get_RemoteNextHtlcId()
get_RemoteKeySet()
get_RemoteRevocationNumber()
get_RemoteNextHtlcId()
get_RemoteFulfilledHtlcs()
get_RemoteRevocationNumber()
get_RemoteOfferedHtlcs()
get_RemoteFulfilledHtlcs()
get_RemoteOldHtlcs()
get_RemoteOfferedHtlcs()
get_RemoteUpfrontShutdownScript()
get_RemoteOldHtlcs()
get_RemoteUpfrontShutdownScript()
.ctor(NLightning.Domain.Channels.ValueObjects.ChannelConfig,NLightning.Domain.Channels.ValueObjects.ChannelId,NLightning.Domain.Protocol.Models.CommitmentNumber,NLightning.Domain.Bitcoin.Transactions.Outputs.FundingOutputInfo,System.Boolean,NLightning.Domain.Crypto.ValueObjects.CompactSignature,NLightning.Domain.Crypto.ValueObjects.CompactSignature,NLightning.Domain.Money.LightningMoney,NLightning.Domain.Channels.Models.ChannelKeySetModel,System.UInt64,System.UInt64,NLightning.Domain.Money.LightningMoney,NLightning.Domain.Channels.Models.ChannelKeySetModel,System.UInt64,NLightning.Domain.Crypto.ValueObjects.CompactPubKey,System.UInt64,NLightning.Domain.Channels.Enums.ChannelState,NLightning.Domain.Channels.Enums.ChannelVersion,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Nullable`1<NLightning.Domain.Bitcoin.ValueObjects.BitcoinScript>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Nullable`1<NLightning.Domain.Bitcoin.ValueObjects.BitcoinScript>)
.ctor(NLightning.Domain.Channels.ValueObjects.ChannelConfig,NLightning.Domain.Channels.ValueObjects.ChannelId,NLightning.Domain.Protocol.Models.CommitmentNumber,NLightning.Domain.Bitcoin.Transactions.Outputs.FundingOutputInfo,System.Boolean,NLightning.Domain.Crypto.ValueObjects.CompactSignature,NLightning.Domain.Crypto.ValueObjects.CompactSignature,NLightning.Domain.Money.LightningMoney,NLightning.Domain.Channels.Models.ChannelKeySetModel,System.UInt64,System.UInt64,NLightning.Domain.Money.LightningMoney,NLightning.Domain.Channels.Models.ChannelKeySetModel,System.UInt64,NLightning.Domain.Crypto.ValueObjects.CompactPubKey,System.UInt64,NLightning.Domain.Channels.Enums.ChannelState,NLightning.Domain.Channels.Enums.ChannelVersion,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Nullable`1<NLightning.Domain.Bitcoin.ValueObjects.BitcoinScript>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Collections.Generic.ICollection`1<NLightning.Domain.Channels.ValueObjects.Htlc>,System.Nullable`1<NLightning.Domain.Bitcoin.ValueObjects.BitcoinScript>)
UpdateState(NLightning.Domain.Channels.Enums.ChannelState)
UpdateState(NLightning.Domain.Channels.Enums.ChannelState)
UpdateChannelId(NLightning.Domain.Channels.ValueObjects.ChannelId)
UpdateChannelId(NLightning.Domain.Channels.ValueObjects.ChannelId)
GetSigningInfo()
UpdateChannelConfig(NLightning.Domain.Channels.ValueObjects.ChannelConfig)
AddRemoteKeySet(NLightning.Domain.Channels.Models.ChannelKeySetModel)
AddCommitmentNumber(NLightning.Domain.Protocol.Models.CommitmentNumber)
AddFundingOutput(NLightning.Domain.Bitcoin.Transactions.Outputs.FundingOutputInfo)
UpdateLastSentSignature(NLightning.Domain.Crypto.ValueObjects.CompactSignature)
UpdateLastReceivedSignature(NLightning.Domain.Crypto.ValueObjects.CompactSignature)
GetSigningInfo()