Skip to content

Commit 7cb58a5

Browse files
gijswijsguggero
authored andcommitted
itest: add itest for MinRelayFee check
This commit adds an integration test for the MinRelayFee check. The test ensures that transactions with fees below the minimum relay fee are rejected.
1 parent d85e021 commit 7cb58a5

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

itest/litd_custom_channels_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/lightningnetwork/lnd/lntest"
2828
"github.com/lightningnetwork/lnd/lntest/port"
2929
"github.com/lightningnetwork/lnd/lntest/wait"
30+
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
3031
"github.com/lightningnetwork/lnd/lnwire"
3132
"github.com/stretchr/testify/require"
3233
)
@@ -2637,3 +2638,87 @@ func testCustomChannelsOraclePricing(_ context.Context,
26372638
noOpCoOpCloseBalanceCheck,
26382639
)
26392640
}
2641+
2642+
// testCustomChannelsFee tests the whether the custom channel funding process
2643+
// fails if the proposed fee rate is lower than the minimum relay fee.
2644+
func testCustomChannelsFee(_ context.Context,
2645+
net *NetworkHarness, t *harnessTest) {
2646+
2647+
ctxb := context.Background()
2648+
lndArgs := slices.Clone(lndArgsTemplate)
2649+
litdArgs := slices.Clone(litdArgsTemplate)
2650+
2651+
zane, err := net.NewNode(
2652+
t.t, "Zane", lndArgs, false, true, litdArgs...,
2653+
)
2654+
require.NoError(t.t, err)
2655+
2656+
litdArgs = append(litdArgs, fmt.Sprintf(
2657+
"--taproot-assets.proofcourieraddr=%s://%s",
2658+
proof.UniverseRpcCourierType, zane.Cfg.LitAddr(),
2659+
))
2660+
2661+
charlie, err := net.NewNode(
2662+
t.t, "Charlie", lndArgs, false, true, litdArgs...,
2663+
)
2664+
require.NoError(t.t, err)
2665+
dave, err := net.NewNode(t.t, "Dave", lndArgs, false, true, litdArgs...)
2666+
require.NoError(t.t, err)
2667+
2668+
nodes := []*HarnessNode{charlie, dave}
2669+
connectAllNodes(t.t, net, nodes)
2670+
fundAllNodes(t.t, net, nodes)
2671+
2672+
charlieTap := newTapClient(t.t, charlie)
2673+
daveTap := newTapClient(t.t, dave)
2674+
2675+
// Mint an assets on Charlie and sync Dave to Charlie as the universe.
2676+
mintedAssets := itest.MintAssetsConfirmBatch(
2677+
t.t, t.lndHarness.Miner.Client, charlieTap,
2678+
[]*mintrpc.MintAssetRequest{
2679+
{
2680+
Asset: itestAsset,
2681+
},
2682+
},
2683+
)
2684+
cents := mintedAssets[0]
2685+
assetID := cents.AssetGenesis.AssetId
2686+
2687+
t.Logf("Minted %d lightning cents, syncing universes...", cents.Amount)
2688+
syncUniverses(t.t, charlieTap, dave)
2689+
t.Logf("Universes synced between all nodes, distributing assets...")
2690+
2691+
// Fund a channel with a fee rate of zero.
2692+
zeroFeeRate := uint32(0)
2693+
2694+
_, err = charlieTap.FundChannel(
2695+
ctxb, &tchrpc.FundChannelRequest{
2696+
AssetAmount: cents.Amount,
2697+
AssetId: assetID,
2698+
PeerPubkey: daveTap.node.PubKey[:],
2699+
FeeRateSatPerVbyte: zeroFeeRate,
2700+
PushSat: 0,
2701+
},
2702+
)
2703+
2704+
errSpecifyFeerate := "fee rate must be specified"
2705+
require.ErrorContains(t.t, err, errSpecifyFeerate)
2706+
2707+
// Fund a channel with a fee rate that is too low.
2708+
tooLowFeeRate := uint32(1)
2709+
tooLowFeeRateAmount := chainfee.SatPerVByte(tooLowFeeRate)
2710+
2711+
_, err = charlieTap.FundChannel(
2712+
ctxb, &tchrpc.FundChannelRequest{
2713+
AssetAmount: cents.Amount,
2714+
AssetId: assetID,
2715+
PeerPubkey: daveTap.node.PubKey[:],
2716+
FeeRateSatPerVbyte: tooLowFeeRate,
2717+
PushSat: 0,
2718+
},
2719+
)
2720+
2721+
errFeeRateTooLow := fmt.Sprintf("fee rate %s too low, "+
2722+
"min_relay_fee: ", tooLowFeeRateAmount.FeePerKWeight())
2723+
require.ErrorContains(t.t, err, errFeeRateTooLow)
2724+
}

itest/litd_test_list_on_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,8 @@ var allTestCases = []*testCase{
6060
name: "test custom channels oracle pricing",
6161
test: testCustomChannelsOraclePricing,
6262
},
63+
{
64+
name: "test custom channels fee",
65+
test: testCustomChannelsFee,
66+
},
6367
}

0 commit comments

Comments
 (0)