Skip to content

Commit

Permalink
fix(nodebuilder): return fx error if theres an error getting keystore…
Browse files Browse the repository at this point in the history
… or constructing signer (celestiaorg#3297)

We never did anything with the errors provided to fx, we can just
short-circuit and return quickly if either fails.
  • Loading branch information
renaynay authored Apr 10, 2024
1 parent 26d411a commit 32f8856
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions nodebuilder/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func ConstructModule(tp node.Type, network p2p.Network, cfg *Config, store Store
log.Infow("Accessing keyring...")
ks, err := store.Keystore()
if err != nil {
fx.Error(err)
return fx.Error(err)
}
signer, err := state.KeyringSigner(cfg.State, ks, network)
if err != nil {
fx.Error(err)
return fx.Error(err)
}

baseComponents := fx.Options(
Expand Down
9 changes: 8 additions & 1 deletion nodebuilder/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ import (
func MockStore(t *testing.T, cfg *Config) Store {
t.Helper()
store := NewMemStore()

err := store.PutConfig(cfg)
require.NoError(t, err)

ks, err := store.Keystore()
require.NoError(t, err)
_, _, err = generateNewKey(ks.Keyring())
require.NoError(t, err)

return store
}

Expand Down Expand Up @@ -67,7 +74,7 @@ func TestNodeWithConfig(t *testing.T, tp node.Type, cfg *Config, opts ...fx.Opti

func TestKeyringSigner(t *testing.T, ring keyring.Keyring) *apptypes.KeyringSigner {
signer := apptypes.NewKeyringSigner(ring, "", string(p2p.Private))
_, _, err := signer.NewMnemonic("test_celes", keyring.English, "",
_, _, err := signer.NewMnemonic("my_celes_key", keyring.English, "",
"", hd.Secp256k1)
require.NoError(t, err)
return signer
Expand Down

0 comments on commit 32f8856

Please sign in to comment.