lnwallet: turn off RBF detection in test

This commit is contained in:
Oliver Gugger
2024-09-03 13:10:54 +02:00
parent 6aec5b00ad
commit 57e7b41510

View File

@@ -1758,97 +1758,88 @@ func testPublishTransaction(r *rpctest.Harness,
tx3, tx3Spend *wire.MsgTx tx3, tx3Spend *wire.MsgTx
) )
t.Run("rbf_tests", func(t *testing.T) { t.Run("rbf_tests", func(t *testing.T) {
for _, rbf := range []bool{false, true} { // Starting with bitcoind v28.0 and later, mempool full RBF is
// Now we'll try to double spend an output with a // turned on, so there's no way to _not_ signal RBF anymore.
// different transaction. Create a new tx and publish const rbf = true
// it. This is the output we'll try to double spend.
tx3 = newTx(t, r, keyDesc.PubKey, alice, false)
err := alice.PublishTransaction(tx3, labels.External)
require.NoError(t, err)
// Mine the transaction. // Now we'll try to double spend an output with a
err = mineAndAssert(r, tx3) // different transaction. Create a new tx and publish
require.NoError(t, err) // it. This is the output we'll try to double spend.
tx3 = newTx(t, r, keyDesc.PubKey, alice, false)
err := alice.PublishTransaction(tx3, labels.External)
require.NoError(t, err)
// Now we create a transaction that spends the output // Mine the transaction.
// from the tx just mined. err = mineAndAssert(r, tx3)
tx4, err := txFromOutput( require.NoError(t, err)
tx3, alice.Cfg.Signer, keyDesc.PubKey,
keyDesc.PubKey, txFee, rbf,
)
require.NoError(t, err)
// This should be accepted into the mempool. // Now we create a transaction that spends the output
err = alice.PublishTransaction(tx4, labels.External) // from the tx just mined.
require.NoError(t, err) tx4, err := txFromOutput(
tx3, alice.Cfg.Signer, keyDesc.PubKey,
keyDesc.PubKey, txFee, rbf,
)
require.NoError(t, err)
// Keep track of the last successfully published tx to // This should be accepted into the mempool.
// spend tx3. err = alice.PublishTransaction(tx4, labels.External)
tx3Spend = tx4 require.NoError(t, err)
txid4 := tx4.TxHash() // Keep track of the last successfully published tx to
err = waitForMempoolTx(r, &txid4) // spend tx3.
require.NoError(t, err, "tx not relayed to miner") tx3Spend = tx4
// Create a new key we'll pay to, to ensure we create a txid4 := tx4.TxHash()
// unique transaction. err = waitForMempoolTx(r, &txid4)
keyDesc2, err := alice.DeriveNextKey( require.NoError(t, err, "tx not relayed to miner")
keychain.KeyFamilyMultiSig,
)
require.NoError(t, err, "unable to obtain public key")
// Create a new transaction that spends the output from // Create a new key we'll pay to, to ensure we create a
// tx3, and that pays to a different address. // unique transaction.
tx5, err := txFromOutput( keyDesc2, err := alice.DeriveNextKey(
tx3, alice.Cfg.Signer, keyDesc.PubKey, keychain.KeyFamilyMultiSig,
keyDesc2.PubKey, txFee, rbf, )
) require.NoError(t, err, "unable to obtain public key")
require.NoError(t, err)
err = alice.PublishTransaction(tx5, labels.External) // Create a new transaction that spends the output from
// tx3, and that pays to a different address.
tx5, err := txFromOutput(
tx3, alice.Cfg.Signer, keyDesc.PubKey,
keyDesc2.PubKey, txFee, rbf,
)
require.NoError(t, err)
// If RBF is not enabled, we expect this to be rejected err = alice.PublishTransaction(tx5, labels.External)
// because it is a double spend.
expectedErr := lnwallet.ErrDoubleSpend
// If RBF is enabled, we expect it to be rejected // We expect it to be rejected/ because it doesn't pay enough
// because it doesn't pay enough fees. // fees.
if rbf { expectedErr := chain.ErrInsufficientFee
expectedErr = chain.ErrInsufficientFee
}
// Assert the expected error. // Assert the expected error.
require.ErrorIsf(t, err, expectedErr, "has rbf=%v", rbf) require.ErrorIsf(t, err, expectedErr, "has rbf=%v", rbf)
// Create another transaction that spends the same // Create another transaction that spends the same
// output, but has a higher fee. We expect also this tx // output, but has a higher fee. We expect also this tx
// to be rejected for non-RBF enabled transactions, // to be rejected for non-RBF enabled transactions,
// while it should succeed otherwise. // while it should succeed otherwise.
pubKey3, err := alice.DeriveNextKey( pubKey3, err := alice.DeriveNextKey(
keychain.KeyFamilyMultiSig, keychain.KeyFamilyMultiSig,
) )
require.NoError(t, err, "unable to obtain public key") require.NoError(t, err, "unable to obtain public key")
tx6, err := txFromOutput( tx6, err := txFromOutput(
tx3, alice.Cfg.Signer, keyDesc.PubKey, tx3, alice.Cfg.Signer, keyDesc.PubKey,
pubKey3.PubKey, 2*txFee, rbf, pubKey3.PubKey, 2*txFee, rbf,
) )
require.NoError(t, err) require.NoError(t, err)
// Expect rejection in non-RBF case. // Expect rejection in non-RBF case.
expErr := lnwallet.ErrDoubleSpend tx3Spend = tx6
if rbf { err = alice.PublishTransaction(tx6, labels.External)
// Expect success in rbf case. require.NoError(t, err)
expErr = nil
tx3Spend = tx6
}
err = alice.PublishTransaction(tx6, labels.External)
require.ErrorIs(t, err, expErr)
// Mine the tx spending tx3. // Mine the tx spending tx3.
err = mineAndAssert(r, tx3Spend) err = mineAndAssert(r, tx3Spend)
require.NoError(t, err) require.NoError(t, err)
}
}) })
t.Run("tx_double_spend", func(t *testing.T) { t.Run("tx_double_spend", func(t *testing.T) {
@@ -3071,9 +3062,9 @@ func testSingleFunderExternalFundingTx(miner *rpctest.Harness,
) )
} }
// TestInterfaces tests all registered interfaces with a unified set of tests // TestLightningWallet tests all registered interfaces with a unified set of
// which exercise each of the required methods found within the WalletController // tests which exercise each of the required methods found within the
// interface. // WalletController interface.
// //
// NOTE: In the future, when additional implementations of the WalletController // NOTE: In the future, when additional implementations of the WalletController
// interface have been implemented, in order to ensure the new concrete // interface have been implemented, in order to ensure the new concrete