common: use names prng and mrand

This commit is contained in:
Ethan Buchman
2017-12-15 00:23:25 -05:00
parent 29471d75cb
commit b5f465b4ec
2 changed files with 53 additions and 29 deletions

View File

@ -9,9 +9,30 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/tendermint/tmlibs/common"
)
func TestRandStr(t *testing.T) {
l := 243
s := common.RandStr(l)
assert.Equal(t, l, len(s))
}
func TestRandBytes(t *testing.T) {
l := 243
b := common.RandBytes(l)
assert.Equal(t, l, len(b))
}
func TestRandIntn(t *testing.T) {
n := 243
for i := 0; i < 100; i++ {
x := common.RandIntn(n)
assert.True(t, x < n)
}
}
// It is essential that these tests run and never repeat their outputs
// lest we've been pwned and the behavior of our randomness is controlled.
// See Issues: