mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
refactor: mark makeJWTSecret to be a test helper
This commit is contained in:
parent
71210b0630
commit
85afb37fa3
1 changed files with 7 additions and 12 deletions
|
|
@ -34,23 +34,21 @@ import (
|
|||
"github.com/ethereum/go-ethereum/p2p"
|
||||
)
|
||||
|
||||
func makeJWTSecret(t *testing.T) (string, [32]byte, error) {
|
||||
func makeJWTSecret(t *testing.T) (string, [32]byte) {
|
||||
t.Helper()
|
||||
var secret [32]byte
|
||||
if _, err := crand.Read(secret[:]); err != nil {
|
||||
return "", secret, fmt.Errorf("failed to create jwt secret: %v", err)
|
||||
t.Fatalf("failed to create jwt secret: %v", err)
|
||||
}
|
||||
jwtPath := filepath.Join(t.TempDir(), "jwt_secret")
|
||||
if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(secret[:])), 0600); err != nil {
|
||||
return "", secret, fmt.Errorf("failed to prepare jwt secret file: %v", err)
|
||||
t.Fatalf("failed to prepare jwt secret file: %v", err)
|
||||
}
|
||||
return jwtPath, secret, nil
|
||||
return jwtPath, secret
|
||||
}
|
||||
|
||||
func TestEthSuite(t *testing.T) {
|
||||
jwtPath, secret, err := makeJWTSecret(t)
|
||||
if err != nil {
|
||||
t.Fatalf("could not make jwt secret: %v", err)
|
||||
}
|
||||
jwtPath, secret := makeJWTSecret(t)
|
||||
geth, err := runGeth("./testdata", jwtPath)
|
||||
if err != nil {
|
||||
t.Fatalf("could not run geth: %v", err)
|
||||
|
|
@ -75,10 +73,7 @@ func TestEthSuite(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSnapSuite(t *testing.T) {
|
||||
jwtPath, secret, err := makeJWTSecret(t)
|
||||
if err != nil {
|
||||
t.Fatalf("could not make jwt secret: %v", err)
|
||||
}
|
||||
jwtPath, secret := makeJWTSecret(t)
|
||||
geth, err := runGeth("./testdata", jwtPath)
|
||||
if err != nil {
|
||||
t.Fatalf("could not run geth: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue