Skip to content

Commit

Permalink
fw: fix pit test
Browse files Browse the repository at this point in the history
PIT entries once removed cannot be reused, even for removing. Since
remove is only called from the priority queue expiration function,
this should not be a problem.
  • Loading branch information
pulsejet committed Dec 25, 2024
1 parent a0bcdf2 commit e370916
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions fw/table/pit-cs-tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (p *PitCsTree) InsertInterest(interest ndn.Interest, hint enc.Name, inFace

// RemoveInterest removes the specified PIT entry, returning true if the entry
// was removed and false if was not (because it does not exist).
// The pitEntry should NEVER be used again after this call.
func (p *PitCsTree) RemoveInterest(pitEntry PitEntry) bool {
e := pitEntry.(*nameTreePitEntry) // No error check needed because PitCsTree always uses nameTreePitEntry
for i, entry := range e.node.pitEntries {
Expand Down
6 changes: 2 additions & 4 deletions fw/table/pit-cs-tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,12 @@ func TestRemoveInterest(t *testing.T) {
assert.True(t, removedInterest)
assert.Equal(t, pitCS.PitSize(), 0)

// Remove a nonexistent pit entry
// Remove a new pit entry
name2, _ := enc.NameFromStr("/interest2")
interest2 := makeInterest(name2)
pitEntry2, _ := pitCS.InsertInterest(interest2, hint, inFace)

removedInterest = pitCS.RemoveInterest(pitEntry)
assert.False(t, removedInterest)
assert.Equal(t, pitCS.PitSize(), 1)

removedInterest = pitCS.RemoveInterest(pitEntry2)
assert.True(t, removedInterest)
assert.Equal(t, pitCS.PitSize(), 0)
Expand Down

0 comments on commit e370916

Please sign in to comment.