Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests infrastructure refactoring. Separation of creation … #1492

Merged
merged 48 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f3fb43f
Integration tests infrastructure refactoring. Separation of creation …
alexeykiselev Sep 10, 2024
f2281c2
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 10, 2024
e1dfe34
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 10, 2024
b5a2fe1
Update GolangCI-Lint to version 1.60.3.
alexeykiselev Sep 10, 2024
88280f6
Handle linter issue.
alexeykiselev Sep 10, 2024
47e161c
Fixed logging of diverged state hashes.
alexeykiselev Sep 11, 2024
8235936
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 12, 2024
548e3cb
Better error handling and other requested changes implemented.
alexeykiselev Sep 13, 2024
5382770
Fix error handling by adding named return parameter.
alexeykiselev Sep 13, 2024
3fbb2a3
Activation of feature "Fee Sponsorship" added to some negative tests.
alexeykiselev Sep 13, 2024
4ce1485
Replaced waiting for activation of sponsorship by waiting for the cer…
alexeykiselev Sep 13, 2024
b6d3533
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 13, 2024
e21ee4a
Introduce constant for default sponsorship activation height. Comment…
alexeykiselev Sep 13, 2024
c3a7ce2
Merge branch 'itest-infra-refactoring' of github.com:wavesplatform/go…
alexeykiselev Sep 13, 2024
12ef74e
Few itests fixed by using height to build expected data.
alexeykiselev Sep 16, 2024
f12e92d
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 16, 2024
4c4b314
Default XTN buyback period increased to 4 blocks.
alexeykiselev Sep 18, 2024
cae47a7
New utility function to wait for new height if it lower than given ad…
alexeykiselev Sep 18, 2024
f037586
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 18, 2024
7588ded
Waiting for height added to one more blinking test.
alexeykiselev Sep 18, 2024
e03bbb9
More blinking tests fixed by adding waiting for new height.
alexeykiselev Sep 18, 2024
2aba685
Two more blinking tests fixed.
alexeykiselev Sep 18, 2024
a31e3ce
Waiting for height 3 added to all related test.
alexeykiselev Sep 19, 2024
65073e7
Merge branch 'master' into itest-infra-refactoring
nickeskov Sep 19, 2024
42e70d0
Waiting for certain height removed from all blinking tests.
alexeykiselev Sep 20, 2024
e5dc67d
Implemented function to request balances by list of addresses in a sy…
alexeykiselev Sep 24, 2024
bc4782c
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 24, 2024
b0602e6
Merge branch 'itest-infra-refactoring' into remove-waiting
alexeykiselev Sep 24, 2024
8bf75e8
Merge branch 'itest-infra-refactoring' of github.com:wavesplatform/go…
alexeykiselev Sep 24, 2024
7eeac68
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 24, 2024
0da968f
Remove incorrect file.
alexeykiselev Sep 24, 2024
38d2836
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 25, 2024
8552b45
Merge branch 'master' into itest-infra-refactoring
nickeskov Sep 25, 2024
61d41e1
Reduce file permisions on test directories.
alexeykiselev Sep 26, 2024
dd86d8f
Add writing to itest logs directories.
alexeykiselev Sep 26, 2024
417f872
Add write permission to logs folders of itests.
alexeykiselev Sep 26, 2024
e81e4fc
Restored full permissions to itests folders.
alexeykiselev Sep 26, 2024
b6d6c1a
Run in parallel internals of some wait methods of 'NodesClients'.
nickeskov Sep 27, 2024
18ff648
Fix data race and refactor 'NodesClients.requestAvailableBalancesForA…
nickeskov Sep 27, 2024
9b17a38
Fix typo in 'getSynchronizedBalances'.
nickeskov Sep 27, 2024
779b049
Merge branch 'master' into itest-infra-refactoring
alexeykiselev Sep 27, 2024
af6aa8b
Fix bug with deadlock in 'NodesClients.WaitForConnectedPeers'.
nickeskov Sep 27, 2024
469b642
Refactor 'NodesClients.WaitForConnectedPeers'
nickeskov Sep 27, 2024
72e6a24
Move API key string to the constant.
alexeykiselev Sep 27, 2024
b7bdc83
Removed unnecessary context cancelling.
nickeskov Sep 27, 2024
e4e9d73
Merge branch 'itest-infra-refactoring.errgroup' into itest-infra-refa…
alexeykiselev Sep 27, 2024
d6f0f04
Handle error.
alexeykiselev Sep 27, 2024
62a5ca6
Merge branch 'master' into itest-infra-refactoring
nickeskov Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
cache: true

