Use SQL database instead of bolt #71
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user