lnwallet: temporarily ensure TestStateUpdatePersistence doesn't make dust
Note that this commit is temporary, and should be reverted once #231 is merged. The reason we need to do this for now, is that we don’t properly track the exact state of the remote party’s commitment. In this test case, the resulting HTLC’s added are dust to one party, but non-dust to another. So upon restart, the states (balance wise) has diverged.
This commit is contained in:
parent
8c6a83a67d
commit
5240953de0
@ -1195,6 +1195,7 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
}
|
||||
|
||||
const numHtlcs = 4
|
||||
const htlcAmt = 20000
|
||||
|
||||
// Alice adds 3 HTLCs to the update log, while Bob adds a single HTLC.
|
||||
var alicePreimage [32]byte
|
||||
@ -1205,7 +1206,7 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
rHash := sha256.Sum256(alicePreimage[:])
|
||||
h := &lnwire.UpdateAddHTLC{
|
||||
PaymentHash: rHash,
|
||||
Amount: btcutil.Amount(5000),
|
||||
Amount: htlcAmt,
|
||||
Expiry: uint32(10),
|
||||
}
|
||||
|
||||
@ -1219,7 +1220,7 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
rHash := sha256.Sum256(bobPreimage[:])
|
||||
bobh := &lnwire.UpdateAddHTLC{
|
||||
PaymentHash: rHash,
|
||||
Amount: btcutil.Amount(5000),
|
||||
Amount: htlcAmt,
|
||||
Expiry: uint32(10),
|
||||
}
|
||||
if _, err := bobChannel.AddHTLC(bobh); err != nil {
|
||||
@ -1287,9 +1288,6 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create new channel: %v", err)
|
||||
}
|
||||
if err := initRevocationWindows(aliceChannelNew, bobChannelNew, 3); err != nil {
|
||||
t.Fatalf("unable to init revocation windows: %v", err)
|
||||
}
|
||||
|
||||
// The state update logs of the new channels and the old channels
|
||||
// should now be identical other than the height the HTLCs were added.
|
||||
@ -1396,7 +1394,7 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
}
|
||||
|
||||
// Now settle all the HTLCs, then force a state update. The state
|
||||
// update should suceed as both sides have identical.
|
||||
// update should succeed as both sides have identical.
|
||||
for i := 0; i < 3; i++ {
|
||||
settleIndex, err := bobChannelNew.SettleHTLC(alicePreimage)
|
||||
if err != nil {
|
||||
@ -1429,21 +1427,21 @@ func TestStateUpdatePersistence(t *testing.T) {
|
||||
|
||||
// The amounts transferred should been updated as per the amounts in
|
||||
// the HTLCs
|
||||
if aliceChannelNew.channelState.TotalSatoshisSent != 15000 {
|
||||
if aliceChannelNew.channelState.TotalSatoshisSent != htlcAmt*3 {
|
||||
t.Fatalf("expected %v alice satoshis sent, got %v",
|
||||
15000, aliceChannelNew.channelState.TotalSatoshisSent)
|
||||
htlcAmt*3, aliceChannelNew.channelState.TotalSatoshisSent)
|
||||
}
|
||||
if aliceChannelNew.channelState.TotalSatoshisReceived != 5000 {
|
||||
if aliceChannelNew.channelState.TotalSatoshisReceived != htlcAmt {
|
||||
t.Fatalf("expected %v alice satoshis received, got %v",
|
||||
5000, aliceChannelNew.channelState.TotalSatoshisReceived)
|
||||
htlcAmt, aliceChannelNew.channelState.TotalSatoshisReceived)
|
||||
}
|
||||
if bobChannelNew.channelState.TotalSatoshisSent != 5000 {
|
||||
if bobChannelNew.channelState.TotalSatoshisSent != htlcAmt {
|
||||
t.Fatalf("expected %v bob satoshis sent, got %v",
|
||||
5000, bobChannel.channelState.TotalSatoshisSent)
|
||||
htlcAmt, bobChannel.channelState.TotalSatoshisSent)
|
||||
}
|
||||
if bobChannelNew.channelState.TotalSatoshisReceived != 15000 {
|
||||
if bobChannelNew.channelState.TotalSatoshisReceived != htlcAmt*3 {
|
||||
t.Fatalf("expected %v bob satoshis sent, got %v",
|
||||
15000, bobChannel.channelState.TotalSatoshisSent)
|
||||
htlcAmt*3, bobChannel.channelState.TotalSatoshisSent)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user