< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Protocol.Payloads.PingPayload
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/Payloads/PingPayload.cs
Tag: 30_15166811759
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 46
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_NumPongBytes()100%11100%
get_BytesLength()100%11100%
get_Ignored()100%11100%
.ctor()100%11100%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/Payloads/PingPayload.cs

#LineLine coverage
 1namespace NLightning.Domain.Protocol.Payloads;
 2
 3using Crypto.Constants;
 4using Interfaces;
 5using Messages;
 6
 7/// <summary>
 8/// The ping payload.
 9/// </summary>
 10/// <remarks>
 11/// The ping payload is used to check if the other party is still alive.
 12/// </remarks>
 13/// <seealso cref="PingMessage"/>
 14public class PingPayload : IMessagePayload
 15{
 16    /// <summary>
 17    /// The maximum length of the ignored bytes.
 18    /// </summary>
 19    private const ushort MAX_LENGTH = 65531;
 20
 21    /// <summary>
 22    /// The number of bytes to send in the pong message.
 23    /// </summary>
 7224    public ushort NumPongBytes { get; internal init; }
 25
 26    /// <summary>
 27    /// The number of bytes to ignore.
 28    /// </summary>
 9629    public ushort BytesLength { get; internal init; }
 30
 31    /// <summary>
 32    /// The ignored bytes.
 33    /// </summary>
 8434    public byte[] Ignored { get; internal init; }
 35
 3636    public PingPayload()
 37    {
 3638        var randomGenerator = new Random();
 39        // Get number of bytes at random between HashConstants.SHA256_HASH_LEN and ushort.MaxValue
 3640        NumPongBytes = (ushort)randomGenerator.Next(byte.MaxValue, MAX_LENGTH);
 3641        BytesLength = (ushort)randomGenerator.Next(HashConstants.SHA256_HASH_LEN, 4 * HashConstants.SHA256_HASH_LEN);
 42
 3643        Ignored = new byte[BytesLength];
 3644        randomGenerator.NextBytes(Ignored);
 3645    }
 46}