From 11bafe84ff624e0d7a2d56ef00be89567a7d4cbd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 26 May 2022 15:49:36 -0700 Subject: [PATCH] lnwallet/test: add new tx publish sub-test for policy weight limits --- lnwallet/test/test_interface.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lnwallet/test/test_interface.go b/lnwallet/test/test_interface.go index ad01a9ebb..bc2dbcf1b 100644 --- a/lnwallet/test/test_interface.go +++ b/lnwallet/test/test_interface.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcjson" "github.com/btcsuite/btcd/btcutil" @@ -1886,6 +1887,31 @@ func testPublishTransaction(r *rpctest.Harness, require.ErrorIs(t, err, lnwallet.ErrDoubleSpend) } }) + + t.Run("test_tx_size_limit", func(t *testing.T) { + // In this test, we'll try to create a massive transaction that + // can't be mined as dictacted by widely deployed transaction + // policy. + // + // To do this, we'll take out of the prior transactions, and + // add a bunch of outputs, putting it over the max weight + // limit. + testTx := tx3.Copy() + for i := 0; i < blockchain.MaxOutputsPerBlock; i++ { + testTx.AddTxOut(&wire.TxOut{ + Value: tx3.TxOut[0].Value, + PkScript: tx3.TxOut[0].PkScript, + }) + } + + // Now broadcast the transaction, we should get an error that + // the weight is too large. + // + // TODO(roasbeef): we can't use Unwrap() here as TxRuleError + // doesn't define it + err := alice.PublishTransaction(testTx, labels.External) + require.Contains(t, err.Error(), "bad-txns-oversize") + }) } func testSignOutputUsingTweaks(r *rpctest.Harness,