Use SQL database instead of bolt #71

Merged
mrngm merged 6 commits from sql into master 2021-05-05 21:34:29 +02:00
1 changed files with 23 additions and 0 deletions
Showing only changes of commit f530a543f9 - Show all commits

View File

@ -75,3 +75,26 @@ func TestGeneratedKeysAreValid(t *testing.T) {
}
}
}
func TestTruncatedKeysAreInvalid(t *testing.T) {
db, err := OpenTemporaryDB()
if err != nil {
t.Error(err)
}
var minimumEntropy int
checkTruncatedKeysInvalid := func(truncRand uint) bool {
key, err := GeneratePasteKey(db, minimumEntropy)
if err != nil {
return false
}
trunc := int(truncRand % uint(len(key)-1))
key = key[:trunc]
return ValidatePasteKey(key) == ErrKeyInvalidLength
}
for minimumEntropy = 0; minimumEntropy <= 80; minimumEntropy++ {
if err = quick.Check(checkTruncatedKeysInvalid, nil); err != nil {
t.Error(err)
}
}
}