< Summary - Combined Code Coverage

Line coverage
0%
Covered lines: 0
Uncovered lines: 422
Coverable lines: 422
Total lines: 492
Line coverage: 0%
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
File 1: Up(...)100%210%
File 1: Down(...)100%210%
File 2: BuildTargetModel(...)100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence.SqlServer/Migrations/20250612173132_AddBlockchaisStateAndWatchedTransaction.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore.Migrations;
 2
 3#nullable disable
 4
 5namespace NLightning.Infrastructure.Persistence.SqlServer.Migrations
 6{
 7    /// <inheritdoc />
 8    public partial class AddBlockchaisStateAndWatchedTransaction : Migration
 9    {
 10        /// <inheritdoc />
 11        protected override void Up(MigrationBuilder migrationBuilder)
 12        {
 013            migrationBuilder.AlterColumn<int>(
 014                name: "FundingOutputIndex",
 015                table: "Channels",
 016                type: "int",
 017                nullable: false,
 018                oldClrType: typeof(long),
 019                oldType: "bigint");
 20
 021            migrationBuilder.AddColumn<byte[]>(
 022                name: "PeerEntityNodeId",
 023                table: "Channels",
 024                type: "varbinary(33)",
 025                nullable: true);
 26
 027            migrationBuilder.CreateTable(
 028                name: "BlockchainStates",
 029                columns: table => new
 030                {
 031                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
 032                    LastProcessedHeight = table.Column<long>(type: "bigint", nullable: false),
 033                    LastProcessedBlockHash = table.Column<byte[]>(type: "varbinary(32)", nullable: false),
 034                    LastProcessedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
 035                },
 036                constraints: table =>
 037                {
 038                    table.PrimaryKey("PK_BlockchainStates", x => x.Id);
 039                });
 40
 041            migrationBuilder.CreateTable(
 042                name: "Peers",
 043                columns: table => new
 044                {
 045                    NodeId = table.Column<byte[]>(type: "varbinary(33)", nullable: false),
 046                    Host = table.Column<string>(type: "nvarchar(max)", nullable: false),
 047                    Port = table.Column<long>(type: "bigint", nullable: false),
 048                    LastSeenAt = table.Column<DateTime>(type: "datetime2", nullable: false)
 049                },
 050                constraints: table =>
 051                {
 052                    table.PrimaryKey("PK_Peers", x => x.NodeId);
 053                });
 54
 055            migrationBuilder.CreateTable(
 056                name: "WatchedTransactions",
 057                columns: table => new
 058                {
 059                    TransactionId = table.Column<byte[]>(type: "varbinary(32)", nullable: false),
 060                    ChannelId = table.Column<byte[]>(type: "varbinary(32)", nullable: false),
 061                    RequiredDepth = table.Column<long>(type: "bigint", nullable: false),
 062                    FirstSeenAtHeight = table.Column<long>(type: "bigint", nullable: true),
 063                    TransactionIndex = table.Column<int>(type: "int", nullable: true),
 064                    CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
 065                    CompletedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
 066                },
 067                constraints: table =>
 068                {
 069                    table.PrimaryKey("PK_WatchedTransactions", x => x.TransactionId);
 070                    table.ForeignKey(
 071                        name: "FK_WatchedTransactions_Channels_ChannelId",
 072                        column: x => x.ChannelId,
 073                        principalTable: "Channels",
 074                        principalColumn: "ChannelId",
 075                        onDelete: ReferentialAction.Cascade);
 076                });
 77
 078            migrationBuilder.CreateIndex(
 079                name: "IX_Channels_PeerEntityNodeId",
 080                table: "Channels",
 081                column: "PeerEntityNodeId");
 82
 083            migrationBuilder.CreateIndex(
 084                name: "IX_WatchedTransactions_ChannelId",
 085                table: "WatchedTransactions",
 086                column: "ChannelId");
 87
 088            migrationBuilder.AddForeignKey(
 089                name: "FK_Channels_Peers_PeerEntityNodeId",
 090                table: "Channels",
 091                column: "PeerEntityNodeId",
 092                principalTable: "Peers",
 093                principalColumn: "NodeId");
 094        }
 95
 96        /// <inheritdoc />
 97        protected override void Down(MigrationBuilder migrationBuilder)
 98        {
 099            migrationBuilder.DropForeignKey(
 0100                name: "FK_Channels_Peers_PeerEntityNodeId",
 0101                table: "Channels");
 102
 0103            migrationBuilder.DropTable(
 0104                name: "BlockchainStates");
 105
 0106            migrationBuilder.DropTable(
 0107                name: "Peers");
 108
 0109            migrationBuilder.DropTable(
 0110                name: "WatchedTransactions");
 111
 0112            migrationBuilder.DropIndex(
 0113                name: "IX_Channels_PeerEntityNodeId",
 0114                table: "Channels");
 115
 0116            migrationBuilder.DropColumn(
 0117                name: "PeerEntityNodeId",
 0118                table: "Channels");
 119
 0120            migrationBuilder.AlterColumn<long>(
 0121                name: "FundingOutputIndex",
 0122                table: "Channels",
 0123                type: "bigint",
 0124                nullable: false,
 0125                oldClrType: typeof(int),
 0126                oldType: "int");
 0127        }
 128    }
 129}

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence.SqlServer/Migrations/20250612173132_AddBlockchaisStateAndWatchedTransaction.Designer.cs

