From bb1cc0bb74449ff7c40ec0b107561fcecafd9228 Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Mon, 11 Mar 2024 17:46:41 +0300 Subject: [PATCH 1/7] Add new checks to reward info tests. --- .../reward_distribution_info_internal_test.go | 36 ++-- .../reward_distribution_features_testdata.go | 50 +++--- .../reward_distribution_rolllback_testdata.go | 12 +- itests/testdata/rewards_info_testdata.go | 72 ++++++-- itests/utilities/assertions.go | 41 +++++ itests/utilities/common.go | 157 ++++++++++++++---- itests/utilities/reward/reward.go | 36 +++- 7 files changed, 306 insertions(+), 98 deletions(-) diff --git a/itests/reward_distribution_info_internal_test.go b/itests/reward_distribution_info_internal_test.go index 87fb48506..1aee5b3df 100644 --- a/itests/reward_distribution_info_internal_test.go +++ b/itests/reward_distribution_info_internal_test.go @@ -23,11 +23,12 @@ type RewardDistributionAPIRewardInfoPreactivatedSuite struct { func (suite *RewardDistributionAPIRewardInfoPreactivatedSuite) Test_NODE855() { const node855 = "/blockchain/rewards returns correct values for term," + " nextCheck and votingIntervalStart after CappedReward activation" - td := testdata.GetRewardInfoApiAfterPreactivated20TestData(&suite.BaseSuite) suite.Run(node855, func() { utl.GetActivationOfFeatures(&suite.BaseSuite, settings.BlockReward, settings.BlockRewardDistribution, settings.CappedRewards) - reward.GetRewardInfoAndChecks(&suite.BaseSuite, td) + utl.WaitForHeight(&suite.BaseSuite, uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, + settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))+utl.GetRewardTermAfter20Cfg(&suite.BaseSuite)-1) + reward.GetRewardInfoAndChecks(&suite.BaseSuite, testdata.GetRewardInfoApiAfterPreactivated20TestData) }) } @@ -43,13 +44,13 @@ type RewardDistributionAPIRewardInfoSupportedSuite struct { func (suite *RewardDistributionAPIRewardInfoSupportedSuite) Test_NODE855_2() { const node855 = "/blockchain/rewards returns correct values for term," + " nextCheck and votingIntervalStart after CappedReward activation" - tdBefore20 := testdata.GetRewardInfoApiBefore20TestData(&suite.BaseSuite) - tdAfter20 := testdata.GetRewardInfoApiAfterSupported20TestData(&suite.BaseSuite) suite.Run(node855, func() { utl.GetActivationOfFeatures(&suite.BaseSuite, settings.BlockReward, settings.BlockRewardDistribution) - reward.GetRewardInfoAndChecks(&suite.BaseSuite, tdBefore20) + reward.GetRewardInfoAndChecks(&suite.BaseSuite, testdata.GetRewardInfoApiBefore20TestData) utl.GetActivationOfFeatures(&suite.BaseSuite, settings.CappedRewards) - reward.GetRewardInfoAndChecks(&suite.BaseSuite, tdAfter20) + utl.WaitForHeight(&suite.BaseSuite, uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, + settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))+utl.GetRewardTermAfter20Cfg(&suite.BaseSuite)) + reward.GetRewardInfoAndChecks(&suite.BaseSuite, testdata.GetRewardInfoApiAfterSupported20TestData) }) } @@ -67,12 +68,15 @@ type RewardDistributionAPIRewardInfoAtHeightPreactivatedSuite struct { func (suite *RewardDistributionAPIRewardInfoAtHeightPreactivatedSuite) Test_NODE856() { const node856 = "/blockchain/rewards/{height} returns correct values for term," + " nextCheck and votingIntervalStart after CappedReward activation" - td := testdata.GetRewardInfoApiAfterPreactivated20TestData(&suite.BaseSuite) suite.Run(node856, func() { utl.GetActivationOfFeatures(&suite.BaseSuite, settings.BlockReward, settings.BlockRewardDistribution, settings.CappedRewards) - reward.GetRewardInfoAtHeightAndChecks(&suite.BaseSuite, td, uint64(utl.GetFeatureActivationHeight( - &suite.BaseSuite, settings.CappedRewards, utl.GetHeight(&suite.BaseSuite))+1)) + utl.WaitForHeight(&suite.BaseSuite, uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, + settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))+utl.GetRewardTermAfter20Cfg(&suite.BaseSuite)-1) + reward.GetRewardInfoAtHeightAndChecks(&suite.BaseSuite, testdata.GetRewardInfoApiAfterPreactivated20TestData, + uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, + settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))+ + utl.GetRewardTermAfter20Cfg(&suite.BaseSuite)-1) }) } @@ -88,15 +92,17 @@ type RewardDistributionAPIRewardInfoAtHeightSupportedSuite struct { func (suite *RewardDistributionAPIRewardInfoAtHeightSupportedSuite) Test_NODE856_2() { const node856 = "/blockchain/rewards/{height} returns correct values for term," + " nextCheck and votingIntervalStart after CappedReward activation" - tdBefore20 := testdata.GetRewardInfoApiBefore20TestData(&suite.BaseSuite) - tdAfter20 := testdata.GetRewardInfoApiAfterSupported20TestData(&suite.BaseSuite) suite.Run(node856, func() { utl.GetActivationOfFeatures(&suite.BaseSuite, settings.BlockReward, settings.BlockRewardDistribution) - reward.GetRewardInfoAtHeightAndChecks(&suite.BaseSuite, tdBefore20, uint64(utl.GetFeatureActivationHeight( - &suite.BaseSuite, settings.BlockRewardDistribution, utl.GetHeight(&suite.BaseSuite))+1)) + reward.GetRewardInfoAtHeightAndChecks(&suite.BaseSuite, testdata.GetRewardInfoApiBefore20TestData, + uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, settings.BlockRewardDistribution, + utl.GetHeight(&suite.BaseSuite))+1)) utl.GetActivationOfFeatures(&suite.BaseSuite, settings.CappedRewards) - reward.GetRewardInfoAtHeightAndChecks(&suite.BaseSuite, tdAfter20, uint64(utl.GetFeatureActivationHeight( - &suite.BaseSuite, settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))) + utl.WaitForHeight(&suite.BaseSuite, uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, + settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))+utl.GetRewardTermAfter20Cfg(&suite.BaseSuite)) + reward.GetRewardInfoAtHeightAndChecks(&suite.BaseSuite, testdata.GetRewardInfoApiAfterSupported20TestData, + uint64(utl.GetFeatureActivationHeight(&suite.BaseSuite, + settings.CappedRewards, utl.GetHeight(&suite.BaseSuite)))+utl.GetRewardTermAfter20Cfg(&suite.BaseSuite)) }) } diff --git a/itests/testdata/reward_distribution_features_testdata.go b/itests/testdata/reward_distribution_features_testdata.go index c8d968225..e7cbfe174 100644 --- a/itests/testdata/reward_distribution_features_testdata.go +++ b/itests/testdata/reward_distribution_features_testdata.go @@ -89,7 +89,7 @@ func GetRewardIncreaseDaoXtnTestData(suite *f.BaseSuite, addresses AddressesForD return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -105,7 +105,7 @@ func GetRewardUnchangedDaoXtnTestData(suite *f.BaseSuite, addresses AddressesFor return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -118,7 +118,7 @@ func GetRewardUnchangedDaoXtnTestData(suite *f.BaseSuite, addresses AddressesFor // NODE - 816 func GetRewardDecreaseDaoXtnTestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -138,7 +138,7 @@ func GetRewardIncreaseDaoTestData(suite *f.BaseSuite, addresses AddressesForDist return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -154,7 +154,7 @@ func GetRewardUnchangedXtnTestData(suite *f.BaseSuite, addresses AddressesForDis return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - MaxAddressReward, DaoDiffBalance: 0, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -167,7 +167,7 @@ func GetRewardUnchangedXtnTestData(suite *f.BaseSuite, addresses AddressesForDis // NODE - 818 func GetRewardDecreaseXtnTestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -184,7 +184,7 @@ func GetRewardDecreaseXtnTestData(suite *f.BaseSuite, addresses AddressesForDist // NODE - 818 func GetRewardDecreaseDaoTestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -204,7 +204,7 @@ func GetReward2WUnchangedDaoXtnTestData(suite *f.BaseSuite, addresses AddressesF return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -220,7 +220,7 @@ func GetRewardMinersTestData(suite *f.BaseSuite, addresses AddressesForDistribut return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -236,7 +236,7 @@ func GetRewardDaoXtnWithout19TestData(suite *f.BaseSuite, addresses AddressesFor return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -260,7 +260,7 @@ func GetRewardIncreaseDaoXtnCeaseXTNBuybackBeforePeriodTestData(suite *f.BaseSui return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -272,7 +272,7 @@ func GetRewardIncreaseDaoXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSuit return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -288,7 +288,7 @@ func GetRewardIncreaseXtnCeaseXTNBuybackBeforePeriodTestData(suite *f.BaseSuite, return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - MaxAddressReward, DaoDiffBalance: 0, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -300,7 +300,7 @@ func GetRewardIncreaseXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSuite, return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -316,7 +316,7 @@ func GetRewardUnchangedDaoXtnCeaseXTNBuybackBeforePeriodTestData(suite *f.BaseSu return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -328,7 +328,7 @@ func GetRewardUnchangedDaoXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSui return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -341,7 +341,7 @@ func GetRewardUnchangedDaoXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSui // NODE - 826 func GetRewardDecreaseDaoXtnCeaseXTNBuybackBeforePeriodTestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -354,7 +354,7 @@ func GetRewardDecreaseDaoXtnCeaseXTNBuybackBeforePeriodTestData(suite *f.BaseSui func GetRewardDecreaseDaoXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -371,7 +371,7 @@ func GetRewardDecreaseDaoXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSuit // NODE - 826 func GetRewardDecreaseXtnCeaseXTNBuybackBeforePeriodTestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -387,7 +387,7 @@ func GetRewardDecreaseXtnCeaseXTNBuybackAfterPeriodTestData(suite *f.BaseSuite, return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -403,7 +403,7 @@ func GetReward2WUnchangedDaoXtnCeaseXTNBuybackTestData(suite *f.BaseSuite, addre return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -419,7 +419,7 @@ func GetReward5W2MinersIncreaseCeaseXTNBuybackTestData(suite *f.BaseSuite, addre return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -432,7 +432,7 @@ func GetReward5W2MinersIncreaseCeaseXTNBuybackTestData(suite *f.BaseSuite, addre // NODE - 830 func GetRewardDaoXtnBeforePeriodWithout20TestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -445,7 +445,7 @@ func GetRewardDaoXtnBeforePeriodWithout20TestData(suite *f.BaseSuite, addresses func GetRewardDaoXtnAfterPeriodWithout20TestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -465,7 +465,7 @@ func GetRewardDaoXtnWithout19And20TestData(suite *f.BaseSuite, addresses Address return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermCfg(suite), diff --git a/itests/testdata/reward_distribution_rolllback_testdata.go b/itests/testdata/reward_distribution_rolllback_testdata.go index 89951997a..6698ce11b 100644 --- a/itests/testdata/reward_distribution_rolllback_testdata.go +++ b/itests/testdata/reward_distribution_rolllback_testdata.go @@ -9,7 +9,7 @@ func GetRewardDistributionAfterF14Before19TestData(suite *f.BaseSuite, addresses height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { return NewRewardDistributionTestData(addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)), + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)), DaoDiffBalance: 0, XtnDiffBalance: 0, Term: utl.GetRewardTermCfg(suite), @@ -21,7 +21,7 @@ func GetRewardDistributionAfterF14Before19TestData(suite *f.BaseSuite, addresses // NODE - 858. func GetRollbackBeforeF19TestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -37,7 +37,7 @@ func GetRollbackBeforeF19TestData(suite *f.BaseSuite, addresses AddressesForDist // NODE - 859. func GetRollbackAfterF19TestData(suite *f.BaseSuite, addresses AddressesForDistribution, height uint64) RewardDistributionTestData[RewardDistributionExpectedValues] { - currentReward := int64(utl.GetCurrentReward(suite, height)) + currentReward := int64(utl.GetCurrentRewardAtHeight(suite, height)) return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ @@ -56,7 +56,7 @@ func GetRollbackBeforeF20TestData(suite *f.BaseSuite, addresses AddressesForDist return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -70,7 +70,7 @@ func GetRollbackAfterF20TestData(suite *f.BaseSuite, addresses AddressesForDistr return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), @@ -84,7 +84,7 @@ func GetRollbackBeforeF21TestData(suite *f.BaseSuite, addresses AddressesForDist return NewRewardDistributionTestData( addresses, RewardDistributionExpectedValues{ - MinersSumDiffBalance: int64(utl.GetCurrentReward(suite, height)) - 2*MaxAddressReward, + MinersSumDiffBalance: int64(utl.GetCurrentRewardAtHeight(suite, height)) - 2*MaxAddressReward, DaoDiffBalance: MaxAddressReward, XtnDiffBalance: MaxAddressReward, Term: utl.GetRewardTermAfter20Cfg(suite), diff --git a/itests/testdata/rewards_info_testdata.go b/itests/testdata/rewards_info_testdata.go index 1ab346a0a..a98dd7cba 100644 --- a/itests/testdata/rewards_info_testdata.go +++ b/itests/testdata/rewards_info_testdata.go @@ -3,16 +3,29 @@ package testdata import ( f "github.com/wavesplatform/gowaves/itests/fixtures" utl "github.com/wavesplatform/gowaves/itests/utilities" + "github.com/wavesplatform/gowaves/pkg/proto" ) type RewardDistributionApiTestData[T any] struct { Expected T } +type Votes struct { + Increase uint32 + Decrease uint32 +} + type RewardInfoApiExpectedValues struct { + TotalWavesAmount uint64 + CurrentReward uint64 + MinIncrement uint64 Term uint64 NextCheck uint64 VotingIntervalStart uint64 + VotingInterval uint64 + Votes Votes + DaoAddress *proto.WavesAddress + XtnAddress *proto.WavesAddress _ struct{} } @@ -23,31 +36,66 @@ func NewRewardDistributionApiTestData[T any](expected T) RewardDistributionApiTe } func GetRewardInfoApiAfterPreactivated20TestData(suite *f.BaseSuite) RewardDistributionApiTestData[RewardInfoApiExpectedValues] { - period := utl.GetRewardTermAfter20Cfg(suite) + totalWavesAmount := utl.GetTotalWavesAmount(suite) + term := utl.GetRewardTermAfter20Cfg(suite) + minIncrement := utl.GetIncrementCfg(suite) + votingInterval := utl.GetVotingIntervalCfg(suite) + daoAddress, xtnAddress := utl.GetDaoAndXtnAddresses(suite) return NewRewardDistributionApiTestData( RewardInfoApiExpectedValues{ - Term: period, - NextCheck: period, - VotingIntervalStart: period, + TotalWavesAmount: totalWavesAmount, + MinIncrement: minIncrement, + Term: term, + NextCheck: term, + VotingIntervalStart: term, + VotingInterval: votingInterval, + Votes: Votes{ + Decrease: 0, + Increase: 1, + }, + DaoAddress: daoAddress, + XtnAddress: xtnAddress, }) } func GetRewardInfoApiAfterSupported20TestData(suite *f.BaseSuite) RewardDistributionApiTestData[RewardInfoApiExpectedValues] { - period := utl.GetRewardTermAfter20Cfg(suite) + totalWavesAmount := utl.GetTotalWavesAmount(suite) + term := utl.GetRewardTermAfter20Cfg(suite) + minIncrement := utl.GetIncrementCfg(suite) + votingInterval := utl.GetVotingIntervalCfg(suite) + daoAddress, xtnAddress := utl.GetDaoAndXtnAddresses(suite) return NewRewardDistributionApiTestData( RewardInfoApiExpectedValues{ - Term: period, - NextCheck: 2 * period, - VotingIntervalStart: 2 * period, + TotalWavesAmount: totalWavesAmount, + MinIncrement: minIncrement, + Term: term, + NextCheck: 3 * term, + VotingIntervalStart: 3 * term, + VotingInterval: votingInterval, + Votes: Votes{ + Decrease: 0, + Increase: 1, + }, + DaoAddress: daoAddress, + XtnAddress: xtnAddress, }) } func GetRewardInfoApiBefore20TestData(suite *f.BaseSuite) RewardDistributionApiTestData[RewardInfoApiExpectedValues] { - period := utl.GetRewardTermCfg(suite) + totalWavesAmount := utl.GetTotalWavesAmount(suite) + term := utl.GetRewardTermCfg(suite) + minIncrement := utl.GetIncrementCfg(suite) + votingInterval := utl.GetVotingIntervalCfg(suite) + daoAddress, xtnAddress := utl.GetDaoAndXtnAddresses(suite) return NewRewardDistributionApiTestData( RewardInfoApiExpectedValues{ - Term: period, - NextCheck: period, - VotingIntervalStart: period, + TotalWavesAmount: totalWavesAmount, + MinIncrement: minIncrement, + Term: term, + NextCheck: term, + VotingIntervalStart: term, + VotingInterval: votingInterval, + DaoAddress: daoAddress, + XtnAddress: xtnAddress, }) } diff --git a/itests/utilities/assertions.go b/itests/utilities/assertions.go index 72e8d02ea..05b16514f 100644 --- a/itests/utilities/assertions.go +++ b/itests/utilities/assertions.go @@ -2,6 +2,7 @@ package utilities import ( "fmt" + "github.com/wavesplatform/gowaves/pkg/proto" "testing" "github.com/stretchr/testify/assert" @@ -95,6 +96,20 @@ func XtnBuyBackDiffBalanceInWavesCheck(t *testing.T, expected int64, actualGo, a assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) } +func TotalWavesAmountCheck(t *testing.T, expected uint64, actualGo, actualScala uint64, + args ...interface{}) { + errMsg := makeErrorMessage("totalWavesAmount mismatch", args...) + assert.Equalf(t, int(expected), int(actualGo), "Node Go: "+errMsg) + assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) +} + +func MinIncrementCheck(t *testing.T, expected uint64, actualGo, actualScala uint64, + args ...interface{}) { + errMsg := makeErrorMessage("min increment mismatch", args...) + assert.Equalf(t, int(expected), int(actualGo), "Node Go: "+errMsg) + assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) +} + func TermCheck(t *testing.T, expected uint64, actualGo, actualScala uint64, args ...interface{}) { errMsg := makeErrorMessage("Terms are mismatch", args...) assert.Equalf(t, int(expected), int(actualGo), "Node Go: "+errMsg) @@ -107,8 +122,34 @@ func VotingIntervalStartCheck(t *testing.T, expected uint64, actualGo, actualSca assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) } +func VotingIntervalCheck(t *testing.T, expected uint64, actualGo, actualScala uint64, args ...interface{}) { + errMsg := makeErrorMessage("VotingInterval parameters are mismatch", args...) + assert.Equalf(t, int(expected), int(actualGo), "Node Go: "+errMsg) + assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) +} + +func VotesCheck(t *testing.T, expected uint32, actualGo, actualScala uint32, args ...interface{}) { + errMsg := makeErrorMessage("Votes parameters are mismatch", args...) + assert.Equalf(t, int(expected), int(actualGo), "Node Go: "+errMsg) + assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) +} + func NextCheckParameterCheck(t *testing.T, expected uint64, actualGo, actualScala uint64, args ...interface{}) { errMsg := makeErrorMessage("NextChecks are mismatch", args...) assert.Equalf(t, int(expected), int(actualGo), "Node Go: "+errMsg) assert.Equalf(t, int(expected), int(actualScala), "Node Scala: "+errMsg) } + +func DaoAddressCheck(t *testing.T, expected *proto.WavesAddress, actualGo, actualScala *proto.WavesAddress, + args ...interface{}) { + errMsg := makeErrorMessage("dao addresses are mismatch", args...) + assert.Equalf(t, expected, actualGo, "Node Go: "+errMsg) + assert.Equalf(t, expected, actualScala, "Node Scala: "+errMsg) +} + +func XtnAddressCheck(t *testing.T, expected *proto.WavesAddress, actualGo, actualScala *proto.WavesAddress, + args ...interface{}) { + errMsg := makeErrorMessage("xtn addresses are mismatch", args...) + assert.Equalf(t, expected, actualGo, "Node Go: "+errMsg) + assert.Equalf(t, expected, actualScala, "Node Scala: "+errMsg) +} diff --git a/itests/utilities/common.go b/itests/utilities/common.go index c5d681e0b..17c20ad0d 100644 --- a/itests/utilities/common.go +++ b/itests/utilities/common.go @@ -318,6 +318,52 @@ func GetAccount(suite *f.BaseSuite, i int) config.AccountInfo { return suite.Cfg.Accounts[i] } +func GetAddressesOfAvailableAccounts(suite *f.BaseSuite) []proto.WavesAddress { + accounts := suite.Cfg.Accounts + var addresses []proto.WavesAddress + daoAddress, xtnAddress := GetDaoAndXtnAddresses(suite) + if daoAddress != nil { + addresses = append(addresses, *daoAddress) + } + if xtnAddress != nil { + addresses = append(addresses, *xtnAddress) + } + for _, account := range accounts { + if account.Address != *daoAddress && account.Address != *xtnAddress { + addresses = append(addresses, account.Address) + } + } + return addresses +} + +func GetTotalWavesAmountGo(suite *f.BaseSuite) uint64 { + var totalWavesAmount uint64 + addresses := GetAddressesOfAvailableAccounts(suite) + for _, address := range addresses { + totalWavesAmount = totalWavesAmount + uint64(GetAvailableBalanceInWavesGo(suite, address)) + } + return totalWavesAmount +} + +func GetTotalWavesAmountScala(suite *f.BaseSuite) uint64 { + var totalWavesAmount uint64 + addresses := GetAddressesOfAvailableAccounts(suite) + for _, address := range addresses { + totalWavesAmount = totalWavesAmount + uint64(GetAvailableBalanceInWavesScala(suite, address)) + } + return totalWavesAmount +} + +func GetTotalWavesAmount(suite *f.BaseSuite) uint64 { + var totalWavesAmount uint64 + totalWavesAmountGo := GetTotalWavesAmountGo(suite) + totalWavesAmountScala := GetTotalWavesAmountScala(suite) + if totalWavesAmountGo == totalWavesAmountScala { + totalWavesAmount = totalWavesAmountGo + } + return totalWavesAmount +} + func MustGetAccountByAddress(suite *f.BaseSuite, address proto.WavesAddress) config.AccountInfo { for _, account := range suite.Cfg.Accounts { if account.Address.Equal(address) { @@ -423,8 +469,7 @@ func getFeatureBlockchainStatus(statusResponse *g.ActivationStatusResponse, fID return status, err } -func getFeatureActivationHeight(statusResponse *g.ActivationStatusResponse, featureID settings.Feature) (int32, error) { - var err error +func getFeatureActivationHeight(statusResponse *g.ActivationStatusResponse, featureID settings.Feature) int32 { var activationHeight int32 activationHeight = -1 for _, feature := range statusResponse.GetFeatures() { @@ -433,10 +478,7 @@ func getFeatureActivationHeight(statusResponse *g.ActivationStatusResponse, feat break } } - if activationHeight == -1 { - err = errors.Errorf("Feature with Id %d not found", featureID) - } - return activationHeight, err + return activationHeight } func GetFeatureBlockchainStatusGo(suite *f.BaseSuite, featureID settings.Feature, h uint64) string { @@ -454,32 +496,37 @@ func GetFeatureBlockchainStatusScala(suite *f.BaseSuite, featureID settings.Feat } func GetFeatureActivationHeightGo(suite *f.BaseSuite, featureID settings.Feature, height uint64) int32 { - activationHeight, err := getFeatureActivationHeight(GetActivationFeaturesStatusInfoGo(suite, height), featureID) - require.NoError(suite.T(), err) - return activationHeight + return getFeatureActivationHeight(GetActivationFeaturesStatusInfoGo(suite, height), featureID) } func GetFeatureActivationHeightScala(suite *f.BaseSuite, featureID settings.Feature, height uint64) int32 { - activationHeight, err := getFeatureActivationHeight(GetActivationFeaturesStatusInfoScala(suite, height), featureID) - require.NoError(suite.T(), err) - return activationHeight + return getFeatureActivationHeight(GetActivationFeaturesStatusInfoScala(suite, height), featureID) } func GetFeatureActivationHeight(suite *f.BaseSuite, featureID settings.Feature, height uint64) int32 { var err error var activationHeight int32 - activationHeight = -1 activationHeightGo := GetFeatureActivationHeightGo(suite, featureID, height) activationHeightScala := GetFeatureActivationHeightScala(suite, featureID, height) if activationHeightGo == activationHeightScala && activationHeightGo > -1 { activationHeight = activationHeightGo } else { - err = errors.New("Activation Height from Go and Scala is different") + err = errors.New("Activation Height from Go and Scala is different or feature not found") } require.NoError(suite.T(), err) return activationHeight } +func isFeatureActivated(suite *f.BaseSuite, featureID settings.Feature, height uint64) bool { + isActivated := false + hGo := GetFeatureActivationHeightGo(suite, featureID, height) + hScala := GetFeatureActivationHeightScala(suite, featureID, height) + if hGo > -1 && hScala > -1 { + isActivated = true + } + return isActivated +} + func GetFeatureBlockchainStatus(suite *f.BaseSuite, featureID settings.Feature, height uint64) (string, error) { var status string var err error @@ -819,44 +866,72 @@ func GetRewardTermAfter20Cfg(suite *f.BaseSuite) uint64 { return suite.Cfg.BlockchainSettings.BlockRewardTermAfter20 } -// GetRewards get response from /blockchain/rewards. -func GetRewardsGo(suite *f.BaseSuite) *client.RewardInfo { +func GetIncrementCfg(suite *f.BaseSuite) uint64 { + return suite.Cfg.BlockchainSettings.BlockRewardIncrement +} + +func GetVotingIntervalCfg(suite *f.BaseSuite) uint64 { + return suite.Cfg.BlockchainSettings.BlockRewardVotingPeriod +} + +// GetRewardsInfo get response from /blockchain/rewards. +func GetRewardsInfoGo(suite *f.BaseSuite) *client.RewardInfo { return suite.Clients.GoClients.HttpClient.Rewards(suite.T()) } -func GetRewardsScala(suite *f.BaseSuite) *client.RewardInfo { +func GetCurrentRewardGo(suite *f.BaseSuite) uint64 { + return GetRewardsInfoGo(suite).CurrentReward +} + +func GetRewardsInfoScala(suite *f.BaseSuite) *client.RewardInfo { return suite.Clients.ScalaClients.HttpClient.Rewards(suite.T()) } -func GetRewards(suite *f.BaseSuite) (*client.RewardInfo, *client.RewardInfo) { - return GetRewardsGo(suite), GetRewardsScala(suite) +func GetCurrentRewardScala(suite *f.BaseSuite) uint64 { + return GetRewardsInfoScala(suite).CurrentReward } -// GetRewards get response from /blockchain/rewards/{height}. -func GetRewardsAtHeightGo(suite *f.BaseSuite, height uint64) *client.RewardInfo { +func GetRewardsInfo(suite *f.BaseSuite) (*client.RewardInfo, *client.RewardInfo) { + return GetRewardsInfoGo(suite), GetRewardsInfoScala(suite) +} + +func GetCurrentReward(suite *f.BaseSuite) uint64 { + var currentReward uint64 + currentRewardGo := GetCurrentRewardGo(suite) + currentRewardScala := GetCurrentRewardScala(suite) + if currentRewardGo == currentRewardScala { + currentReward = currentRewardGo + } else { + suite.FailNow("Current reward is different") + } + return currentReward +} + +// GetRewardsInfo get response from /blockchain/rewards/{height}. +func GetRewardsInfoAtHeightGo(suite *f.BaseSuite, height uint64) *client.RewardInfo { return suite.Clients.GoClients.HttpClient.RewardsAtHeight(suite.T(), height) } -func GetRewardsAtHeightScala(suite *f.BaseSuite, height uint64) *client.RewardInfo { +func GetRewardsInfoAtHeightScala(suite *f.BaseSuite, height uint64) *client.RewardInfo { return suite.Clients.ScalaClients.HttpClient.RewardsAtHeight(suite.T(), height) } -func GetRewardsAtHeight(suite *f.BaseSuite, height uint64) (*client.RewardInfo, *client.RewardInfo) { - return GetRewardsAtHeightGo(suite, height), GetRewardsAtHeightScala(suite, height) +func GetRewardsInfoAtHeight(suite *f.BaseSuite, height uint64) (*client.RewardInfo, *client.RewardInfo) { + return GetRewardsInfoAtHeightGo(suite, height), GetRewardsInfoAtHeightScala(suite, height) } -func GetCurrentRewardGo(suite *f.BaseSuite, height uint64) uint64 { +func GetCurrentRewardAtHeightGo(suite *f.BaseSuite, height uint64) uint64 { return suite.Clients.GoClients.HttpClient.RewardsAtHeight(suite.T(), height).CurrentReward } -func GetCurrentRewardScala(suite *f.BaseSuite, height uint64) uint64 { +func GetCurrentRewardAtHeightScala(suite *f.BaseSuite, height uint64) uint64 { return suite.Clients.ScalaClients.HttpClient.RewardsAtHeight(suite.T(), height).CurrentReward } -func GetCurrentReward(suite *f.BaseSuite, height uint64) uint64 { +func GetCurrentRewardAtHeight(suite *f.BaseSuite, height uint64) uint64 { var currentReward uint64 - currentRewardGo := GetCurrentRewardGo(suite, height) - currentRewardScala := GetCurrentRewardScala(suite, height) + currentRewardGo := GetCurrentRewardAtHeightGo(suite, height) + currentRewardScala := GetCurrentRewardAtHeightScala(suite, height) if currentRewardGo == currentRewardScala { currentReward = currentRewardGo } else { @@ -866,11 +941,11 @@ func GetCurrentReward(suite *f.BaseSuite, height uint64) uint64 { } func GetRewardTermAtHeightGo(suite *f.BaseSuite, height uint64) uint64 { - return GetRewardsAtHeightGo(suite, height).Term + return GetRewardsInfoAtHeightGo(suite, height).Term } func GetRewardTermAtHeightScala(suite *f.BaseSuite, height uint64) uint64 { - return GetRewardsAtHeightScala(suite, height).Term + return GetRewardsInfoAtHeightScala(suite, height).Term } func GetRewardTermAtHeight(suite *f.BaseSuite, height uint64) RewardTerm { @@ -881,6 +956,22 @@ func GetRewardTermAtHeight(suite *f.BaseSuite, height uint64) RewardTerm { return NewRewardTerm(termGo, termScala) } +func GetDaoAndXtnAddresses(suite *f.BaseSuite) (*proto.WavesAddress, *proto.WavesAddress) { + var daoAddress, xtnAddress *proto.WavesAddress + isBlockRewardDistributionActivated := isFeatureActivated(suite, settings.BlockRewardDistribution, GetHeight(suite)) + isXtnBuybackCessationActivated := isFeatureActivated(suite, settings.XTNBuyBackCessation, GetHeight(suite)) + currentRewardAddresses := suite.Cfg.BlockchainSettings.CurrentRewardAddresses(isXtnBuybackCessationActivated) + if isBlockRewardDistributionActivated && len(currentRewardAddresses) > 0 { + if dao, ok := suite.Cfg.BlockchainSettings.DAOAddress(isXtnBuybackCessationActivated); ok { + daoAddress = &dao + } + if xtn, ok := suite.Cfg.BlockchainSettings.XTNBuybackAddress(isXtnBuybackCessationActivated); ok { + xtnAddress = &xtn + } + } + return daoAddress, xtnAddress +} + type RewardTerm struct { TermGo uint64 TermScala uint64 @@ -893,6 +984,10 @@ func NewRewardTerm(termGo, termScala uint64) RewardTerm { } } +func GetVotes(suite *f.BaseSuite) { + +} + func GetXtnBuybackPeriodCfg(suite *f.BaseSuite) uint64 { return suite.Cfg.BlockchainSettings.MinXTNBuyBackPeriod } diff --git a/itests/utilities/reward/reward.go b/itests/utilities/reward/reward.go index 4e7835eee..f24092ea1 100644 --- a/itests/utilities/reward/reward.go +++ b/itests/utilities/reward/reward.go @@ -6,7 +6,7 @@ import ( utl "github.com/wavesplatform/gowaves/itests/utilities" ) -func getAddressesBalances(suite *f.BaseSuite, +func getAddressesWavesBalances(suite *f.BaseSuite, addresses testdata.AddressesForDistribution) (utl.BalanceInWaves, utl.BalanceInWaves, utl.BalanceInWaves) { var balanceMiner1Go, balanceMiner1Scala, balanceMiner2Go, balanceMiner2Scala, balanceDaoGo, balanceDaoScala, balanceXtnGo, balanceXtnScala int64 @@ -66,13 +66,13 @@ func GetBlockRewardDistribution(suite *f.BaseSuite, addresses testdata.Addresses // Get balances in waves before block applied. suite.T().Log("Balances before applied block: ") initHeight := utl.GetHeight(suite) - initSumMinersBalance, initDaoBalance, initXtnBalance := getAddressesBalances(suite, addresses) + initSumMinersBalance, initDaoBalance, initXtnBalance := getAddressesWavesBalances(suite, addresses) // Wait for 1 block. utl.WaitForNewHeight(suite) // Get balances after block applied. suite.T().Log("Balances after applied block: ") currentHeight := utl.GetHeight(suite) - currentSumMinersBalance, currentDaoBalance, currentXtnBalance := getAddressesBalances(suite, addresses) + currentSumMinersBalance, currentDaoBalance, currentXtnBalance := getAddressesWavesBalances(suite, addresses) term := utl.GetRewardTermAtHeight(suite, currentHeight) // Get diff balances. suite.T().Log("Diff Balances: ") @@ -106,20 +106,38 @@ func GetRewardDistributionAndChecks(suite *f.BaseSuite, addresses testdata.Addre rewardDistributions.XTNBuyBackDiffBalance.BalanceInWavesScala) } -func GetRewardInfoAndChecks(suite *f.BaseSuite, - td testdata.RewardDistributionApiTestData[testdata.RewardInfoApiExpectedValues]) { - rewardInfoGo, rewardInfoScala := utl.GetRewards(suite) +type GetTestDataForRewardInfo func(suite *f.BaseSuite) testdata.RewardDistributionApiTestData[testdata.RewardInfoApiExpectedValues] + +func GetRewardInfoAndChecks(suite *f.BaseSuite, testdata GetTestDataForRewardInfo) { + rewardInfoGo, rewardInfoScala := utl.GetRewardsInfo(suite) + td := testdata(suite) + utl.TotalWavesAmountCheck(suite.T(), td.Expected.TotalWavesAmount, rewardInfoGo.TotalWavesAmount, + rewardInfoScala.TotalWavesAmount) + utl.MinIncrementCheck(suite.T(), td.Expected.MinIncrement, rewardInfoGo.MinIncrement, rewardInfoScala.MinIncrement) utl.TermCheck(suite.T(), td.Expected.Term, rewardInfoGo.Term, rewardInfoScala.Term) utl.NextCheckParameterCheck(suite.T(), td.Expected.NextCheck, rewardInfoGo.NextCheck, rewardInfoScala.NextCheck) utl.VotingIntervalStartCheck(suite.T(), td.Expected.VotingIntervalStart, rewardInfoGo.VotingIntervalStart, rewardInfoScala.VotingIntervalStart) + utl.VotingIntervalCheck(suite.T(), td.Expected.VotingInterval, rewardInfoGo.VotingInterval, + rewardInfoScala.VotingInterval) + utl.VotesCheck(suite.T(), td.Expected.Votes.Increase, rewardInfoGo.Votes.Increase, rewardInfoScala.Votes.Increase) + utl.DaoAddressCheck(suite.T(), td.Expected.DaoAddress, rewardInfoGo.DAOAddress, rewardInfoScala.DAOAddress) + utl.XtnAddressCheck(suite.T(), td.Expected.XtnAddress, rewardInfoGo.XTNBuybackAddress, + rewardInfoScala.XTNBuybackAddress) } -func GetRewardInfoAtHeightAndChecks(suite *f.BaseSuite, - td testdata.RewardDistributionApiTestData[testdata.RewardInfoApiExpectedValues], height uint64) { - rewardInfoGo, rewardInfoScala := utl.GetRewardsAtHeight(suite, height) +func GetRewardInfoAtHeightAndChecks(suite *f.BaseSuite, testdata GetTestDataForRewardInfo, height uint64) { + rewardInfoGo, rewardInfoScala := utl.GetRewardsInfoAtHeight(suite, height) + td := testdata(suite) + utl.MinIncrementCheck(suite.T(), td.Expected.MinIncrement, rewardInfoGo.MinIncrement, rewardInfoScala.MinIncrement) utl.TermCheck(suite.T(), td.Expected.Term, rewardInfoGo.Term, rewardInfoScala.Term) utl.NextCheckParameterCheck(suite.T(), td.Expected.NextCheck, rewardInfoGo.NextCheck, rewardInfoScala.NextCheck) utl.VotingIntervalStartCheck(suite.T(), td.Expected.VotingIntervalStart, rewardInfoGo.VotingIntervalStart, rewardInfoScala.VotingIntervalStart) + utl.VotingIntervalCheck(suite.T(), td.Expected.VotingInterval, rewardInfoGo.VotingInterval, + rewardInfoScala.VotingInterval) + utl.VotesCheck(suite.T(), td.Expected.Votes.Increase, rewardInfoGo.Votes.Increase, rewardInfoScala.Votes.Increase) + utl.DaoAddressCheck(suite.T(), td.Expected.DaoAddress, rewardInfoGo.DAOAddress, rewardInfoScala.DAOAddress) + utl.XtnAddressCheck(suite.T(), td.Expected.XtnAddress, rewardInfoGo.XTNBuybackAddress, + rewardInfoScala.XTNBuybackAddress) } From 21553e7e69a7a78534263eaf492c7a22a97a6191 Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Mon, 11 Mar 2024 17:49:01 +0300 Subject: [PATCH 2/7] Fix warnings. --- itests/utilities/common.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/itests/utilities/common.go b/itests/utilities/common.go index 17c20ad0d..bd453f84e 100644 --- a/itests/utilities/common.go +++ b/itests/utilities/common.go @@ -895,18 +895,6 @@ func GetRewardsInfo(suite *f.BaseSuite) (*client.RewardInfo, *client.RewardInfo) return GetRewardsInfoGo(suite), GetRewardsInfoScala(suite) } -func GetCurrentReward(suite *f.BaseSuite) uint64 { - var currentReward uint64 - currentRewardGo := GetCurrentRewardGo(suite) - currentRewardScala := GetCurrentRewardScala(suite) - if currentRewardGo == currentRewardScala { - currentReward = currentRewardGo - } else { - suite.FailNow("Current reward is different") - } - return currentReward -} - // GetRewardsInfo get response from /blockchain/rewards/{height}. func GetRewardsInfoAtHeightGo(suite *f.BaseSuite, height uint64) *client.RewardInfo { return suite.Clients.GoClients.HttpClient.RewardsAtHeight(suite.T(), height) @@ -984,10 +972,6 @@ func NewRewardTerm(termGo, termScala uint64) RewardTerm { } } -func GetVotes(suite *f.BaseSuite) { - -} - func GetXtnBuybackPeriodCfg(suite *f.BaseSuite) uint64 { return suite.Cfg.BlockchainSettings.MinXTNBuyBackPeriod } From 5b0f631a8ebd0026fc332ce91d79a2b37c957632 Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Mon, 11 Mar 2024 17:49:52 +0300 Subject: [PATCH 3/7] Fix warnings. --- itests/utilities/common.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/itests/utilities/common.go b/itests/utilities/common.go index bd453f84e..181209e3c 100644 --- a/itests/utilities/common.go +++ b/itests/utilities/common.go @@ -879,18 +879,10 @@ func GetRewardsInfoGo(suite *f.BaseSuite) *client.RewardInfo { return suite.Clients.GoClients.HttpClient.Rewards(suite.T()) } -func GetCurrentRewardGo(suite *f.BaseSuite) uint64 { - return GetRewardsInfoGo(suite).CurrentReward -} - func GetRewardsInfoScala(suite *f.BaseSuite) *client.RewardInfo { return suite.Clients.ScalaClients.HttpClient.Rewards(suite.T()) } -func GetCurrentRewardScala(suite *f.BaseSuite) uint64 { - return GetRewardsInfoScala(suite).CurrentReward -} - func GetRewardsInfo(suite *f.BaseSuite) (*client.RewardInfo, *client.RewardInfo) { return GetRewardsInfoGo(suite), GetRewardsInfoScala(suite) } From e06c62364885f995bdcb2bddcdb43affdd86688b Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Mon, 11 Mar 2024 18:56:45 +0300 Subject: [PATCH 4/7] Fix lint issues. --- itests/utilities/common.go | 4 ++-- itests/utilities/reward/reward.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/itests/utilities/common.go b/itests/utilities/common.go index 181209e3c..2bc6136f1 100644 --- a/itests/utilities/common.go +++ b/itests/utilities/common.go @@ -340,7 +340,7 @@ func GetTotalWavesAmountGo(suite *f.BaseSuite) uint64 { var totalWavesAmount uint64 addresses := GetAddressesOfAvailableAccounts(suite) for _, address := range addresses { - totalWavesAmount = totalWavesAmount + uint64(GetAvailableBalanceInWavesGo(suite, address)) + totalWavesAmount += uint64(GetAvailableBalanceInWavesGo(suite, address)) } return totalWavesAmount } @@ -349,7 +349,7 @@ func GetTotalWavesAmountScala(suite *f.BaseSuite) uint64 { var totalWavesAmount uint64 addresses := GetAddressesOfAvailableAccounts(suite) for _, address := range addresses { - totalWavesAmount = totalWavesAmount + uint64(GetAvailableBalanceInWavesScala(suite, address)) + totalWavesAmount += uint64(GetAvailableBalanceInWavesScala(suite, address)) } return totalWavesAmount } diff --git a/itests/utilities/reward/reward.go b/itests/utilities/reward/reward.go index f24092ea1..ca0914f25 100644 --- a/itests/utilities/reward/reward.go +++ b/itests/utilities/reward/reward.go @@ -106,7 +106,8 @@ func GetRewardDistributionAndChecks(suite *f.BaseSuite, addresses testdata.Addre rewardDistributions.XTNBuyBackDiffBalance.BalanceInWavesScala) } -type GetTestDataForRewardInfo func(suite *f.BaseSuite) testdata.RewardDistributionApiTestData[testdata.RewardInfoApiExpectedValues] +type GetTestDataForRewardInfo func( + suite *f.BaseSuite) testdata.RewardDistributionApiTestData[testdata.RewardInfoApiExpectedValues] func GetRewardInfoAndChecks(suite *f.BaseSuite, testdata GetTestDataForRewardInfo) { rewardInfoGo, rewardInfoScala := utl.GetRewardsInfo(suite) From 0cf20535f89388c1352f03893b4f760c9edc4b65 Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Mon, 11 Mar 2024 19:41:31 +0300 Subject: [PATCH 5/7] Fix lint issues. --- itests/utilities/assertions.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/itests/utilities/assertions.go b/itests/utilities/assertions.go index 05b16514f..17efeeac6 100644 --- a/itests/utilities/assertions.go +++ b/itests/utilities/assertions.go @@ -2,9 +2,10 @@ package utilities import ( "fmt" - "github.com/wavesplatform/gowaves/pkg/proto" "testing" + "github.com/wavesplatform/gowaves/pkg/proto" + "github.com/stretchr/testify/assert" ) From 89db8a7e6336c45ab38a98f13cdd0abe934baa1c Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Tue, 12 Mar 2024 10:10:40 +0300 Subject: [PATCH 6/7] Add total waves amount check for reward info at height. --- itests/utilities/reward/reward.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/itests/utilities/reward/reward.go b/itests/utilities/reward/reward.go index ca0914f25..e9736b443 100644 --- a/itests/utilities/reward/reward.go +++ b/itests/utilities/reward/reward.go @@ -130,6 +130,8 @@ func GetRewardInfoAndChecks(suite *f.BaseSuite, testdata GetTestDataForRewardInf func GetRewardInfoAtHeightAndChecks(suite *f.BaseSuite, testdata GetTestDataForRewardInfo, height uint64) { rewardInfoGo, rewardInfoScala := utl.GetRewardsInfoAtHeight(suite, height) td := testdata(suite) + utl.TotalWavesAmountCheck(suite.T(), td.Expected.TotalWavesAmount, rewardInfoGo.TotalWavesAmount, + rewardInfoScala.TotalWavesAmount) utl.MinIncrementCheck(suite.T(), td.Expected.MinIncrement, rewardInfoGo.MinIncrement, rewardInfoScala.MinIncrement) utl.TermCheck(suite.T(), td.Expected.Term, rewardInfoGo.Term, rewardInfoScala.Term) utl.NextCheckParameterCheck(suite.T(), td.Expected.NextCheck, rewardInfoGo.NextCheck, rewardInfoScala.NextCheck) From 434b99f44470e9fc505202a6d462e7bd97566131 Mon Sep 17 00:00:00 2001 From: irina-pereiaslavskaia Date: Tue, 12 Mar 2024 17:17:43 +0300 Subject: [PATCH 7/7] Add error message. --- itests/utilities/common.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/itests/utilities/common.go b/itests/utilities/common.go index 2bc6136f1..ba763ab57 100644 --- a/itests/utilities/common.go +++ b/itests/utilities/common.go @@ -358,8 +358,9 @@ func GetTotalWavesAmount(suite *f.BaseSuite) uint64 { var totalWavesAmount uint64 totalWavesAmountGo := GetTotalWavesAmountGo(suite) totalWavesAmountScala := GetTotalWavesAmountScala(suite) - if totalWavesAmountGo == totalWavesAmountScala { - totalWavesAmount = totalWavesAmountGo + totalWavesAmount = totalWavesAmountScala + if totalWavesAmountGo != totalWavesAmountScala { + require.FailNow(suite.T(), "total Waves amount Go and total Waves amount Scala are not equal") } return totalWavesAmount }