lnwallet tests: update tests to new FeeEstimator and fee rate types
This commit is contained in:
parent
1f839d2526
commit
d7834ca4eb
@ -231,11 +231,11 @@ func createTestChannels(revocationWindow int) (*LightningChannel,
|
||||
}
|
||||
|
||||
estimator := &StaticFeeEstimator{24}
|
||||
feePerWeight, err := estimator.EstimateFeePerWeight(1)
|
||||
feePerVSize, err := estimator.EstimateFeePerVSize(1)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
feePerKw := feePerWeight * 1000
|
||||
feePerKw := feePerVSize.FeePerKWeight()
|
||||
commitFee := calcStaticFee(0)
|
||||
|
||||
aliceCommit := channeldb.ChannelCommitment{
|
||||
@ -243,7 +243,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel,
|
||||
LocalBalance: lnwire.NewMSatFromSatoshis(channelBal - commitFee),
|
||||
RemoteBalance: lnwire.NewMSatFromSatoshis(channelBal),
|
||||
CommitFee: commitFee,
|
||||
FeePerKw: feePerKw,
|
||||
FeePerKw: btcutil.Amount(feePerKw),
|
||||
CommitTx: aliceCommitTx,
|
||||
CommitSig: bytes.Repeat([]byte{1}, 71),
|
||||
}
|
||||
@ -252,7 +252,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel,
|
||||
LocalBalance: lnwire.NewMSatFromSatoshis(channelBal),
|
||||
RemoteBalance: lnwire.NewMSatFromSatoshis(channelBal - commitFee),
|
||||
CommitFee: commitFee,
|
||||
FeePerKw: feePerKw,
|
||||
FeePerKw: btcutil.Amount(feePerKw),
|
||||
CommitTx: bobCommitTx,
|
||||
CommitSig: bytes.Repeat([]byte{1}, 71),
|
||||
}
|
||||
@ -747,12 +747,12 @@ func TestCooperativeChannelClosure(t *testing.T) {
|
||||
aliceDeliveryScript := bobsPrivKey[:]
|
||||
bobDeliveryScript := testHdSeed[:]
|
||||
|
||||
aliceFeeRate := uint64(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
bobFeeRate := uint64(bobChannel.channelState.LocalCommitment.FeePerKw)
|
||||
aliceFeeRate := SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
bobFeeRate := SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw)
|
||||
|
||||
// We'll store with both Alice and Bob creating a new close proposal
|
||||
// with the same fee.
|
||||
aliceFee := btcutil.Amount(aliceChannel.CalcFee(aliceFeeRate))
|
||||
aliceFee := aliceChannel.CalcFee(aliceFeeRate)
|
||||
aliceSig, _, _, err := aliceChannel.CreateCloseProposal(
|
||||
aliceFee, aliceDeliveryScript, bobDeliveryScript,
|
||||
)
|
||||
@ -761,7 +761,7 @@ func TestCooperativeChannelClosure(t *testing.T) {
|
||||
}
|
||||
aliceCloseSig := append(aliceSig, byte(txscript.SigHashAll))
|
||||
|
||||
bobFee := btcutil.Amount(bobChannel.CalcFee(bobFeeRate))
|
||||
bobFee := bobChannel.CalcFee(bobFeeRate)
|
||||
bobSig, _, _, err := bobChannel.CreateCloseProposal(
|
||||
bobFee, bobDeliveryScript, aliceDeliveryScript,
|
||||
)
|
||||
@ -889,8 +889,8 @@ func TestForceClose(t *testing.T) {
|
||||
// Factoring in the fee rate, Alice's amount should properly reflect
|
||||
// that we've added two additional HTLC to the commitment transaction.
|
||||
totalCommitWeight := CommitWeight + (HtlcWeight * 2)
|
||||
feePerKw := aliceChannel.channelState.LocalCommitment.FeePerKw
|
||||
commitFee := btcutil.Amount((int64(feePerKw) * totalCommitWeight) / 1000)
|
||||
feePerKw := SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
commitFee := feePerKw.FeeForWeight(totalCommitWeight)
|
||||
expectedAmount := (aliceChannel.Capacity / 2) - htlcAmount.ToSatoshis() - commitFee
|
||||
if aliceCommitResolution.SelfOutputSignDesc.Output.Value != int64(expectedAmount) {
|
||||
t.Fatalf("alice incorrect output value in SelfOutputSignDesc, "+
|
||||
@ -1297,8 +1297,8 @@ func TestHTLCDustLimit(t *testing.T) {
|
||||
|
||||
// The amount of the HTLC should be above Alice's dust limit and below
|
||||
// Bob's dust limit.
|
||||
htlcSat := (btcutil.Amount(500) +
|
||||
htlcTimeoutFee(aliceChannel.channelState.LocalCommitment.FeePerKw))
|
||||
htlcSat := (btcutil.Amount(500) + htlcTimeoutFee(
|
||||
SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw)))
|
||||
htlcAmount := lnwire.NewMSatFromSatoshis(htlcSat)
|
||||
|
||||
htlc, preimage := createHTLC(0, htlcAmount)
|
||||
@ -1392,7 +1392,7 @@ func TestChannelBalanceDustLimit(t *testing.T) {
|
||||
aliceBalance := aliceChannel.channelState.LocalCommitment.LocalBalance.ToSatoshis()
|
||||
htlcSat := aliceBalance - defaultFee
|
||||
htlcSat += htlcSuccessFee(
|
||||
aliceChannel.channelState.LocalCommitment.FeePerKw,
|
||||
SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw),
|
||||
)
|
||||
|
||||
htlcAmount := lnwire.NewMSatFromSatoshis(htlcSat)
|
||||
@ -1853,8 +1853,8 @@ func TestCooperativeCloseDustAdherence(t *testing.T) {
|
||||
}
|
||||
defer cleanUp()
|
||||
|
||||
aliceFeeRate := uint64(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
bobFeeRate := uint64(bobChannel.channelState.LocalCommitment.FeePerKw)
|
||||
aliceFeeRate := SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
bobFeeRate := SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw)
|
||||
|
||||
setDustLimit := func(dustVal btcutil.Amount) {
|
||||
aliceChannel.channelState.LocalChanCfg.DustLimit = dustVal
|
||||
@ -2069,7 +2069,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
||||
}
|
||||
|
||||
// Simulate Alice sending update fee message to bob.
|
||||
fee := btcutil.Amount(111)
|
||||
fee := SatPerKWeight(111)
|
||||
aliceChannel.UpdateFee(fee)
|
||||
bobChannel.ReceiveUpdateFee(fee)
|
||||
|
||||
@ -2089,7 +2089,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
||||
t.Fatalf("bob unable to process alice's new commitment: %v", err)
|
||||
}
|
||||
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw == fee {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) == fee {
|
||||
t.Fatalf("bob's feePerKw was unexpectedly locked in")
|
||||
}
|
||||
|
||||
@ -2100,7 +2100,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
||||
t.Fatalf("unable to generate bob revocation: %v", err)
|
||||
}
|
||||
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw != fee {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) != fee {
|
||||
t.Fatalf("bob's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
@ -2125,7 +2125,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
||||
t.Fatalf("alice unable to process bob's new commitment: %v", err)
|
||||
}
|
||||
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw == fee {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) == fee {
|
||||
t.Fatalf("alice's feePerKw was unexpectedly locked in")
|
||||
}
|
||||
|
||||
@ -2136,7 +2136,7 @@ func TestUpdateFeeSenderCommits(t *testing.T) {
|
||||
t.Fatalf("unable to revoke alice channel: %v", err)
|
||||
}
|
||||
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw != fee {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) != fee {
|
||||
t.Fatalf("alice's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
@ -2181,7 +2181,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
||||
}
|
||||
|
||||
// Simulate Alice sending update fee message to bob
|
||||
fee := btcutil.Amount(111)
|
||||
fee := SatPerKWeight(111)
|
||||
aliceChannel.UpdateFee(fee)
|
||||
bobChannel.ReceiveUpdateFee(fee)
|
||||
|
||||
@ -2228,7 +2228,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
||||
t.Fatalf("alice unable to process bob's new commitment: %v", err)
|
||||
}
|
||||
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw == fee {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) == fee {
|
||||
t.Fatalf("bob's feePerKw was unexpectedly locked in")
|
||||
}
|
||||
|
||||
@ -2240,7 +2240,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
||||
t.Fatalf("unable to revoke alice channel: %v", err)
|
||||
}
|
||||
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw != fee {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) != fee {
|
||||
t.Fatalf("bob's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
@ -2264,7 +2264,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
||||
t.Fatalf("alice unable to process bob's new commitment: %v", err)
|
||||
}
|
||||
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw == fee {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) == fee {
|
||||
t.Fatalf("alice's feePerKw was unexpectedly locked in")
|
||||
}
|
||||
|
||||
@ -2275,7 +2275,7 @@ func TestUpdateFeeReceiverCommits(t *testing.T) {
|
||||
t.Fatalf("unable to generate bob revocation: %v", err)
|
||||
}
|
||||
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw != fee {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) != fee {
|
||||
t.Fatalf("Alice's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
@ -2302,7 +2302,7 @@ func TestUpdateFeeReceiverSendsUpdate(t *testing.T) {
|
||||
|
||||
// Since Alice is the channel initiator, she should fail when receiving
|
||||
// fee update
|
||||
fee := btcutil.Amount(111)
|
||||
fee := SatPerKWeight(111)
|
||||
err = aliceChannel.ReceiveUpdateFee(fee)
|
||||
if err == nil {
|
||||
t.Fatalf("expected alice to fail receiving fee update")
|
||||
@ -2330,9 +2330,9 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
||||
defer cleanUp()
|
||||
|
||||
// Simulate Alice sending update fee message to bob.
|
||||
fee1 := btcutil.Amount(111)
|
||||
fee2 := btcutil.Amount(222)
|
||||
fee := btcutil.Amount(333)
|
||||
fee1 := SatPerKWeight(111)
|
||||
fee2 := SatPerKWeight(222)
|
||||
fee := SatPerKWeight(333)
|
||||
aliceChannel.UpdateFee(fee1)
|
||||
aliceChannel.UpdateFee(fee2)
|
||||
aliceChannel.UpdateFee(fee)
|
||||
@ -2357,15 +2357,15 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
||||
t.Fatalf("bob unable to process alice's new commitment: %v", err)
|
||||
}
|
||||
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw == fee {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) == fee {
|
||||
t.Fatalf("bob's feePerKw was unexpectedly locked in")
|
||||
}
|
||||
|
||||
// Alice sending more fee updates now should not mess up the old fee
|
||||
// they both committed to.
|
||||
fee3 := btcutil.Amount(444)
|
||||
fee4 := btcutil.Amount(555)
|
||||
fee5 := btcutil.Amount(666)
|
||||
fee3 := SatPerKWeight(444)
|
||||
fee4 := SatPerKWeight(555)
|
||||
fee5 := SatPerKWeight(666)
|
||||
aliceChannel.UpdateFee(fee3)
|
||||
aliceChannel.UpdateFee(fee4)
|
||||
aliceChannel.UpdateFee(fee5)
|
||||
@ -2380,7 +2380,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
||||
t.Fatalf("unable to generate bob revocation: %v", err)
|
||||
}
|
||||
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw != fee {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) != fee {
|
||||
t.Fatalf("bob's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
@ -2404,7 +2404,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
||||
t.Fatalf("alice unable to process bob's new commitment: %v", err)
|
||||
}
|
||||
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw == fee {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) == fee {
|
||||
t.Fatalf("alice's feePerKw was unexpectedly locked in")
|
||||
}
|
||||
|
||||
@ -2415,7 +2415,7 @@ func TestUpdateFeeMultipleUpdates(t *testing.T) {
|
||||
t.Fatalf("unable to revoke alice channel: %v", err)
|
||||
}
|
||||
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw != fee {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) != fee {
|
||||
t.Fatalf("alice's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
@ -3498,7 +3498,7 @@ func TestFeeUpdateRejectInsaneFee(t *testing.T) {
|
||||
|
||||
// Next, we'll try to add a fee rate to Alice which is 1,000,000x her
|
||||
// starting fee rate.
|
||||
startingFeeRate := aliceChannel.channelState.LocalCommitment.FeePerKw
|
||||
startingFeeRate := SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
newFeeRate := startingFeeRate * 1000000
|
||||
|
||||
// Both Alice and Bob should reject this new fee rate as it it far too
|
||||
@ -3524,7 +3524,7 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
||||
|
||||
// First, we'll fetch the current fee rate present within the
|
||||
// commitment transactions.
|
||||
startingFeeRate := aliceChannel.channelState.LocalCommitment.FeePerKw
|
||||
startingFeeRate := SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw)
|
||||
|
||||
// Next, we'll start a commitment update, with Alice sending a new
|
||||
// update to double the fee rate of the commitment.
|
||||
@ -3664,10 +3664,10 @@ func TestChannelRetransmissionFeeUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
// Both parties should now have the latest fee rate locked-in.
|
||||
if aliceChannel.channelState.LocalCommitment.FeePerKw != newFeeRate {
|
||||
if SatPerKWeight(aliceChannel.channelState.LocalCommitment.FeePerKw) != newFeeRate {
|
||||
t.Fatalf("alice's feePerKw was not locked in")
|
||||
}
|
||||
if bobChannel.channelState.LocalCommitment.FeePerKw != newFeeRate {
|
||||
if SatPerKWeight(bobChannel.channelState.LocalCommitment.FeePerKw) != newFeeRate {
|
||||
t.Fatalf("bob's feePerKw was not locked in")
|
||||
}
|
||||
|
||||
|
@ -283,13 +283,13 @@ 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.
|
||||
feePerWeight, err := alice.Cfg.FeeEstimator.EstimateFeePerWeight(1)
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feePerWeight * 1000
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
aliceChanReservation, err := alice.InitChannelReservation(
|
||||
fundingAmount*2, fundingAmount, 0, feePerKw, feePerKw,
|
||||
fundingAmount*2, fundingAmount, 0, feePerKw, feeRate,
|
||||
bobPub, bobAddr, chainHash, lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation: %v", err)
|
||||
@ -313,7 +313,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
||||
// receives' Alice's contribution, and consumes that so we can continue
|
||||
// the funding process.
|
||||
bobChanReservation, err := bob.InitChannelReservation(fundingAmount*2,
|
||||
fundingAmount, 0, feePerKw, feePerKw, alicePub, aliceAddr,
|
||||
fundingAmount, 0, feePerKw, feeRate, alicePub, aliceAddr,
|
||||
chainHash, lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("bob unable to init channel reservation: %v", err)
|
||||
@ -449,13 +449,13 @@ func testFundingTransactionLockedOutputs(miner *rpctest.Harness,
|
||||
|
||||
// Create a single channel asking for 16 BTC total.
|
||||
fundingAmount := btcutil.Amount(8 * 1e8)
|
||||
feePerWeight, err := alice.Cfg.FeeEstimator.EstimateFeePerWeight(1)
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feePerWeight * 1000
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
_, err = alice.InitChannelReservation(fundingAmount,
|
||||
fundingAmount, 0, feePerKw, feePerKw, bobPub, bobAddr, chainHash,
|
||||
fundingAmount, 0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
@ -467,7 +467,8 @@ func testFundingTransactionLockedOutputs(miner *rpctest.Harness,
|
||||
// that aren't locked, so this should fail.
|
||||
amt := btcutil.Amount(900 * 1e8)
|
||||
failedReservation, err := alice.InitChannelReservation(amt, amt, 0,
|
||||
feePerKw, feePerKw, bobPub, bobAddr, chainHash, lnwire.FFAnnounceChannel)
|
||||
feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
if err == nil {
|
||||
t.Fatalf("not error returned, should fail on coin selection")
|
||||
}
|
||||
@ -482,16 +483,16 @@ func testFundingTransactionLockedOutputs(miner *rpctest.Harness,
|
||||
func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
alice, _ *lnwallet.LightningWallet, t *testing.T) {
|
||||
|
||||
feePerWeight, err := alice.Cfg.FeeEstimator.EstimateFeePerWeight(1)
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feePerWeight * 1000
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
|
||||
// Create a reservation for 44 BTC.
|
||||
fundingAmount := btcutil.Amount(44 * 1e8)
|
||||
chanReservation, err := alice.InitChannelReservation(fundingAmount,
|
||||
fundingAmount, 0, feePerKw, feePerKw, bobPub, bobAddr, chainHash,
|
||||
fundingAmount, 0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation: %v", err)
|
||||
@ -499,7 +500,7 @@ func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
|
||||
// Attempt to create another channel with 44 BTC, this should fail.
|
||||
_, err = alice.InitChannelReservation(fundingAmount,
|
||||
fundingAmount, 0, feePerKw, feePerKw, bobPub, bobAddr, chainHash,
|
||||
fundingAmount, 0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if _, ok := err.(*lnwallet.ErrInsufficientFunds); !ok {
|
||||
@ -530,8 +531,9 @@ func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
// attempting coin selection.
|
||||
|
||||
// Request to fund a new channel should now succeed.
|
||||
_, err = alice.InitChannelReservation(fundingAmount, fundingAmount, 0,
|
||||
feePerKw, feePerKw, bobPub, bobAddr, chainHash, lnwire.FFAnnounceChannel)
|
||||
_, err = alice.InitChannelReservation(fundingAmount, fundingAmount,
|
||||
0, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to initialize funding reservation: %v", err)
|
||||
}
|
||||
@ -540,14 +542,15 @@ func testFundingCancellationNotEnoughFunds(miner *rpctest.Harness,
|
||||
func testCancelNonExistentReservation(miner *rpctest.Harness,
|
||||
alice, _ *lnwallet.LightningWallet, t *testing.T) {
|
||||
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerWeight(1)
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(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, alice, 22, 10, &testHdSeed, lnwire.FFAnnounceChannel,
|
||||
10000, 10000, feeRate.FeePerKWeight(), alice,
|
||||
22, 10, &testHdSeed, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create res: %v", err)
|
||||
@ -567,9 +570,10 @@ func testReservationInitiatorBalanceBelowDustCancel(miner *rpctest.Harness,
|
||||
// rate. This should push our balance into the negative and result in a
|
||||
// failure to create the reservation.
|
||||
fundingAmount := btcutil.Amount(4 * 1e8)
|
||||
feePerKw := btcutil.Amount(btcutil.SatoshiPerBitcoin * 10)
|
||||
feePerVSize := lnwallet.SatPerVByte(btcutil.SatoshiPerBitcoin * 4 / 100)
|
||||
feePerKw := feePerVSize.FeePerKWeight()
|
||||
_, err := alice.InitChannelReservation(
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerKw, bobPub,
|
||||
fundingAmount, fundingAmount, 0, feePerKw, feePerVSize, bobPub,
|
||||
bobAddr, chainHash, lnwire.FFAnnounceChannel,
|
||||
)
|
||||
switch {
|
||||
@ -636,13 +640,13 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
||||
// towards Bob's side.
|
||||
fundingAmt := btcutil.Amount(4 * 1e8)
|
||||
pushAmt := lnwire.NewMSatFromSatoshis(btcutil.SatoshiPerBitcoin)
|
||||
feePerWeight, err := alice.Cfg.FeeEstimator.EstimateFeePerWeight(1)
|
||||
feeRate, err := alice.Cfg.FeeEstimator.EstimateFeePerVSize(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
feePerKw := feePerWeight * 1000
|
||||
feePerKw := feeRate.FeePerKWeight()
|
||||
aliceChanReservation, err := alice.InitChannelReservation(fundingAmt,
|
||||
fundingAmt, pushAmt, feePerKw, feePerKw, bobPub, bobAddr, chainHash,
|
||||
fundingAmt, pushAmt, feePerKw, feeRate, bobPub, bobAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to init channel reservation: %v", err)
|
||||
@ -666,7 +670,7 @@ 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, feePerKw, alicePub, aliceAddr, chainHash,
|
||||
pushAmt, feePerKw, feeRate, alicePub, aliceAddr, chainHash,
|
||||
lnwire.FFAnnounceChannel)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create bob reservation: %v", err)
|
||||
|
@ -787,7 +787,7 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
||||
height: test.commitment.CommitHeight,
|
||||
ourBalance: test.commitment.LocalBalance,
|
||||
theirBalance: test.commitment.RemoteBalance,
|
||||
feePerKw: test.commitment.FeePerKw,
|
||||
feePerKw: SatPerKWeight(test.commitment.FeePerKw),
|
||||
dustLimit: tc.dustLimit,
|
||||
isOurs: true,
|
||||
}
|
||||
@ -829,8 +829,8 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
||||
// Generate second-level HTLC transactions for HTLCs in
|
||||
// commitment tx.
|
||||
htlcResolutions, err := extractHtlcResolutions(
|
||||
test.commitment.FeePerKw, true, signer, htlcs, keys,
|
||||
channel.localChanCfg, channel.remoteChanCfg,
|
||||
SatPerKWeight(test.commitment.FeePerKw), true, signer,
|
||||
htlcs, keys, channel.localChanCfg, channel.remoteChanCfg,
|
||||
commitTx.TxHash(), pCache,
|
||||
)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user