< 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: 30_15166811759
Line coverage
71%
Covered lines: 10
Uncovered lines: 4
Coverable lines: 14
Total lines: 65
Line coverage: 71.4%
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%210%
FromBitReader(...)50%2.86240%

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 Common.Utils;
 6using Constants;
 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 that is used to identify the payee
 15/// </remarks>
 16/// <seealso cref="ITaggedField"/>
 17internal sealed class PayeePubKeyTaggedField : ITaggedField
 18{
 44819    public TaggedFieldTypes Type => TaggedFieldTypes.PAYEE_PUB_KEY;
 6020    internal PubKey Value { get; }
 1221    public short Length => TaggedFieldConstants.PAYEE_PUBKEY_LENGTH;
 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    {
 042        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.PAYEE_PUBKEY_LENGTH)
 55        {
 456            throw new ArgumentException($"Invalid length for DescriptionHashTaggedField. Expected {TaggedFieldConstants.
 57        }
 58
 59        // Read the data from the BitReader
 060        var data = new byte[33];
 061        bitReader.ReadBits(data, length * 5);
 62
 063        return new PayeePubKeyTaggedField(new PubKey(data));
 64    }
 65}