forked from TrueCloudLab/frostfs-node
[#280] ir: Add parser unit tests
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
2dbe382b5f
commit
e70f808dc3
2 changed files with 229 additions and 3 deletions
|
@ -22,7 +22,7 @@ type contracts struct {
|
|||
alphabet alphabetContracts // in morph
|
||||
}
|
||||
|
||||
func parseContracts(cfg *viper.Viper, morph *client.Client, withoutMainNet, withoutMainNotary, withoutSideNotary bool) (*contracts, error) {
|
||||
func parseContracts(cfg *viper.Viper, morph nnsResolver, withoutMainNet, withoutMainNotary, withoutSideNotary bool) (*contracts, error) {
|
||||
var (
|
||||
result = new(contracts)
|
||||
err error
|
||||
|
@ -76,7 +76,7 @@ func parseContracts(cfg *viper.Viper, morph *client.Client, withoutMainNet, with
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func parseAlphabetContracts(cfg *viper.Viper, morph *client.Client) (alphabetContracts, error) {
|
||||
func parseAlphabetContracts(cfg *viper.Viper, morph nnsResolver) (alphabetContracts, error) {
|
||||
num := GlagoliticLetter(cfg.GetUint("contracts.alphabet.amount"))
|
||||
alpha := newAlphabetContracts()
|
||||
|
||||
|
@ -115,7 +115,7 @@ func parseAlphabetContracts(cfg *viper.Viper, morph *client.Client) (alphabetCon
|
|||
return alpha, nil
|
||||
}
|
||||
|
||||
func parseContract(cfg *viper.Viper, morph *client.Client, cfgName, nnsName string) (res util.Uint160, err error) {
|
||||
func parseContract(cfg *viper.Viper, morph nnsResolver, cfgName, nnsName string) (res util.Uint160, err error) {
|
||||
contractStr := cfg.GetString(cfgName)
|
||||
if len(contractStr) == 0 {
|
||||
return morph.NNSContractAddress(nnsName)
|
||||
|
@ -123,3 +123,7 @@ func parseContract(cfg *viper.Viper, morph *client.Client, cfgName, nnsName stri
|
|||
|
||||
return util.Uint160DecodeStringLE(contractStr)
|
||||
}
|
||||
|
||||
type nnsResolver interface {
|
||||
NNSContractAddress(name string) (sh util.Uint160, err error)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue