Switches default random source to deterministic (#736)
This changes the default random source to provide deterministic values similar to how nanotime and walltime do. This also prevents any worries about if wasm can deplete the host's underlying source of entropy. Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -2,6 +2,7 @@ package wazero
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"io/fs"
|
||||
"math"
|
||||
@@ -479,6 +480,23 @@ func TestModuleConfig_toSysContext(t *testing.T) {
|
||||
testFS2, // fs
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "WithRandSource",
|
||||
input: base.WithRandSource(rand.Reader),
|
||||
expected: requireSysContext(t,
|
||||
math.MaxUint32, // max
|
||||
nil, // args
|
||||
nil, // environ
|
||||
nil, // stdin
|
||||
nil, // stdout
|
||||
nil, // stderr
|
||||
rand.Reader, // randSource
|
||||
&wt, 1, // walltime, walltimeResolution
|
||||
&nt, 1, // nanotime, nanotimeResolution
|
||||
nil, // nanosleep
|
||||
nil, // fs
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user