-
Notifications
You must be signed in to change notification settings - Fork 215
Integration test rewards Andromeda #6875
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
Conversation
| defaultPathToInitialConfig = "../../../cmd/node/config/" | ||
| ) | ||
|
|
||
| func TestRewardsTxsAfterEquivalentMessages(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we consider this a long test as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, changed
| ApiInterface: api.NewNoApiInterface(), | ||
| MinNodesPerShard: 3, | ||
| MetaChainMinNodes: 3, | ||
| AlterConfigsFunction: func(cfg *config.Configs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove new line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
| for i := 0; i < targetEpoch; i++ { | ||
| if i == 8 { | ||
| fmt.Println("here") | ||
| } | ||
| err = cs.ForceChangeOfEpoch() | ||
| require.Nil(t, err) | ||
| } | ||
|
|
||
| err = cs.GenerateBlocks(210) | ||
| require.Nil(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed? or GenerateBlocksUntilEpochIsReached can be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use that function, more blocks will be generated until I reach epoch 9, with this method, only 30 blocks are generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove
if i == 8 {
fmt.Println("here")
}| nodesSetupFile := path.Join(tempDir, "config", "nodesSetup.json") | ||
| validators, err := readValidatorsAndOwners(nodesSetupFile) | ||
| require.Nil(t, err) | ||
| fmt.Println(validators) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, removed
| rewardsPerShard[shardID] = big.NewInt(0) | ||
| } | ||
|
|
||
| valueBig, okR := rewardsPerShard[shardID].SetString(tx.Value, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| valueBig, okR := rewardsPerShard[shardID].SetString(tx.Value, 10) | |
| valueBig, okR := big.NewInt(0).SetString(tx.Value, 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise it will also set rewardsPerShard[shardID]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| } | ||
|
|
||
| func allValuesEqual(m map[uint32]*big.Int) bool { | ||
| var firstValue *big.Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use m[0] as expectedValue instead of these 2 variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
| } | ||
|
|
||
| func (s *simulator) addProofs() { | ||
| proofs := make([]*block.HeaderProof, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| proofs := make([]*block.HeaderProof, 0) | |
| proofs := make([]*block.HeaderProof, 0, len(s.nodes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
|
|
||
| for _, proof := range proofs { | ||
| s.GetNodeHandler(core.MetachainShardId).GetDataComponents().Datapool().Proofs().AddProof(proof) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract s.GetNodeHandler(core.MetachainShardId).GetDataComponents().Datapool().Proofs() outside of the for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| for i := 0; i < targetEpoch; i++ { | ||
| if i == 8 { | ||
| fmt.Println("here") | ||
| } | ||
| err = cs.ForceChangeOfEpoch() | ||
| require.Nil(t, err) | ||
| } | ||
|
|
||
| err = cs.GenerateBlocks(210) | ||
| require.Nil(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove
if i == 8 {
fmt.Println("here")
}| func allValuesEqual(m map[uint32]*big.Int) bool { | ||
| if len(m) == 0 { | ||
| return true | ||
| } | ||
|
|
||
| var firstValue *big.Int | ||
| for _, v := range m { | ||
| if firstValue == nil { | ||
| firstValue = v | ||
| continue | ||
| } | ||
| if firstValue.Cmp(v) != 0 { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func allValuesEqual(m map[uint32]*big.Int) bool { | |
| if len(m) == 0 { | |
| return true | |
| } | |
| var firstValue *big.Int | |
| for _, v := range m { | |
| if firstValue == nil { | |
| firstValue = v | |
| continue | |
| } | |
| if firstValue.Cmp(v) != 0 { | |
| return false | |
| } | |
| } | |
| return true | |
| } | |
| func allValuesEqual(m map[uint32]*big.Int) bool { | |
| if len(m) == 0 { | |
| return true | |
| } | |
| expectedValue := m[0] | |
| for _, v := range m { | |
| if expectedValue.Cmp(v) != 0 { | |
| return false | |
| } | |
| } | |
| return true | |
| } |
this was my initial suggestion, assuming we always have a shard 0
Reasoning behind the pull request
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?