-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(stf/branch/memiter): Fix Iter validity (#21556)
- Loading branch information
1 parent
b92c173
commit b1bf488
Showing
2 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package branch | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_memIterator(t *testing.T) { | ||
t.Run("iter is invalid after close", func(t *testing.T) { | ||
cs := newChangeSet() | ||
for i := byte(0); i < 32; i++ { | ||
cs.set([]byte{0, i}, []byte{i}) | ||
} | ||
|
||
it, err := cs.iterator(nil, nil) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
err = it.Close() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if it.Valid() { | ||
t.Fatal("iterator must be invalid") | ||
} | ||
}) | ||
} |