mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-24 06:25:47 +00:00
feat: changed from SetValidatorAddress to env var
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
73e48c4ed7
commit
3c879b1610
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/planetmint/planetmint-go/lib"
|
||||
@ -25,17 +26,18 @@ issuer-host = "{{ .PlmntConfig.IssuerHost }}"
|
||||
certs-path = "{{ .PlmntConfig.CertsPath }}"
|
||||
`
|
||||
|
||||
const ValAddr = "VALIDATOR_ADDRESS"
|
||||
|
||||
// Config defines Planetmint's top level configuration
|
||||
type Config struct {
|
||||
MqttDomain string `json:"mqtt-domain" mapstructure:"mqtt-domain"`
|
||||
MqttPort int `json:"mqtt-port" mapstructure:"mqtt-port"`
|
||||
MqttUser string `json:"mqtt-user" mapstructure:"mqtt-user"`
|
||||
MqttPassword string `json:"mqtt-password" mapstructure:"mqtt-password"`
|
||||
ClaimHost string `json:"claim-host" mapstructure:"claim-host"`
|
||||
MqttTLS bool `json:"mqtt-tls" mapstructure:"mqtt-tls"`
|
||||
IssuerHost string `json:"issuer-host" mapstructure:"issuer-host"`
|
||||
CertsPath string `json:"certs-path" mapstructure:"certs-path"`
|
||||
validatorAddress string
|
||||
MqttDomain string `json:"mqtt-domain" mapstructure:"mqtt-domain"`
|
||||
MqttPort int `json:"mqtt-port" mapstructure:"mqtt-port"`
|
||||
MqttUser string `json:"mqtt-user" mapstructure:"mqtt-user"`
|
||||
MqttPassword string `json:"mqtt-password" mapstructure:"mqtt-password"`
|
||||
ClaimHost string `json:"claim-host" mapstructure:"claim-host"`
|
||||
MqttTLS bool `json:"mqtt-tls" mapstructure:"mqtt-tls"`
|
||||
IssuerHost string `json:"issuer-host" mapstructure:"issuer-host"`
|
||||
CertsPath string `json:"certs-path" mapstructure:"certs-path"`
|
||||
}
|
||||
|
||||
// cosmos-sdk wide global singleton
|
||||
@ -78,17 +80,12 @@ func (config *Config) SetPlanetmintConfig(planetmintconfig interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (config *Config) SetValidatorAddress(validatorAddress string) *Config {
|
||||
config.validatorAddress = validatorAddress
|
||||
return config
|
||||
}
|
||||
|
||||
func (config *Config) GetValidatorAddress() string {
|
||||
libConfig := lib.GetConfig()
|
||||
if libConfig.GetSerialPort() == "" {
|
||||
return config.validatorAddress
|
||||
if os.Getenv(ValAddr) != "" {
|
||||
return os.Getenv(ValAddr)
|
||||
}
|
||||
|
||||
libConfig := lib.GetConfig()
|
||||
connector, err := trustwallet.NewTrustWalletConnector(libConfig.GetSerialPort())
|
||||
if err != nil {
|
||||
logger.GetLogger(logger.ERROR).Error("msg", err.Error())
|
||||
|
||||
@ -595,8 +595,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
|
||||
}
|
||||
l.Log("started validator", idx)
|
||||
if idx == 0 {
|
||||
conf := config.GetConfig()
|
||||
conf.SetValidatorAddress(network.Validators[0].Address.String())
|
||||
os.Setenv(config.ValAddr, network.Validators[0].Address.String())
|
||||
// set missing validator client context values for sending txs
|
||||
var output bytes.Buffer
|
||||
network.Validators[0].ClientCtx.BroadcastMode = "sync"
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
@ -51,8 +52,7 @@ func TestRegisterNFT(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMachineNFTIssuance(t *testing.T) {
|
||||
cfg := config.GetConfig()
|
||||
cfg.SetValidatorAddress("plmnt10mq5nj8jhh27z7ejnz2ql3nh0qhzjnfvy50877")
|
||||
os.Setenv(config.ValAddr, "plmnt10mq5nj8jhh27z7ejnz2ql3nh0qhzjnfvy50877")
|
||||
ctrl := gomock.NewController(t)
|
||||
elements.Client = &elementsmocks.MockClient{}
|
||||
shamirMock := clientmocks.NewMockIShamirCoordinatorClient(ctrl)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user