Skip to content

Commit

Permalink
itest: add itest for MinRelayFee check
Browse files Browse the repository at this point in the history
This commit adds an integration test for the MinRelayFee check. The test
ensures that transactions with fees below the minimum relay fee are
rejected.
  • Loading branch information
gijswijs committed Nov 1, 2024
1 parent 3a8f1f6 commit 2506456
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
69 changes: 69 additions & 0 deletions itest/litd_custom_channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/port"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -2637,3 +2638,71 @@ func testCustomChannelsOraclePricing(_ context.Context,
noOpCoOpCloseBalanceCheck,
)
}

// testCustomChannelsFee tests the whether the custom channel funding process
// fails if the proposed fee rate is lower than the minimum relay fee.
func testCustomChannelsFee(_ context.Context,
net *NetworkHarness, t *harnessTest) {

ctxb := context.Background()
lndArgs := slices.Clone(lndArgsTemplate)
litdArgs := slices.Clone(litdArgsTemplate)

zane, err := net.NewNode(
t.t, "Zane", lndArgs, false, true, litdArgs...,
)
require.NoError(t.t, err)

litdArgs = append(litdArgs, fmt.Sprintf(
"--taproot-assets.proofcourieraddr=%s://%s",
proof.UniverseRpcCourierType, zane.Cfg.LitAddr(),
))

charlie, err := net.NewNode(
t.t, "Charlie", lndArgs, false, true, litdArgs...,
)
require.NoError(t.t, err)
dave, err := net.NewNode(t.t, "Dave", lndArgs, false, true, litdArgs...)
require.NoError(t.t, err)

nodes := []*HarnessNode{charlie, dave}
connectAllNodes(t.t, net, nodes)
fundAllNodes(t.t, net, nodes)

charlieTap := newTapClient(t.t, charlie)
daveTap := newTapClient(t.t, dave)

// Mint an assets on Charlie and sync Dave to Charlie as the universe.
mintedAssets := itest.MintAssetsConfirmBatch(
t.t, t.lndHarness.Miner.Client, charlieTap,
[]*mintrpc.MintAssetRequest{
{
Asset: itestAsset,
},
},
)
cents := mintedAssets[0]
assetID := cents.AssetGenesis.AssetId

t.Logf("Minted %d lightning cents, syncing universes...", cents.Amount)
syncUniverses(t.t, charlieTap, dave)
t.Logf("Universes synced between all nodes, distributing assets...")

// Fund a channel with a fee rate that is too low.
tooLowFeeRate := uint32(1)
tooLowFeeRateAmount := chainfee.SatPerVByte(tooLowFeeRate)

_, err = charlieTap.FundChannel(
ctxb, &tchrpc.FundChannelRequest{
AssetAmount: cents.Amount,
AssetId: assetID,
PeerPubkey: daveTap.node.PubKey[:],
FeeRateSatPerVbyte: tooLowFeeRate,
PushSat: 0,
},
)

errStr := fmt.Sprintf("fee rate %s too low, min_relay_fee: ",
tooLowFeeRateAmount.FeePerKWeight())
require.ErrorContains(t.t, err, errStr)
}
4 changes: 4 additions & 0 deletions itest/litd_test_list_on_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ var allTestCases = []*testCase{
name: "test custom channels oracle pricing",
test: testCustomChannelsOraclePricing,
},
{
name: "test custom channels fee",
test: testCustomChannelsFee,
},
}

0 comments on commit 2506456

Please sign in to comment.