diff options
Diffstat (limited to 'core/test/governance.go')
-rw-r--r-- | core/test/governance.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/test/governance.go b/core/test/governance.go index a4e86d1..58ab582 100644 --- a/core/test/governance.go +++ b/core/test/governance.go @@ -18,12 +18,20 @@ package test import ( + "fmt" + "github.com/dexon-foundation/dexon-consensus-core/core/types" "github.com/dexon-foundation/dexon-consensus-core/crypto" "github.com/dexon-foundation/dexon-consensus-core/crypto/eth" "github.com/shopspring/decimal" ) +var ( + // ErrPrivateKeyNotExists means caller request private key for an + // unknown validator ID. + ErrPrivateKeyNotExists = fmt.Errorf("private key not exists") +) + // Governance is an implementation of Goverance for testing purpose. type Governance struct { BlockProposingInterval int @@ -79,3 +87,16 @@ func (g *Governance) GetConfigurationChangeEvent( epoch int) []types.ConfigurationChangeEvent { return nil } + +// GetPrivateKey return the private key for that validator, this function +// is a test utility and not a general core.Governance interface. +func (g *Governance) GetPrivateKey( + vID types.ValidatorID) (key crypto.PrivateKey, err error) { + + key, exists := g.PrivateKeys[vID] + if !exists { + err = ErrPrivateKeyNotExists + return + } + return +} |