mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-24 22:45:45 +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 (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/planetmint/planetmint-go/lib"
|
"github.com/planetmint/planetmint-go/lib"
|
||||||
@ -25,6 +26,8 @@ issuer-host = "{{ .PlmntConfig.IssuerHost }}"
|
|||||||
certs-path = "{{ .PlmntConfig.CertsPath }}"
|
certs-path = "{{ .PlmntConfig.CertsPath }}"
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const ValAddr = "VALIDATOR_ADDRESS"
|
||||||
|
|
||||||
// Config defines Planetmint's top level configuration
|
// Config defines Planetmint's top level configuration
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MqttDomain string `json:"mqtt-domain" mapstructure:"mqtt-domain"`
|
MqttDomain string `json:"mqtt-domain" mapstructure:"mqtt-domain"`
|
||||||
@ -35,7 +38,6 @@ type Config struct {
|
|||||||
MqttTLS bool `json:"mqtt-tls" mapstructure:"mqtt-tls"`
|
MqttTLS bool `json:"mqtt-tls" mapstructure:"mqtt-tls"`
|
||||||
IssuerHost string `json:"issuer-host" mapstructure:"issuer-host"`
|
IssuerHost string `json:"issuer-host" mapstructure:"issuer-host"`
|
||||||
CertsPath string `json:"certs-path" mapstructure:"certs-path"`
|
CertsPath string `json:"certs-path" mapstructure:"certs-path"`
|
||||||
validatorAddress string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cosmos-sdk wide global singleton
|
// 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 {
|
func (config *Config) GetValidatorAddress() string {
|
||||||
libConfig := lib.GetConfig()
|
if os.Getenv(ValAddr) != "" {
|
||||||
if libConfig.GetSerialPort() == "" {
|
return os.Getenv(ValAddr)
|
||||||
return config.validatorAddress
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libConfig := lib.GetConfig()
|
||||||
connector, err := trustwallet.NewTrustWalletConnector(libConfig.GetSerialPort())
|
connector, err := trustwallet.NewTrustWalletConnector(libConfig.GetSerialPort())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.GetLogger(logger.ERROR).Error("msg", err.Error())
|
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)
|
l.Log("started validator", idx)
|
||||||
if idx == 0 {
|
if idx == 0 {
|
||||||
conf := config.GetConfig()
|
os.Setenv(config.ValAddr, network.Validators[0].Address.String())
|
||||||
conf.SetValidatorAddress(network.Validators[0].Address.String())
|
|
||||||
// set missing validator client context values for sending txs
|
// set missing validator client context values for sending txs
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
network.Validators[0].ClientCtx.BroadcastMode = "sync"
|
network.Validators[0].ClientCtx.BroadcastMode = "sync"
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@ -51,8 +52,7 @@ func TestRegisterNFT(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMachineNFTIssuance(t *testing.T) {
|
func TestMachineNFTIssuance(t *testing.T) {
|
||||||
cfg := config.GetConfig()
|
os.Setenv(config.ValAddr, "plmnt10mq5nj8jhh27z7ejnz2ql3nh0qhzjnfvy50877")
|
||||||
cfg.SetValidatorAddress("plmnt10mq5nj8jhh27z7ejnz2ql3nh0qhzjnfvy50877")
|
|
||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
elements.Client = &elementsmocks.MockClient{}
|
elements.Client = &elementsmocks.MockClient{}
|
||||||
shamirMock := clientmocks.NewMockIShamirCoordinatorClient(ctrl)
|
shamirMock := clientmocks.NewMockIShamirCoordinatorClient(ctrl)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user