Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: BLS signer refactor #110

Merged
merged 9 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fmt"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
tmconfig "github.com/tendermint/tendermint/config"
tmos "github.com/tendermint/tendermint/libs/os"
"path/filepath"
"strconv"
"testing"
"time"
Expand Down Expand Up @@ -96,18 +94,8 @@ func Setup(isCheckTx bool) *BabylonApp {
// SetupPrivSigner sets up a PrivSigner for testing
func SetupPrivSigner() (*PrivSigner, error) {
nodeCfg := tmconfig.DefaultConfig()
pvKeyFile := nodeCfg.PrivValidatorKeyFile()
err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0777)
if err != nil {
return nil, err
}
pvStateFile := nodeCfg.PrivValidatorStateFile()
err = tmos.EnsureDir(filepath.Dir(pvStateFile), 0777)
if err != nil {
return nil, err
}
privSigner, _ := InitClientContext(client.Context{}, keyring.BackendMemory)
privSigner.WrappedPV.Clean(pvKeyFile, pvStateFile)
privSigner.WrappedPV.Clean(nodeCfg.PrivValidatorKeyFile(), nodeCfg.PrivValidatorStateFile())
return privSigner, nil
}

Expand Down
6 changes: 6 additions & 0 deletions app/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type PrivSigner struct {
}

func InitClientContext(clientCtx client.Context, backend string) (*PrivSigner, error) {
// setup private validator
nodeCfg := tmconfig.DefaultConfig()
pvKeyFile := nodeCfg.PrivValidatorKeyFile()
err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0777)
Expand All @@ -27,7 +28,12 @@ func InitClientContext(clientCtx client.Context, backend string) (*PrivSigner, e
}
pvStateFile := nodeCfg.PrivValidatorStateFile()
err = tmos.EnsureDir(filepath.Dir(pvStateFile), 0777)
if err != nil {
return nil, err
}
wrappedPV := privval.LoadOrGenWrappedFilePV(pvKeyFile, pvStateFile)

// setup client context
encodingCfg := MakeTestEncodingConfig()
clientCtx = client.Context{}.
WithHomeDir(DefaultNodeHome).
Expand Down