< Summary - Combined Code Coverage

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

File(s)

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

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Channel;
 5
 6using Domain.Channels.Constants;
 7using Domain.Crypto.Constants;
 8using Entities.Channel;
 9using Enums;
 10using ValueConverters;
 11
 12public static class ChannelKeySetEntityConfiguration
 13{
 14    public static void ConfigureChannelKeySetEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 15    {
 016        modelBuilder.Entity<ChannelKeySetEntity>(entity =>
 017        {
 018            // Composite key
 019            entity.HasKey(e => new { e.ChannelId, e.IsLocal });
 020
 021            // Set required props
 022            entity.Property(e => e.IsLocal).IsRequired();
 023            entity.Property(e => e.CurrentPerCommitmentIndex).IsRequired();
 024            entity.Property(e => e.KeyIndex).IsRequired();
 025
 026            // Required byte[] properties
 027            entity.Property(e => e.ChannelId)
 028                  .HasConversion<ChannelIdConverter>()
 029                  .IsRequired();
 030            entity.Property(e => e.FundingPubKey).IsRequired();
 031            entity.Property(e => e.RevocationBasepoint).IsRequired();
 032            entity.Property(e => e.PaymentBasepoint).IsRequired();
 033            entity.Property(e => e.DelayedPaymentBasepoint).IsRequired();
 034            entity.Property(e => e.HtlcBasepoint).IsRequired();
 035            entity.Property(e => e.CurrentPerCommitmentPoint).IsRequired();
 036
 037            // Nullable byte[] properties
 038            entity.Property(e => e.LastRevealedPerCommitmentSecret).IsRequired(false);
 039
 040            if (databaseType == DatabaseType.MicrosoftSql)
 041                OptimizeConfigurationForSqlServer(entity);
 042        });
 043    }
 44
 45    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<ChannelKeySetEntity> entity)
 46    {
 047        entity.Property(e => e.ChannelId).HasColumnType($"varbinary({ChannelConstants.ChannelIdLength})");
 048        entity.Property(e => e.FundingPubKey).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 049        entity.Property(e => e.RevocationBasepoint).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 050        entity.Property(e => e.PaymentBasepoint).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 051        entity.Property(e => e.DelayedPaymentBasepoint).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 052        entity.Property(e => e.HtlcBasepoint).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 053        entity.Property(e => e.CurrentPerCommitmentPoint)
 054              .HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 055    }
 56}