watchtower/wtdb+wtserver: allow retransmission of last update
This commit is contained in:
parent
81497eceaf
commit
8b0cc487f0
@ -82,7 +82,7 @@ func (s *SessionInfo) AcceptUpdateSequence(seqNum, lastApplied uint16) error {
|
|||||||
return ErrSessionConsumed
|
return ErrSessionConsumed
|
||||||
|
|
||||||
// Client update does not match our expected next seqnum.
|
// Client update does not match our expected next seqnum.
|
||||||
case seqNum != s.LastApplied+1:
|
case seqNum != s.LastApplied && seqNum != s.LastApplied+1:
|
||||||
return ErrUpdateOutOfOrder
|
return ErrUpdateOutOfOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,8 +418,8 @@ var stateUpdateTests = []stateUpdateTestCase{
|
|||||||
{Code: wtwire.CodeOK, LastApplied: 4},
|
{Code: wtwire.CodeOK, LastApplied: 4},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// Valid update sequence with disconnection, ensure resumes resume.
|
// Valid update sequence with disconnection, resume next update. Client
|
||||||
// Client doesn't echo last applied until last message.
|
// doesn't echo last applied until last message.
|
||||||
{
|
{
|
||||||
name: "resume after disconnect lagging lastapplied",
|
name: "resume after disconnect lagging lastapplied",
|
||||||
initMsg: wtwire.NewInitMessage(
|
initMsg: wtwire.NewInitMessage(
|
||||||
@ -448,6 +448,38 @@ var stateUpdateTests = []stateUpdateTestCase{
|
|||||||
{Code: wtwire.CodeOK, LastApplied: 4},
|
{Code: wtwire.CodeOK, LastApplied: 4},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// Valid update sequence with disconnection, resume last update. Client
|
||||||
|
// doesn't echo last applied until last message.
|
||||||
|
{
|
||||||
|
name: "resume after disconnect lagging lastapplied",
|
||||||
|
initMsg: wtwire.NewInitMessage(
|
||||||
|
lnwire.NewRawFeatureVector(),
|
||||||
|
testnetChainHash,
|
||||||
|
),
|
||||||
|
createMsg: &wtwire.CreateSession{
|
||||||
|
BlobType: blob.TypeDefault,
|
||||||
|
MaxUpdates: 4,
|
||||||
|
RewardBase: 0,
|
||||||
|
RewardRate: 0,
|
||||||
|
SweepFeeRate: 1,
|
||||||
|
},
|
||||||
|
updates: []*wtwire.StateUpdate{
|
||||||
|
{SeqNum: 1, LastApplied: 0},
|
||||||
|
{SeqNum: 2, LastApplied: 0},
|
||||||
|
nil, // Wait for read timeout to drop conn, then reconnect.
|
||||||
|
{SeqNum: 2, LastApplied: 0},
|
||||||
|
{SeqNum: 3, LastApplied: 0},
|
||||||
|
{SeqNum: 4, LastApplied: 3},
|
||||||
|
},
|
||||||
|
replies: []*wtwire.StateUpdateReply{
|
||||||
|
{Code: wtwire.CodeOK, LastApplied: 1},
|
||||||
|
{Code: wtwire.CodeOK, LastApplied: 2},
|
||||||
|
nil,
|
||||||
|
{Code: wtwire.CodeOK, LastApplied: 2},
|
||||||
|
{Code: wtwire.CodeOK, LastApplied: 3},
|
||||||
|
{Code: wtwire.CodeOK, LastApplied: 4},
|
||||||
|
},
|
||||||
|
},
|
||||||
// Send update with sequence number that exceeds MaxUpdates.
|
// Send update with sequence number that exceeds MaxUpdates.
|
||||||
{
|
{
|
||||||
name: "seqnum exceed maxupdates",
|
name: "seqnum exceed maxupdates",
|
||||||
|
Loading…
Reference in New Issue
Block a user