#LineLine coverage
 1// <auto-generated />
 2using System;
 3using Microsoft.EntityFrameworkCore;
 4using Microsoft.EntityFrameworkCore.Infrastructure;
 5using Microsoft.EntityFrameworkCore.Metadata;
 6using Microsoft.EntityFrameworkCore.Migrations;
 7using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 8using NLightning.Infrastructure.Persistence.Contexts;
 9
 10#nullable disable
 11
 12namespace NLightning.Infrastructure.Persistence.SqlServer.Migrations
 13{
 14    [DbContext(typeof(NLightningDbContext))]
 15    [Migration("20250612173132_AddBlockchaisStateAndWatchedTransaction")]
 16    partial class AddBlockchaisStateAndWatchedTransaction
 17    {
 18        /// <inheritdoc />
 19        protected override void BuildTargetModel(ModelBuilder modelBuilder)
 20        {
 21#pragma warning disable 612, 618
 022            modelBuilder
 023                .HasAnnotation("ProductVersion", "8.0.12")
 024                .HasAnnotation("Relational:MaxIdentifierLength", 128);
 25
 026            SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
 27
 028            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Bitcoin.BlockchainStateEntity", b =>
 029                {
 030                    b.Property<Guid>("Id")
 031                        .ValueGeneratedOnAdd()
 032                        .HasColumnType("uniqueidentifier");
 033
 034                    b.Property<DateTime>("LastProcessedAt")
 035                        .HasColumnType("datetime2");
 036
 037                    b.Property<byte[]>("LastProcessedBlockHash")
 038                        .IsRequired()
 039                        .HasColumnType("varbinary(32)");
 040
 041                    b.Property<long>("LastProcessedHeight")
 042                        .HasColumnType("bigint");
 043
 044                    b.HasKey("Id");
 045
 046                    b.ToTable("BlockchainStates");
 047                });
 48
 049            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Bitcoin.WatchedTransactionEntity", b =>
 050                {
 051                    b.Property<byte[]>("TransactionId")
 052                        .HasColumnType("varbinary(32)");
 053
 054                    b.Property<byte[]>("ChannelId")
 055                        .IsRequired()
 056                        .HasColumnType("varbinary(32)");
 057
 058                    b.Property<DateTime?>("CompletedAt")
 059                        .HasColumnType("datetime2");
 060
 061                    b.Property<DateTime>("CreatedAt")
 062                        .HasColumnType("datetime2");
 063
 064                    b.Property<long?>("FirstSeenAtHeight")
 065                        .HasColumnType("bigint");
 066
 067                    b.Property<long>("RequiredDepth")
 068                        .HasColumnType("bigint");
 069
 070                    b.Property<int?>("TransactionIndex")
 071                        .HasColumnType("int");
 072
 073                    b.HasKey("TransactionId");
 074
 075                    b.HasIndex("ChannelId");
 076
 077                    b.ToTable("WatchedTransactions");
 078                });
 79
 080            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelConfigEntity", b =>
 081                {
 082                    b.Property<byte[]>("ChannelId")
 083                        .HasColumnType("varbinary(32)");
 084
 085                    b.Property<long?>("ChannelReserveAmountSats")
 086                        .HasColumnType("bigint");
 087
 088                    b.Property<long>("FeeRatePerKwSatoshis")
 089                        .HasColumnType("bigint");
 090
 091                    b.Property<decimal>("HtlcMinimumMsat")
 092                        .HasColumnType("decimal(20,0)");
 093
 094                    b.Property<long>("LocalDustLimitAmountSats")
 095                        .HasColumnType("bigint");
 096
 097                    b.Property<byte[]>("LocalUpfrontShutdownScript")
 098                        .HasColumnType("varbinary(max)");
 099
 0100                    b.Property<int>("MaxAcceptedHtlcs")
 0101                        .HasColumnType("int");
 0102
 0103                    b.Property<decimal>("MaxHtlcAmountInFlight")
 0104                        .HasColumnType("decimal(20,0)");
 0105
 0106                    b.Property<long>("MinimumDepth")
 0107                        .HasColumnType("bigint");
 0108
 0109                    b.Property<bool>("OptionAnchorOutputs")
 0110                        .HasColumnType("bit");
 0111
 0112                    b.Property<long>("RemoteDustLimitAmountSats")
 0113                        .HasColumnType("bigint");
 0114
 0115                    b.Property<byte[]>("RemoteUpfrontShutdownScript")
 0116                        .HasColumnType("varbinary(max)");
 0117
 0118                    b.Property<int>("ToSelfDelay")
 0119                        .HasColumnType("int");
 0120
 0121                    b.Property<byte>("UseScidAlias")
 0122                        .HasColumnType("tinyint");
 0123
 0124                    b.HasKey("ChannelId");
 0125
 0126                    b.ToTable("ChannelConfigs");
 0127                });
 128
 0129            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", b =>
 0130                {
 0131                    b.Property<byte[]>("ChannelId")
 0132                        .HasColumnType("varbinary(32)");
 0133
 0134                    b.Property<long>("FundingAmountSatoshis")
 0135                        .HasColumnType("bigint");
 0136
 0137                    b.Property<long>("FundingCreatedAtBlockHeight")
 0138                        .HasColumnType("bigint");
 0139
 0140                    b.Property<int>("FundingOutputIndex")
 0141                        .HasColumnType("int");
 0142
 0143                    b.Property<byte[]>("FundingTxId")
 0144                        .IsRequired()
 0145                        .HasColumnType("varbinary(32)");
 0146
 0147                    b.Property<bool>("IsInitiator")
 0148                        .HasColumnType("bit");
 0149
 0150                    b.Property<byte[]>("LastReceivedSignature")
 0151                        .HasColumnType("varbinary(64)");
 0152
 0153                    b.Property<byte[]>("LastSentSignature")
 0154                        .HasColumnType("varbinary(64)");
 0155
 0156                    b.Property<long>("LocalBalanceSatoshis")
 0157                        .HasColumnType("bigint");
 0158
 0159                    b.Property<decimal>("LocalNextHtlcId")
 0160                        .HasColumnType("decimal(20,0)");
 0161
 0162                    b.Property<decimal>("LocalRevocationNumber")
 0163                        .HasColumnType("decimal(20,0)");
 0164
 0165                    b.Property<byte[]>("PeerEntityNodeId")
 0166                        .HasColumnType("varbinary(33)");
 0167
 0168                    b.Property<long>("RemoteBalanceSatoshis")
 0169                        .HasColumnType("bigint");
 0170
 0171                    b.Property<decimal>("RemoteNextHtlcId")
 0172                        .HasColumnType("decimal(20,0)");
 0173
 0174                    b.Property<byte[]>("RemoteNodeId")
 0175                        .IsRequired()
 0176                        .HasColumnType("varbinary(32)");
 0177
 0178                    b.Property<decimal>("RemoteRevocationNumber")
 0179                        .HasColumnType("decimal(20,0)");
 0180
 0181                    b.Property<byte>("State")
 0182                        .HasColumnType("tinyint");
 0183
 0184                    b.Property<byte>("Version")
 0185                        .HasColumnType("tinyint");
 0186
 0187                    b.HasKey("ChannelId");
 0188
 0189                    b.HasIndex("PeerEntityNodeId");
 0190
 0191                    b.ToTable("Channels");
 0192                });
 193
 0194            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelKeySetEntity", b =>
 0195                {
 0196                    b.Property<byte[]>("ChannelId")
 0197                        .HasColumnType("varbinary(32)");
 0198
 0199                    b.Property<bool>("IsLocal")
 0200                        .HasColumnType("bit");
 0201
 0202                    b.Property<decimal>("CurrentPerCommitmentIndex")
 0203                        .HasColumnType("decimal(20,0)");
 0204
 0205                    b.Property<byte[]>("CurrentPerCommitmentPoint")
 0206                        .IsRequired()
 0207                        .HasColumnType("varbinary(33)");
 0208
 0209                    b.Property<byte[]>("DelayedPaymentBasepoint")
 0210                        .IsRequired()
 0211                        .HasColumnType("varbinary(33)");
 0212
 0213                    b.Property<byte[]>("FundingPubKey")
 0214                        .IsRequired()
 0215                        .HasColumnType("varbinary(33)");
 0216
 0217                    b.Property<byte[]>("HtlcBasepoint")
 0218                        .IsRequired()
 0219                        .HasColumnType("varbinary(33)");
 0220
 0221                    b.Property<long>("KeyIndex")
 0222                        .HasColumnType("bigint");
 0223
 0224                    b.Property<byte[]>("LastRevealedPerCommitmentSecret")
 0225                        .HasColumnType("varbinary(max)");
 0226
 0227                    b.Property<byte[]>("PaymentBasepoint")
 0228                        .IsRequired()
 0229                        .HasColumnType("varbinary(33)");
 0230
 0231                    b.Property<byte[]>("RevocationBasepoint")
 0232                        .IsRequired()
 0233                        .HasColumnType("varbinary(33)");
 0234
 0235                    b.HasKey("ChannelId", "IsLocal");
 0236
 0237                    b.ToTable("ChannelKeySets");
 0238                });
 239
 0240            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.HtlcEntity", b =>
 0241                {
 0242                    b.Property<byte[]>("ChannelId")
 0243                        .HasColumnType("varbinary(32)");
 0244
 0245                    b.Property<decimal>("HtlcId")
 0246                        .HasColumnType("decimal(20,0)");
 0247
 0248                    b.Property<byte>("Direction")
 0249                        .HasColumnType("tinyint");
 0250
 0251                    b.Property<byte[]>("AddMessageBytes")
 0252                        .IsRequired()
 0253                        .HasColumnType("varbinary(max)");
 0254
 0255                    b.Property<decimal>("AmountMsat")
 0256                        .HasColumnType("decimal(20,0)");
 0257
 0258                    b.Property<long>("CltvExpiry")
 0259                        .HasColumnType("bigint");
 0260
 0261                    b.Property<decimal>("ObscuredCommitmentNumber")
 0262                        .HasColumnType("decimal(20,0)");
 0263
 0264                    b.Property<byte[]>("PaymentHash")
 0265                        .IsRequired()
 0266                        .HasColumnType("varbinary(32)");
 0267
 0268                    b.Property<byte[]>("PaymentPreimage")
 0269                        .HasColumnType("varbinary(32)");
 0270
 0271                    b.Property<byte[]>("Signature")
 0272                        .HasColumnType("varbinary(max)");
 0273
 0274                    b.Property<byte>("State")
 0275                        .HasColumnType("tinyint");
 0276
 0277                    b.HasKey("ChannelId", "HtlcId", "Direction");
 0278
 0279                    b.ToTable("Htlcs");
 0280                });
 281
 0282            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Node.PeerEntity", b =>
 0283                {
 0284                    b.Property<byte[]>("NodeId")
 0285                        .HasColumnType("varbinary(33)");
 0286
 0287                    b.Property<string>("Host")
 0288                        .IsRequired()
 0289                        .HasColumnType("nvarchar(max)");
 0290
 0291                    b.Property<DateTime>("LastSeenAt")
 0292                        .HasColumnType("datetime2");
 0293
 0294                    b.Property<long>("Port")
 0295                        .HasColumnType("bigint");
 0296
 0297                    b.HasKey("NodeId");
 0298
 0299                    b.ToTable("Peers");
 0300                });
 301
 0302            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Bitcoin.WatchedTransactionEntity", b =>
 0303                {
 0304                    b.HasOne("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", null)
 0305                        .WithMany("WatchedTransactions")
 0306                        .HasForeignKey("ChannelId")
 0307                        .OnDelete(DeleteBehavior.Cascade)
 0308                        .IsRequired();
 0309                });
 310
 0311            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelConfigEntity", b =>
 0312                {
 0313                    b.HasOne("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", null)
 0314                        .WithOne("Config")
 0315                        .HasForeignKey("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelConfigEntity", "Ch
 0316                        .OnDelete(DeleteBehavior.Cascade)
 0317                        .IsRequired();
 0318                });
 319
 0320            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", b =>
 0321                {
 0322                    b.HasOne("NLightning.Infrastructure.Persistence.Entities.Node.PeerEntity", null)
 0323                        .WithMany("Channels")
 0324                        .HasForeignKey("PeerEntityNodeId");
 0325                });
 326
 0327            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelKeySetEntity", b =>
 0328                {
 0329                    b.HasOne("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", null)
 0330                        .WithMany("KeySets")
 0331                        .HasForeignKey("ChannelId")
 0332                        .OnDelete(DeleteBehavior.Cascade)
 0333                        .IsRequired();
 0334                });
 335
 0336            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.HtlcEntity", b =>
 0337                {
 0338                    b.HasOne("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", null)
 0339                        .WithMany("Htlcs")
 0340                        .HasForeignKey("ChannelId")
 0341                        .OnDelete(DeleteBehavior.Cascade)
 0342                        .IsRequired();
 0343                });
 344
 0345            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Channel.ChannelEntity", b =>
 0346                {
 0347                    b.Navigation("Config");
 0348
 0349                    b.Navigation("Htlcs");
 0350
 0351                    b.Navigation("KeySets");
 0352
 0353                    b.Navigation("WatchedTransactions");
 0354                });
 355
 0356            modelBuilder.Entity("NLightning.Infrastructure.Persistence.Entities.Node.PeerEntity", b =>
 0357                {
 0358                    b.Navigation("Channels");
 0359                });
 360#pragma warning restore 612, 618
 0361        }
 362    }
 363}