Files
wazero/internal/gojs/crypto_test.go
Crypt Keeper 8918d73020 ci: supports building with Go 1.20 and raises floor version to 1.18 (#1096)
This moves our floor version to the same we'll release 1.0 with: 1.18.
This is congruent with our version policy which is current-2.

Fixes #921

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-02-06 17:29:08 +02:00

35 lines
894 B
Go

package gojs_test
import (
"bytes"
"context"
"testing"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/experimental"
"github.com/tetratelabs/wazero/experimental/logging"
"github.com/tetratelabs/wazero/internal/testing/require"
)
func Test_crypto(t *testing.T) {
t.Parallel()
var log bytes.Buffer
loggingCtx := context.WithValue(testCtx, experimental.FunctionListenerFactoryKey{},
logging.NewHostLoggingListenerFactory(&log, logging.LogScopeRandom))
stdout, stderr, err := compileAndRun(loggingCtx, "crypto", wazero.NewModuleConfig())
require.Zero(t, stderr)
require.EqualError(t, err, `module "" closed with exit_code(0)`)
require.Equal(t, `7a0c9f9f0d
`, stdout)
require.Equal(t, `==> go.runtime.getRandomData(r_len=32)
<==
==> go.runtime.getRandomData(r_len=8)
<==
==> go.syscall/js.valueCall(crypto.getRandomValues(r_len=5))
<== (n=5)
`, log.String())
}