forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v0.44.x' of https://github.com/cosmos/cosmos-sdk …
…into release/v0.44.x
- Loading branch information
Showing
15 changed files
with
231 additions
and
43 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
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
Binary file not shown.
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
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
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,44 @@ | ||
package cachekv_test | ||
|
||
import "crypto/rand" | ||
|
||
func randSlice(sliceSize int) []byte { | ||
bz := make([]byte, sliceSize) | ||
_, _ = rand.Read(bz) | ||
return bz | ||
} | ||
|
||
func incrementByteSlice(bz []byte) { | ||
for index := len(bz) - 1; index >= 0; index-- { | ||
if bz[index] < 255 { | ||
bz[index]++ | ||
break | ||
} else { | ||
bz[index] = 0 | ||
} | ||
} | ||
} | ||
|
||
// Generate many keys starting at startKey, and are in sequential order | ||
func generateSequentialKeys(startKey []byte, numKeys int) [][]byte { | ||
toReturn := make([][]byte, 0, numKeys) | ||
cur := make([]byte, len(startKey)) | ||
copy(cur, startKey) | ||
for i := 0; i < numKeys; i++ { | ||
newKey := make([]byte, len(startKey)) | ||
copy(newKey, cur) | ||
toReturn = append(toReturn, newKey) | ||
incrementByteSlice(cur) | ||
} | ||
return toReturn | ||
} | ||
|
||
// Generate many random, unsorted keys | ||
func generateRandomKeys(keySize int, numKeys int) [][]byte { | ||
toReturn := make([][]byte, 0, numKeys) | ||
for i := 0; i < numKeys; i++ { | ||
newKey := randSlice(keySize) | ||
toReturn = append(toReturn, newKey) | ||
} | ||
return toReturn | ||
} |
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
Oops, something went wrong.