prysm-pulse/testing/endtoend/helpers/keystore.go
kasey d58d3f2c57
E2E deposit testing overhaul (#11667)
* rewrite/refactor deposit testing code

keep track of sent deposits so that they can be compared in detail with
the validator set retreived from the API.

* fix bugs in evaluator and retry

* lint + deepsource appeasement

* typo s/Sprintf/Printf/

* gosec, more like nosec

* fix gosec number - 204->304

* type switch to get signed block from container

* improve comments

* centralizing constants and adding comments

* lock around Depositor to avoid future races

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
2022-11-19 03:40:32 +00:00

18 lines
496 B
Go

package helpers
import (
"os"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/pkg/errors"
)
// KeyFromPath should only be used in endtoend tests. It is a simple helper to init a geth keystore.Key from a file.
func KeyFromPath(path, pw string) (*keystore.Key, error) {
jsonb, err := os.ReadFile(path) // #nosec G304 -- for endtoend use only
if err != nil {
return nil, errors.Wrapf(err, "couldn't read keystore file %s", path)
}
return keystore.DecryptKey(jsonb, pw)
}