< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Persistence.EntityConfiguration.Channel.HtlcEntityConfiguration
Assembly: NLightning.Infrastructure.Persistence
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Channel/HtlcEntityConfiguration.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 35
Coverable lines: 35
Total lines: 54
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ConfigureHtlcEntity(...)0%620%
OptimizeConfigurationForSqlServer(...)100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Channel/HtlcEntityConfiguration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Channel;
 5
 6using Domain.Bitcoin.Transactions.Constants;
 7using Domain.Channels.Constants;
 8using Entities.Channel;
 9using Enums;
 10using ValueConverters;
 11
 12public static class HtlcEntityConfiguration
 13{
 14    public static void ConfigureHtlcEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 15    {
 016        modelBuilder.Entity<HtlcEntity>(entity =>
 017        {
 018            // Configure the composite key using ChannelId, HtlcId, and Direction
 019            entity.HasKey(h => new { h.ChannelId, h.HtlcId, h.Direction });
 020
 021            // Set required props
 022            entity.Property(e => e.HtlcId).IsRequired();
 023            entity.Property(e => e.Direction).IsRequired();
 024            entity.Property(e => e.AmountMsat).IsRequired();
 025            entity.Property(e => e.CltvExpiry).IsRequired();
 026            entity.Property(e => e.State).IsRequired();
 027            entity.Property(e => e.ObscuredCommitmentNumber).IsRequired();
 028
 029            // Required byte[] properties
 030            entity.Property(h => h.ChannelId)
 031                  .HasConversion<ChannelIdConverter>()
 032                  .IsRequired();
 033            entity.Property(h => h.PaymentHash).IsRequired();
 034            entity.Property(h => h.AddMessageBytes).IsRequired();
 035
 036            // Nullable byte[] properties
 037            entity.Property(h => h.PaymentPreimage).IsRequired(false);
 038            entity.Property(h => h.Signature).IsRequired(false);
 039
 040            if (databaseType == DatabaseType.MicrosoftSql)
 041            {
 042                OptimizeConfigurationForSqlServer(entity);
 043            }
 044        });
 045    }
 46
 47    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<HtlcEntity> entity)
 48    {
 049        entity.Property(h => h.ChannelId).HasColumnType($"varbinary({ChannelConstants.ChannelIdLength})");
 050        entity.Property(h => h.PaymentHash).HasColumnType($"varbinary({TransactionConstants.TxIdLength})");
 051        entity.Property(h => h.PaymentPreimage).HasColumnType($"varbinary({TransactionConstants.TxIdLength})");
 052        entity.Property(h => h.AddMessageBytes).HasColumnType("varbinary(max)");
 053    }
 54}