lnwallet/test: add new tx publish sub-test for policy weight limits

This commit is contained in:
Olaoluwa Osuntokun 2022-05-26 15:49:36 -07:00 committed by yyforyongyu
parent a616fa3fb7
commit 11bafe84ff
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

View File

@ -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,