Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Business logic error: PrefixDB unit tests #336

Open
ivansukach opened this issue Jul 9, 2023 · 1 comment
Open

Business logic error: PrefixDB unit tests #336

ivansukach opened this issue Jul 9, 2023 · 1 comment

Comments

@ivansukach
Copy link

ivansukach commented Jul 9, 2023

https://github.com/tendermint/tm-db/blob/master/prefixdb_test.go#L120

For each iteration you are going through values [0; len(mine)) for key := range mine {
and allocate slice of 4 bytes bs := make([]byte, 4)
Then you splitting into 4 bytes golang runes in reverse order binary.LittleEndian.PutUint32(bs, uint32(key))
Finally
if err := db.Delete(bs); err != nil {
t.Errorf("Delete %q: %v", key, err)
}

You try to delete element by the index of rune in the key pattern in little-endian order.

@ivansukach
Copy link
Author

Solution:
// Delete all the keys we inserted.
for k := 1; k <= numKeys; k++ {
key := taskKey(i, k) // say, "task--key-"
if err := db.Delete(key); err != nil {
t.Errorf("Delete %q: %v", key, err)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant