< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Protocol.Validators.TxAddInputValidator
Assembly: NLightning.Infrastructure
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure/Protocol/Validators/TxAddInputValidator.cs
Tag: 30_15166811759
Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 60
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
Validate()0%272160%
GetOutputCount(...)100%210%
IsScriptPubKeyValid(...)100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure/Protocol/Validators/TxAddInputValidator.cs

#LineLine coverage
 1namespace NLightning.Infrastructure.Protocol.Validators;
 2
 3using Domain.Protocol.Constants;
 4using Domain.Protocol.Payloads;
 5
 6public static class TxAddInputValidator
 7{
 8    public static async void Validate(bool isInitiator, TxAddInputPayload input, int currentInputCount, Func<byte[], Tas
 9    {
 010        if (isInitiator && (input.SerialId & 1) != 0) // Ensure even serial_id for initiator
 11        {
 012            throw new InvalidOperationException("SerialId has the wrong parity.");
 13        }
 14
 015        if (!isSerialIdUnique(input.SerialId))
 16        {
 017            throw new InvalidOperationException("SerialId is already included in the transaction.");
 18        }
 19
 020        if (!await isValidPrevTx(input.PrevTx))
 21        {
 022            throw new InvalidOperationException("PrevTx is not a valid transaction.");
 23        }
 24
 025        if (input.PrevTxVout >= GetOutputCount(input.PrevTx))
 26        {
 027            throw new InvalidOperationException("PrevTxVout is greater than or equal to the number of outputs on PrevTx.
 28        }
 29
 030        if (!IsScriptPubKeyValid(input.PrevTx, input.PrevTxVout))
 31        {
 032            throw new InvalidOperationException("ScriptPubKey of the PrevTxVout output is not valid.");
 33        }
 34
 035        if (!isUniqueInput(input.PrevTx, input.PrevTxVout))
 36        {
 037            throw new InvalidOperationException("The PrevTx and PrevTxVout are identical to a previously added input.");
 38        }
 39
 040        if (currentInputCount >= InteractiveTransactionConstants.MAX_INPUTS_ALLOWED)
 41        {
 042            throw new InvalidOperationException($"Cannot receive more than {InteractiveTransactionConstants.MAX_INPUTS_A
 43        }
 044    }
 45
 46    private static uint GetOutputCount(byte[] prevTx)
 47    {
 48        _ = prevTx;
 49        // TODO: Implement logic to parse prevTx and return the output count
 050        return 1;
 51    }
 52
 53    private static bool IsScriptPubKeyValid(byte[] prevTx, uint prevTxVout)
 54    {
 55        _ = prevTx;
 56        _ = prevTxVout;
 57        // TODO: Implement logic to parse prevTx and check the scriptPubKey of the given output
 058        return true;
 59    }
 60}