< Summary - Combined Code Coverage

Information
Class: NLightning.Bolt11.Models.TaggedFields.PayeePubKeyTaggedField
Assembly: NLightning.Bolt11
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Bolt11/Models/TaggedFields/PayeePubKeyTaggedField.cs
Tag: 36_15743069263
Line coverage
80%
Covered lines: 12
Uncovered lines: 3
Coverable lines: 15
Total lines: 64
Line coverage: 80%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Type()100%11100%
get_Value()100%11100%
get_Length()100%11100%
.ctor(...)100%11100%
WriteToBitWriter(...)100%11100%
IsValid()100%11100%
FromBitReader(...)50%2.5250%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Bolt11/Models/TaggedFields/PayeePubKeyTaggedField.cs

#LineLine coverage
 1using NBitcoin;
 2
 3namespace NLightning.Bolt11.Models.TaggedFields;
 4
 5using Constants;
 6using Domain.Utils;
 7using Enums;
 8using Interfaces;
 9
 10/// <summary>
 11/// Tagged field for the payee public key
 12/// </summary>
 13/// <remarks>
 14/// The payee public key is a 33-byte public key used to identify the payee
 15/// </remarks>
 16/// <seealso cref="ITaggedField"/>
 17internal sealed class PayeePubKeyTaggedField : ITaggedField
 18{
 51219    public TaggedFieldTypes Type => TaggedFieldTypes.PayeePubKey;
 6020    internal PubKey Value { get; }
 1221    public short Length => TaggedFieldConstants.PayeePubkeyLength;
 22
 23    /// <summary>
 24    /// Initializes a new instance of the <see cref="ExpiryTimeTaggedField"/> class.
 25    /// </summary>
 26    /// <param name="value">The Expiry Time in seconds</param>
 6427    internal PayeePubKeyTaggedField(PubKey value)
 28    {
 6429        Value = value;
 6430    }
 31
 32    /// <inheritdoc/>
 33    public void WriteToBitWriter(BitWriter bitWriter)
 34    {
 35        // Write data
 436        bitWriter.WriteBits(Value.ToBytes(), Length * 5);
 437    }
 38
 39    /// <inheritdoc/>
 40    public bool IsValid()
 41    {
 6442        return true;
 43    }
 44
 45    /// <summary>
 46    /// Reads a PayeePubKeyTaggedField from a BitReader
 47    /// </summary>
 48    /// <param name="bitReader">The BitReader to read from</param>
 49    /// <param name="length">The length of the field</param>
 50    /// <returns>The PayeePubKeyTaggedField</returns>
 51    /// <exception cref="ArgumentException">Thrown when the length is invalid</exception>
 52    internal static PayeePubKeyTaggedField FromBitReader(BitReader bitReader, short length)
 53    {
 454        if (length != TaggedFieldConstants.PayeePubkeyLength)
 455            throw new ArgumentException(
 456                $"Invalid length for {nameof(PayeePubKeyTaggedField)}. Expected {TaggedFieldConstants.PayeePubkeyLength}
 57
 58        // Read the data from the BitReader
 059        var data = new byte[33];
 060        bitReader.ReadBits(data, length * 5);
 61
 062        return new PayeePubKeyTaggedField(new PubKey(data));
 63    }
 64}