< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Protocol.Tlv.RemoteAddressTlv
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/Tlv/RemoteAddressTlv.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 24
Coverable lines: 24
Total lines: 38
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 16
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_AddressType()100%210%
get_Address()100%210%
get_Port()100%210%
.ctor(...)0%272160%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/Tlv/RemoteAddressTlv.cs

#LineLine coverage
 1using System.Globalization;
 2using NLightning.Domain.Protocol.Constants;
 3
 4namespace NLightning.Domain.Protocol.Tlv;
 5
 6public class RemoteAddressTlv : BaseTlv
 7{
 08    public byte AddressType { get; }
 09    public string Address { get; }
 010    public ushort Port { get; }
 11
 012    public RemoteAddressTlv(byte addressType, string address, ushort port) : base(TlvConstants.RemoteAddress)
 13    {
 014        if (addressType is < 1 or > 5)
 015            throw new ArgumentException("Invalid address type", nameof(addressType));
 16
 017        if (addressType == 5)
 018            address = new IdnMapping().GetAscii(address);
 19
 020        AddressType = addressType;
 021        Address = address;
 022        Port = port;
 23
 024        Length = addressType switch
 025        {
 026            1 => 7,
 027            2 => 19,
 028            3 => throw new ArgumentException("Tor v2 addresses are deprecated", nameof(addressType)),
 029            4 => 38,
 030            5 when address.Length > 255 => throw new ArgumentException("Maximum lenght for address is 255",
 031                                                                       nameof(address)),
 032            5 => 3 + address.Length,
 033            _ => throw new ArgumentException("Invalid address type", nameof(addressType))
 034        };
 35
 036        Value = new byte[Length];
 037    }
 38}