From 56135c29f8b1530ed55f16b765c23172da1a1c24 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 7 Jul 2026 16:24:37 +0200 Subject: [PATCH] test(wallet): cover TransactionFactory's standardness-policy rejection builder.Verify's failure branch (the safety net right before a signed tx would be returned to the caller) had no test: an absurd fee rate now proves the "Invalid transaction: ..." path fires instead of silently returning a policy-violating transaction. --- .../Wallet/TransactionFactoryTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/PalladiumWallet.Tests/Wallet/TransactionFactoryTests.cs b/tests/PalladiumWallet.Tests/Wallet/TransactionFactoryTests.cs index 668bb2b..c21b1ea 100644 --- a/tests/PalladiumWallet.Tests/Wallet/TransactionFactoryTests.cs +++ b/tests/PalladiumWallet.Tests/Wallet/TransactionFactoryTests.cs @@ -104,6 +104,21 @@ public class TransactionFactoryTests Assert.Contains("unconfirmed", ex.Message); } + [Fact] + public void Una_fee_oltre_la_policy_standard_viene_rifiutata_prima_del_broadcast() + { + // An absurd fee rate produces a fee far above NBitcoin's standard policy + // cap: the builder.Verify safety net must refuse the transaction instead + // of letting a fat-finger fee reach the network. + var account = Account(); + var (utxos, txs) = Fund(account, 100_000_000); // 1 PLM + + var ex = Assert.Throws(() => new TransactionFactory(account).Build( + utxos, txs, account.GetReceiveAddress(1), amountSats: 1_000_000, + feeRateSatPerVByte: 500_000, changeIndex: 0, tipHeight: 100)); + Assert.Contains("Invalid transaction", ex.Message); + } + [Fact] public void Gli_utxo_congelati_sono_esclusi_dalla_spesa() {