multi: update to latest fee estimation interface
This commit is contained in:
21 files changed
+150
-204
No files matched your search
+53
-48
@@ -186,7 +186,7 @@ func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet,
|
||||
Value: int64(satoshiPerOutput),
|
||||
PkScript: script,
|
||||
}
|
||||
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
|
||||
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 2500); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ func createTestWallet(tempTestDir string, miningNode *rpctest.Harness,
|
||||
WalletController: wc,
|
||||
Signer: signer,
|
||||
ChainIO: bio,
|
||||
FeeEstimator: lnwallet.StaticFeeEstimator{FeeRate: 10},
|
||||
FeeEstimator: lnwallet.StaticFeeEstimator{FeePerKW: 2500},
|
||||
DefaultConstraints: channeldb.ChannelConstraints{
|
||||
DustLimit: 500,
|
||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin) * 100,
|
||||
@@ -290,14 +290,14 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
||||
|
||||
// Alice initiates a channel funded with 5 BTC for each side, so 10 BTC
|
||||
// total. She also generates 2 BTC in change.
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
feePerKw, err := alice.Cfg.FeeEstimator.EstimateFeePerKW(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
aliceChanReservation, err := alice.InitChannelReservation(
|
||||
fundingAmount*2, fundingAmount, 0, feePerKw, feeRate,
|
||||
bobPub, bobAddr, chainHash, lnwire.FFAnnounceChannel)
|
||||
fundingAmount*2, fundingAmount, 0, feePerKw, feePerKw, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation: %v", err)
|
||||
}
|
||||
@@ -325,9 +325,10 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
||||
// Bob does the same, generating his own contribution. He then also
|
||||
// receives' Alice's contribution, and consumes that so we can continue
|
||||
// the funding process.
|
||||
bobChanReservation, err := bob.InitChannelReservation(fundingAmount*2,
|
||||
fundingAmount, 0, feePerKw, feeRate, alicePub, aliceAddr,
|
||||
chainHash, lnwire.FFAnnounceChannel)
|
||||
bobChanReservation, err := bob.InitChannelReservation(
|
||||
fundingAmount*2, fundingAmount, 0, feePerKw, feePerKw, alicePub,
|
||||
aliceAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("bob unable to init channel reservation: %v", err)
|
||||
}
|
||||
@@ -471,14 +472,13 @@ func testFundingTransactionLockedOutputs(miner *rpctest.Harness,
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create amt: %v", err)
|
||||
}
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
feePerKw, err := alice.Cfg.FeeEstimator.EstimateFeePerKW(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
_, err = alice.InitChannelReservation(fundingAmount,
|
||||
fundingAmount, 0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel,
|
||||
_, err = alice.InitChannelReservation(
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerKw, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation 1: %v", err)
|
||||
@@ -491,9 +491,10 @@ func testFundingTransactionLockedOutputs(miner *rpctest.Harness,
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create amt: %v", err)
|
||||
}
|
||||
failedReservation, err := alice.InitChannelReservation(amt, amt, 0,
|
||||
feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
failedReservation, err := alice.InitChannelReservation(
|
||||
amt, amt, 0, feePerKw, feePerKw, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err == nil {
|
||||
t.Fatalf("not error returned, should fail on coin selection")
|
||||
}
|
||||
@@ -508,28 +509,28 @@ func testFundingTransactionLockedOutputs(miner *rpctest.Harness,
|
||||
func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
alice, _ *lnwallet.LightningWallet, t *testing.T) {
|
||||
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
feePerKw, err := alice.Cfg.FeeEstimator.EstimateFeePerKW(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
|
||||
// Create a reservation for 44 BTC.
|
||||
fundingAmount, err := btcutil.NewAmount(44)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create amt: %v", err)
|
||||
}
|
||||
chanReservation, err := alice.InitChannelReservation(fundingAmount,
|
||||
fundingAmount, 0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
chanReservation, err := alice.InitChannelReservation(
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerKw, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation: %v", err)
|
||||
}
|
||||
|
||||
// Attempt to create another channel with 44 BTC, this should fail.
|
||||
_, err = alice.InitChannelReservation(fundingAmount,
|
||||
fundingAmount, 0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel,
|
||||
_, err = alice.InitChannelReservation(
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerKw, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if _, ok := err.(*lnwallet.ErrInsufficientFunds); !ok {
|
||||
t.Fatalf("coin selection succeeded should have insufficient funds: %v",
|
||||
@@ -560,7 +561,7 @@ func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
|
||||
// Request to fund a new channel should now succeed.
|
||||
_, err = alice.InitChannelReservation(fundingAmount, fundingAmount,
|
||||
0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
0, feePerKw, feePerKw, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation: %v", err)
|
||||
@@ -570,15 +571,15 @@ func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
func testCancelNonExistentReservation(miner *rpctest.Harness,
|
||||
alice, _ *lnwallet.LightningWallet, t *testing.T) {
|
||||
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
feePerKw, err := alice.Cfg.FeeEstimator.EstimateFeePerKW(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
|
||||
// Create our own reservation, give it some ID.
|
||||
res, err := lnwallet.NewChannelReservation(
|
||||
10000, 10000, feeRate.FeePerKWeight(), alice,
|
||||
22, 10, &testHdSeed, lnwire.FFAnnounceChannel,
|
||||
10000, 10000, feePerKw, alice, 22, 10, &testHdSeed,
|
||||
lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create res: %v", err)
|
||||
@@ -597,14 +598,17 @@ func testReservationInitiatorBalanceBelowDustCancel(miner *rpctest.Harness,
|
||||
// We'll attempt to create a new reservation with an extremely high fee
|
||||
// rate. This should push our balance into the negative and result in a
|
||||
// failure to create the reservation.
|
||||
fundingAmount, err := btcutil.NewAmount(4)
|
||||
const numBTC = 4
|
||||
fundingAmount, err := btcutil.NewAmount(numBTC)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create amt: %v", err)
|
||||
}
|
||||
feePerVSize := lnwallet.SatPerVByte(btcutil.SatoshiPerBitcoin * 4 / 100)
|
||||
feePerKw := feePerVSize.FeePerKWeight()
|
||||
|
||||
feePerKw := lnwallet.SatPerKWeight(
|
||||
numBTC * numBTC * btcutil.SatoshiPerBitcoin,
|
||||
)
|
||||
_, err = alice.InitChannelReservation(
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerVSize, bobPub,
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerKw, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
switch {
|
||||
@@ -672,14 +676,14 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
||||
t.Fatalf("unable to create amt: %v", err)
|
||||
}
|
||||
pushAmt := lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin)
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
feePerKw, err := alice.Cfg.FeeEstimator.EstimateFeePerKW(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
aliceChanReservation, err := alice.InitChannelReservation(fundingAmt,
|
||||
fundingAmt, pushAmt, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
aliceChanReservation, err := alice.InitChannelReservation(
|
||||
fundingAmt, fundingAmt, pushAmt, feePerKw, feePerKw, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to init channel reservation: %v", err)
|
||||
}
|
||||
@@ -707,9 +711,10 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
||||
|
||||
// Next, Bob receives the initial request, generates a corresponding
|
||||
// reservation initiation, then consume Alice's contribution.
|
||||
bobChanReservation, err := bob.InitChannelReservation(fundingAmt, 0,
|
||||
pushAmt, feePerKw, feeRate, alicePub, aliceAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
bobChanReservation, err := bob.InitChannelReservation(
|
||||
fundingAmt, 0, pushAmt, feePerKw, feePerKw, alicePub, aliceAddr,
|
||||
chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create bob reservation: %v", err)
|
||||
}
|
||||
@@ -891,7 +896,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
Value: outputAmt,
|
||||
PkScript: script,
|
||||
}
|
||||
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
|
||||
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send coinbase: %v", err)
|
||||
}
|
||||
@@ -994,7 +999,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
t.Fatalf("unable to make output script: %v", err)
|
||||
}
|
||||
burnOutput := wire.NewTxOut(outputAmt, outputScript)
|
||||
burnTXID, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 10)
|
||||
burnTXID, err := alice.SendOutputs([]*wire.TxOut{burnOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create burn tx: %v", err)
|
||||
}
|
||||
@@ -1108,7 +1113,7 @@ func testTransactionSubscriptions(miner *rpctest.Harness,
|
||||
Value: outputAmt,
|
||||
PkScript: script,
|
||||
}
|
||||
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
|
||||
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send coinbase: %v", err)
|
||||
}
|
||||
@@ -1308,7 +1313,7 @@ func testPublishTransaction(r *rpctest.Harness,
|
||||
Value: btcutil.SatoshiPerBitcoin,
|
||||
PkScript: keyScript,
|
||||
}
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 10)
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create output: %v", err)
|
||||
}
|
||||
@@ -1553,7 +1558,7 @@ func testSignOutputUsingTweaks(r *rpctest.Harness,
|
||||
Value: btcutil.SatoshiPerBitcoin,
|
||||
PkScript: keyScript,
|
||||
}
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 10)
|
||||
txid, err := alice.SendOutputs([]*wire.TxOut{newOutput}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create output: %v", err)
|
||||
}
|
||||
@@ -1679,7 +1684,7 @@ func testReorgWalletBalance(r *rpctest.Harness, w *lnwallet.LightningWallet,
|
||||
Value: 1e8,
|
||||
PkScript: script,
|
||||
}
|
||||
txid, err := w.SendOutputs([]*wire.TxOut{output}, 10)
|
||||
txid, err := w.SendOutputs([]*wire.TxOut{output}, 2500)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send outputs: %v", err)
|
||||
}
|
||||
@@ -2073,7 +2078,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver,
|
||||
}
|
||||
|
||||
case "neutrino":
|
||||
feeEstimator = lnwallet.StaticFeeEstimator{FeeRate: 250}
|
||||
feeEstimator = lnwallet.StaticFeeEstimator{FeePerKW: 62500}
|
||||
|
||||
// Set some package-level variable to speed up
|
||||
// operation for tests.
|
||||
|
||||
Reference in new issue
Block a user