Skip to content

Commit

Permalink
Fixed preactivated features duplication in configuration files. (#1130)
Browse files Browse the repository at this point in the history
* Fixed preactivated features duplication in configuration files.

* Added collection of stderr output from containers in separate files.
Made DefaultCustomSettings by-value constant.

* Add path cleaning back.
  • Loading branch information
alexeykiselev committed Jun 15, 2023
1 parent 7e0d92a commit df50e74
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 16 deletions.
3 changes: 2 additions & 1 deletion cmd/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/mr-tron/base58"
"github.com/pkg/errors"

"github.com/wavesplatform/gowaves/pkg/crypto"
"github.com/wavesplatform/gowaves/pkg/proto"
"github.com/wavesplatform/gowaves/pkg/settings"
Expand Down Expand Up @@ -120,7 +121,7 @@ func run() error {
}
var js []byte
if config {
cfg := *settings.DefaultCustomSettings
cfg := settings.DefaultCustomSettings
cfg.Genesis = *block
cfg.AddressSchemeCharacter = sc
var err error
Expand Down
7 changes: 4 additions & 3 deletions itests/config/genesis_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ func newBlockchainConfig() (*config, []AccountInfo, error) {
cfg.FeaturesVotingPeriod = 1
cfg.VotesForFeatureActivation = 1
cfg.MinUpdateAssetInfoInterval = 2
for _, feature := range genSettings.PreactivatedFeatures {
cfg.PreactivatedFeatures = append(cfg.PreactivatedFeatures, feature.Feature)
cfg.PreactivatedFeatures = make([]int16, len(genSettings.PreactivatedFeatures))
for i, f := range genSettings.PreactivatedFeatures {
cfg.PreactivatedFeatures[i] = f.Feature
}
return &config{
BlockchainSettings: cfg,
BlockchainSettings: &cfg,
ScalaOpts: &scalaCustomOptions{Features: genSettings.PreactivatedFeatures, EnableMining: false},
}, acc, nil
}
Expand Down
44 changes: 36 additions & 8 deletions itests/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ const (

const (
goNodeLogFileName = "go-node.log"
goNodeErrFileName = "go-node.err"
scalaNodeLogFileName = "scala-node.log"
logDir = "../build/logs"
scalaNodeErrFileName = "scala-node.err"
logsDir = "../build/logs"

walletPath = "wallet"
)
Expand All @@ -58,8 +60,10 @@ type Docker struct {
network *dockertest.Network
goNode *dockertest.Resource
goLogFile *os.File
goErrFile *os.File
scalaNode *dockertest.Resource
scalaLogFile *os.File
scalaErrFile *os.File
}

func NewDocker(suiteName string) (*Docker, error) {
Expand Down Expand Up @@ -112,7 +116,7 @@ func (d *Docker) RunContainers(ctx context.Context, paths config.ConfigPaths, su
if err != nil {
return nil, err
}
err = os.MkdirAll(filepath.Join(pwd, logDir, suiteName), os.ModePerm)
err = os.MkdirAll(filepath.Join(pwd, logsDir, suiteName), os.ModePerm)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -155,11 +159,21 @@ func (d *Docker) Finish(cancel context.CancelFunc) {
log.Warnf("Failed to close go-node logs file: %s", err)
}
}
if d.goErrFile != nil {
if err := d.goErrFile.Close(); err != nil {
log.Warnf("Failed to close go-node errors file: %s", err)
}
}
if d.scalaLogFile != nil {
if err := d.scalaLogFile.Close(); err != nil {
log.Warnf("Failed to close scala-node logs file: %s", err)
}
}
if d.scalaErrFile != nil {
if err := d.scalaErrFile.Close(); err != nil {
log.Warnf("Failed to close scala-node errors file: %s", err)
}
}
}

func (d *Docker) runGoNode(ctx context.Context, cfgPath string, suiteName string) (*dockertest.Resource, *PortConfig, error) {
Expand Down Expand Up @@ -199,7 +213,12 @@ func (d *Docker) runGoNode(ctx context.Context, cfgPath string, suiteName string
return nil, nil, err
}

logfile, err := os.Create(filepath.Clean(filepath.Join(pwd, logDir, suiteName, goNodeLogFileName)))
dir := filepath.Join(pwd, logsDir, suiteName)
logFile, err := os.Create(filepath.Clean(filepath.Join(dir, goNodeLogFileName)))
if err != nil {
return nil, nil, err
}
errFile, err := os.Create(filepath.Clean(filepath.Join(dir, goNodeErrFileName)))
if err != nil {
return nil, nil, err
}
Expand All @@ -215,13 +234,15 @@ func (d *Docker) runGoNode(ctx context.Context, cfgPath string, suiteName string

Container: res.Container.ID,

OutputStream: logfile,
OutputStream: logFile,
ErrorStream: errFile,
})
if err != nil {
log.Warnf("Fail to get logs from go-node: %s", err)
}
}()
d.goLogFile = logfile
d.goLogFile = logFile
d.goErrFile = errFile

portCfg := &PortConfig{
RestApiPort: res.GetPort(RESTApiPort + tcp),
Expand Down Expand Up @@ -287,7 +308,12 @@ func (d *Docker) runScalaNode(ctx context.Context, cfgPath string, suiteName str
return nil, nil, err
}

logfile, err := os.Create(filepath.Clean(filepath.Join(pwd, logDir, suiteName, scalaNodeLogFileName)))
dir := filepath.Join(pwd, logsDir, suiteName)
logFile, err := os.Create(filepath.Clean(filepath.Join(dir, scalaNodeLogFileName)))
if err != nil {
return nil, nil, err
}
errFile, err := os.Create(filepath.Clean(filepath.Join(dir, scalaNodeErrFileName)))
if err != nil {
return nil, nil, err
}
Expand All @@ -303,13 +329,15 @@ func (d *Docker) runScalaNode(ctx context.Context, cfgPath string, suiteName str

Container: res.Container.ID,

OutputStream: logfile,
OutputStream: logFile,
ErrorStream: errFile,
})
if err != nil {
log.Warnf("Fail to get logs from scala-node: %s", err)
}
}()
d.scalaLogFile = logfile
d.scalaLogFile = logFile
d.scalaErrFile = errFile

portCfg := &PortConfig{
RestApiPort: res.GetPort(RESTApiPort + tcp),
Expand Down
7 changes: 4 additions & 3 deletions pkg/grpc/server/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/wavesplatform/gowaves/pkg/crypto"
g "github.com/wavesplatform/gowaves/pkg/grpc/generated/waves/node/grpc"
"github.com/wavesplatform/gowaves/pkg/proto"
Expand All @@ -24,8 +27,6 @@ import (
"github.com/wavesplatform/gowaves/pkg/state"
"github.com/wavesplatform/gowaves/pkg/types"
"github.com/wavesplatform/gowaves/pkg/wallet"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

const (
Expand Down Expand Up @@ -76,7 +77,7 @@ func customSettingsWithGenesis(t *testing.T, genesisPath string) *settings.Block
// This is needed because transactions from MainNet blockchain are used in tests' genesis blocks.
sets.AddressSchemeCharacter = settings.MainNetSettings.AddressSchemeCharacter
sets.BlockRewardTerm = 100000
return sets
return &sets
}

func stateWithCustomGenesis(t *testing.T, genesisPath string) state.State {
Expand Down
2 changes: 1 addition & 1 deletion pkg/settings/blockchain_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ var (
DelayDelta: delayDeltaDefault,
},
}
DefaultCustomSettings = &BlockchainSettings{
DefaultCustomSettings = BlockchainSettings{
Type: Custom,
FunctionalitySettings: FunctionalitySettings{
FeaturesVotingPeriod: 5000,
Expand Down

0 comments on commit df50e74

Please sign in to comment.