- name: Set up GolangCI-Lint
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $HOME/bin v1.60.2
run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $HOME/bin v1.60.3

- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions itests/alias_tx_api_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/stretchr/testify/suite"

f "github.com/wavesplatform/gowaves/itests/fixtures"
"github.com/wavesplatform/gowaves/itests/testdata"
utl "github.com/wavesplatform/gowaves/itests/utilities"
Expand Down
4 changes: 3 additions & 1 deletion itests/config/base_target_calculating_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package config

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/wavesplatform/gowaves/pkg/consensus"
"github.com/wavesplatform/gowaves/pkg/types"
"testing"
)

func TestCalculateBaseTarget(t *testing.T) {
Expand Down
223 changes: 223 additions & 0 deletions itests/config/blockchain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
package config

import (
"slices"
"strconv"
"strings"
"time"

"github.com/pkg/errors"

"github.com/wavesplatform/gowaves/pkg/proto"
"github.com/wavesplatform/gowaves/pkg/settings"
"github.com/wavesplatform/gowaves/pkg/util/genesis_generator"
)

// RewardAddresses contains information about DAO and XTNBuyback addresses.
// Methods of RewardAddresses allow to represent this information in a form suitable for Go node configuration.
type RewardAddresses struct {
DAORewardAddress *proto.WavesAddress
XTNBuybackAddress *proto.WavesAddress
}

// NewRewardAddresses creates RewardAddresses from two string representations of DAO and XTNBuyback addresses.
func NewRewardAddresses(daoAddress, xtnAddress string) (RewardAddresses, error) {
r := RewardAddresses{}
if len(daoAddress) != 0 {
a, err := proto.NewAddressFromString(daoAddress)
if err != nil {
return RewardAddresses{}, errors.Wrap(err, "failed to create reward addresses")
}
r.DAORewardAddress = &a
}
if len(xtnAddress) != 0 {
a, err := proto.NewAddressFromString(xtnAddress)
if err != nil {
return RewardAddresses{}, errors.Wrap(err, "failed to create reward addresses")
}
r.XTNBuybackAddress = &a
}
return r, nil
}

// Addresses returns DAO and XTNBuyback addresses as a slice of Waves addresses.
func (ra *RewardAddresses) Addresses() []proto.WavesAddress {
r := make([]proto.WavesAddress, 0, 2)
if ra.DAORewardAddress != nil {
r = append(r, *ra.DAORewardAddress)
}
if ra.XTNBuybackAddress != nil {
r = append(r, *ra.XTNBuybackAddress)
}
return r
}

// AddressesAfter21 returns DAO address as a slice of Waves addresses that doesn't contain XTNBuyback address to
// represent the set of reward addresses after the activation of feature 21.
func (ra *RewardAddresses) AddressesAfter21() []proto.WavesAddress {
if ra.DAORewardAddress != nil {
return []proto.WavesAddress{*ra.DAORewardAddress}
}
return []proto.WavesAddress{}
}

// BlockchainOption is a function type that allows to set additional parameters to BlockchainConfig.
type BlockchainOption func(*BlockchainConfig) error

// BlockchainConfig is a struct that contains settings for blockchain.
// This configuration is used both for building Scala and Go configuration files.
// Also, it's used to produce a Docker container run configurations for both nodes.
type BlockchainConfig struct {
accounts []AccountInfo
supported []int16
desiredReward uint64

Settings *settings.BlockchainSettings
Features []FeatureInfo
RewardAddresses RewardAddresses
EnableScalaMining bool
}

func NewBlockchainConfig(options ...BlockchainOption) (*BlockchainConfig, error) {
gs, err := parseGenesisSettings()
if err != nil {
return nil, errors.Wrap(err, "failed to create blockchain configuration")
}

// Generate new genesis block.
ts := safeNow()
txs, acs, err := makeTransactionAndKeyPairs(gs, ts)
if err != nil {
return nil, err
}
bt, err := calcInitialBaseTarget(gs)
if err != nil {
return nil, err
}
b, err := genesis_generator.GenerateGenesisBlock(gs.Scheme, txs, bt, ts)
if err != nil {
return nil, err
}
bs := settings.MustDefaultCustomSettings()
bs.Genesis = *b
bs.AddressSchemeCharacter = gs.Scheme
bs.AverageBlockDelaySeconds = gs.AverageBlockDelay
bs.MinBlockTime = gs.MinBlockTime
bs.DelayDelta = gs.DelayDelta
bs.DoubleFeaturesPeriodsAfterHeight = 0
bs.SponsorshipSingleActivationPeriod = true
bs.MinUpdateAssetInfoInterval = 2
bs.FeaturesVotingPeriod = 1
bs.VotesForFeatureActivation = 1
bs.InitialBlockReward = defaultInitialBlockReward
bs.BlockRewardIncrement = defaultBlockRewardIncrement
bs.BlockRewardVotingPeriod = defaultBlockRewardVotingPeriod
bs.BlockRewardTermAfter20 = defaultBlockRewardTermAfter20
bs.BlockRewardTerm = defaultBlockRewardTerm
bs.MinXTNBuyBackPeriod = defaultMinXTNBuyBackPeriod

cfg := &BlockchainConfig{
Settings: bs,
accounts: acs,
desiredReward: defaultDesiredBlockReward,
}

if ftErr := cfg.UpdatePreactivatedFeatures(gs.PreactivatedFeatures); ftErr != nil {
return nil, errors.Wrap(ftErr, "failed to create blockchain configuration")
}

// Apply additional options.
for _, opt := range options {
if optErr := opt(cfg); optErr != nil {
return nil, errors.Wrap(optErr, "failed to create blockchain configuration")
}
}
return cfg, nil
}

// UpdatePreactivatedFeatures checks and inserts new preactivated features in BlockchainConfig.
func (c *BlockchainConfig) UpdatePreactivatedFeatures(features []FeatureInfo) error {
for _, f := range features {
if f.Feature <= 0 {
return errors.Errorf("invalid feature ID '%d'", f.Feature)
}
if !slices.ContainsFunc(c.Features, func(fi FeatureInfo) bool {
return fi.Feature == f.Feature
}) {
c.Features = append(c.Features, f)
}
}
// Replace preactivated features of blockchain settings with a new set of features.
c.Settings.PreactivatedFeatures = make([]int16, len(c.Features))
for i, f := range c.Features {
c.Settings.PreactivatedFeatures[i] = f.Feature
}
return nil
}

func (c *BlockchainConfig) SupportedFeaturesString() string {
ss := make([]string, len(c.supported))
for i, s := range c.supported {
ss[i] = strconv.FormatInt(int64(s), 10)
}
return strings.Join(ss, ",")
}

func (c *BlockchainConfig) DesiredBlockRewardString() string {
return strconv.FormatUint(c.desiredReward, 10)
}

func (c *BlockchainConfig) TestConfig() TestConfig {
return TestConfig{
Accounts: c.accounts,
BlockchainSettings: c.Settings,
}
}

// WithRewardSettingFromFile is a BlockchainOption that allows to set reward settings from configuration file.
// Reward settings configuration file is a JSON file with the structure of `rewardSettings`.
func WithRewardSettingFromFile(dir, file string) BlockchainOption {
return func(cfg *BlockchainConfig) error {
rs, err := NewRewardSettingsFromFile(dir, file)
if err != nil {
return errors.Wrap(err, "failed to modify reward settings")
}
cfg.Settings.InitialBlockReward = rs.InitialBlockReward
cfg.Settings.BlockRewardIncrement = rs.BlockRewardIncrement
cfg.Settings.BlockRewardVotingPeriod = rs.BlockRewardVotingPeriod
cfg.Settings.BlockRewardTermAfter20 = rs.BlockRewardTermAfter20
cfg.Settings.BlockRewardTerm = rs.BlockRewardTerm
cfg.Settings.MinXTNBuyBackPeriod = rs.MinXTNBuyBackPeriod

ras, err := NewRewardAddresses(rs.DaoAddress, rs.XtnBuybackAddress)
if err != nil {
return errors.Wrap(err, "failed to modify reward settings")
}
cfg.RewardAddresses = ras
cfg.Settings.RewardAddresses = ras.Addresses()
cfg.Settings.RewardAddressesAfter21 = ras.AddressesAfter21()

cfg.supported = rs.SupportedFeatures
cfg.desiredReward = rs.DesiredBlockReward

if ftErr := cfg.UpdatePreactivatedFeatures(rs.PreactivatedFeatures); ftErr != nil {
return errors.Wrap(ftErr, "failed to modify preactivated features")
}
return nil
}
}

func WithScalaMining() BlockchainOption {
return func(cfg *BlockchainConfig) error {
cfg.EnableScalaMining = true
return nil
}
}

func safeNow() uint64 {
now := time.Now().UnixMilli()
if now < 0 {
return 0
}
return uint64(now)
}
Loading
Loading