< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Persistence.EntityConfiguration.Channel.ChannelConfigEntityConfiguration
Assembly: NLightning.Infrastructure.Persistence
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Channel/ChannelConfigEntityConfiguration.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 33
Coverable lines: 33
Total lines: 51
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
ConfigureChannelConfigEntity(...)0%620%
OptimizeConfigurationForSqlServer(...)100%210%

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Channel;
 5
 6using Domain.Channels.Constants;
 7using Entities.Channel;
 8using Enums;
 9using ValueConverters;
 10
 11public static class ChannelConfigEntityConfiguration
 12{
 13    public static void ConfigureChannelConfigEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 14    {
 015        modelBuilder.Entity<ChannelConfigEntity>(entity =>
 016        {
 017            // Set PrimaryKey
 018            entity.HasKey(e => e.ChannelId);
 019
 020            // Set required props
 021            entity.Property(e => e.ChannelId)
 022                  .HasConversion<ChannelIdConverter>()
 023                  .IsRequired();
 024            entity.Property(e => e.MinimumDepth).IsRequired();
 025            entity.Property(e => e.ToSelfDelay).IsRequired();
 026            entity.Property(e => e.MaxAcceptedHtlcs).IsRequired();
 027            entity.Property(e => e.LocalDustLimitAmountSats).IsRequired();
 028            entity.Property(e => e.RemoteDustLimitAmountSats).IsRequired();
 029            entity.Property(e => e.HtlcMinimumMsat).IsRequired();
 030            entity.Property(e => e.MaxHtlcAmountInFlight).IsRequired();
 031            entity.Property(e => e.FeeRatePerKwSatoshis).IsRequired();
 032            entity.Property(e => e.OptionAnchorOutputs).IsRequired();
 033
 034            // Nullable byte[] properties
 035            entity.Property(e => e.LocalUpfrontShutdownScript).IsRequired(false);
 036            entity.Property(e => e.RemoteUpfrontShutdownScript).IsRequired(false);
 037
 038            if (databaseType == DatabaseType.MicrosoftSql)
 039            {
 040                OptimizeConfigurationForSqlServer(entity);
 041            }
 042        });
 043    }
 44
 45    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<ChannelConfigEntity> entity)
 46    {
 047        entity.Property(e => e.ChannelId).HasColumnType($"varbinary({ChannelConstants.ChannelIdLength})");
 048        entity.Property(e => e.LocalUpfrontShutdownScript).HasColumnType("varbinary(max)");
 049        entity.Property(e => e.RemoteUpfrontShutdownScript).HasColumnType("varbinary(max)");
 050    }
 51}