htlcswitch: optimize tests to not tear down harness

This commit is contained in:
Keagan McClelland committed 2023-07-07 13:30:25 -06:00
1 parent f2bb4ff559
commit 7b179a8e64
1 file changed
+14 -12
+14 -12
View File
@@ -821,10 +821,6 @@ func TestExitNodeTimelockPayloadExceedsHTLC(t *testing.T) {
func TestExitNodeHTLCUnderpaysPayloadAmount(t *testing.T) { func TestExitNodeHTLCUnderpaysPayloadAmount(t *testing.T) {
t.Parallel() t.Parallel()
f := func(underpaymentRand uint64) bool {
underpayment := lnwire.MilliSatoshi(
underpaymentRand%(btcutil.SatoshiPerBitcoin-1) + 1,
)
channels, _, err := createClusterChannels( channels, _, err := createClusterChannels(
t, btcutil.SatoshiPerBitcoin*5, t, btcutil.SatoshiPerBitcoin*5,
btcutil.SatoshiPerBitcoin*5, btcutil.SatoshiPerBitcoin*5,
@@ -839,7 +835,12 @@ func TestExitNodeHTLCUnderpaysPayloadAmount(t *testing.T) {
require.NoError(t, n.start()) require.NoError(t, n.start())
t.Cleanup(n.stop) t.Cleanup(n.stop)
const amount = btcutil.SatoshiPerBitcoin f := func(underpaymentRand uint64) bool {
const amount = btcutil.SatoshiPerBitcoin / 100
underpayment := lnwire.MilliSatoshi(
underpaymentRand%(amount-1) + 1,
)
htlcAmt, htlcExpiry, hops := generateHops( htlcAmt, htlcExpiry, hops := generateHops(
amount, testStartingHeight, n.firstBobChannelLink, amount, testStartingHeight, n.firstBobChannelLink,
) )
@@ -858,7 +859,7 @@ func TestExitNodeHTLCUnderpaysPayloadAmount(t *testing.T) {
return err != nil return err != nil
} }
err := quick.Check(f, &quick.Config{MaxCount: 20}) err = quick.Check(f, nil)
require.NoError(t, err, "payment should have failed but didn't") require.NoError(t, err, "payment should have failed but didn't")
} }
@@ -868,10 +869,6 @@ func TestExitNodeHTLCUnderpaysPayloadAmount(t *testing.T) {
func TestExitNodeHTLCExceedsAmountPayload(t *testing.T) { func TestExitNodeHTLCExceedsAmountPayload(t *testing.T) {
t.Parallel() t.Parallel()
f := func(overpaymentRand uint64) bool {
overpayment := lnwire.MilliSatoshi(
overpaymentRand%(btcutil.SatoshiPerBitcoin-1) + 1,
)
channels, _, err := createClusterChannels( channels, _, err := createClusterChannels(
t, btcutil.SatoshiPerBitcoin*5, t, btcutil.SatoshiPerBitcoin*5,
btcutil.SatoshiPerBitcoin*5, btcutil.SatoshiPerBitcoin*5,
@@ -884,7 +881,12 @@ func TestExitNodeHTLCExceedsAmountPayload(t *testing.T) {
require.NoError(t, n.start()) require.NoError(t, n.start())
t.Cleanup(n.stop) t.Cleanup(n.stop)
const amount = btcutil.SatoshiPerBitcoin f := func(overpaymentRand uint64) bool {
const amount = btcutil.SatoshiPerBitcoin / 100
overpayment := lnwire.MilliSatoshi(
overpaymentRand%(amount-1) + 1,
)
htlcAmt, htlcExpiry, hops := generateHops(amount, htlcAmt, htlcExpiry, hops := generateHops(amount,
testStartingHeight, n.firstBobChannelLink) testStartingHeight, n.firstBobChannelLink)
@@ -901,7 +903,7 @@ func TestExitNodeHTLCExceedsAmountPayload(t *testing.T) {
return err == nil return err == nil
} }
err := quick.Check(f, &quick.Config{MaxCount: 20}) err = quick.Check(f, nil)
require.NoError(t, err, "payment should have succeeded but didn't") require.NoError(t, err, "payment should have succeeded but didn't")
} }