< Summary - Combined Code Coverage

Information
Class: NLightning.Bolt11.Models.TaggedFields.FeaturesTaggedField
Assembly: NLightning.Bolt11
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Bolt11/Models/TaggedFields/FeaturesTaggedField.cs
Tag: 30_15166811759
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 65
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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(...)100%22100%

File(s)

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

#LineLine coverage
 1namespace NLightning.Bolt11.Models.TaggedFields;
 2
 3using Common.Utils;
 4using Domain.Node;
 5using Enums;
 6using Interfaces;
 7
 8/// <summary>
 9/// Tagged field for features
 10/// </summary>
 11/// <remarks>
 12/// The features are a collection of features that are supported by the node.
 13/// </remarks>
 14/// <seealso cref="ITaggedField"/>
 15internal sealed class FeaturesTaggedField : ITaggedField
 16{
 100817    public TaggedFieldTypes Type => TaggedFieldTypes.FEATURES;
 22018    internal FeatureSet Value { get; }
 32019    public short Length { get; }
 20
 21    /// <summary>
 22    /// Initializes a new instance of the <see cref="DescriptionTaggedField"/> class.
 23    /// </summary>
 24    /// <param name="value">The Description</param>
 15225    internal FeaturesTaggedField(FeatureSet value)
 26    {
 15227        Value = value;
 15228        Length = (short)(value.SizeInBits / 5 + (value.SizeInBits % 5 == 0 ? 0 : 1));
 15229    }
 30
 31    /// <inheritdoc/>
 32    public void WriteToBitWriter(BitWriter bitWriter)
 33    {
 6434        var shouldPad = Length * 5 / 8 == (Length * 5 - 7) / 8;
 35
 36        // Write data
 6437        Value.WriteToBitWriter(bitWriter, Length * 5, shouldPad);
 6438    }
 39
 40    /// <inheritdoc/>
 41    public bool IsValid()
 42    {
 6443        return true;
 44    }
 45
 46    /// <summary>
 47    /// Reads a FeaturesTaggedField from a BitReader
 48    /// </summary>
 49    /// <param name="bitReader">The BitReader to read from</param>
 50    /// <param name="length">The length of the field</param>
 51    /// <returns>The FeaturesTaggedField</returns>
 52    /// <exception cref="ArgumentException">Thrown when the length is invalid</exception>
 53    internal static FeaturesTaggedField FromBitReader(BitReader bitReader, short length)
 54    {
 8055        if (length <= 0)
 56        {
 457            throw new ArgumentException("Invalid length for FeaturesTaggedField. Length must be greater than 0", nameof(
 58        }
 59
 7660        var shouldPad = length * 5 / 8 == (length * 5 - 7) / 8;
 7661        var features = FeatureSet.DeserializeFromBitReader(bitReader, length * 5, shouldPad);
 62
 7663        return new FeaturesTaggedField(features);
 64    }
 65}