-
Notifications
You must be signed in to change notification settings - Fork 673
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
Remove duplicate genesis creations in P-chain unit tests #3318
Conversation
// Staker2's end time matches staker5's start time, so typically | ||
// the block builder would produce a ProposalBlock to remove | ||
// staker2 when advancing the time. However, this test injects | ||
// staker0 into the staker set artificially to advance the time. | ||
// This means that staker2 is not removed by the ProposalBlock | ||
// when advancing the time. |
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.
This comment is describing that the behavior of this test makes assumptions on the hash ordering of txID
for staker0
and staker2
. This is not useful to test as it is currently written imo, so decided to remove it.
@@ -137,7 +138,7 @@ func TestRewardValidatorTxExecuteOnCommit(t *testing.T) { | |||
|
|||
onCommitBalance, err := avax.GetBalance(env.state, stakeOwners) | |||
require.NoError(err) | |||
require.Equal(oldBalance+stakerToRemove.Weight+27697, onCommitBalance) | |||
require.Equal(oldBalance+stakerToRemove.Weight+38944, onCommitBalance) |
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.
This is a terrible test. But out-of-scope for this PR.
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 action required) What does this magic number signify?
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.
This magic number is signifying the staking rewards that the genesis validator will receive. The reason this number changes is because the genesis staking duration was increased from 20
days to 28
days (because 28
days was used in most other places)
@@ -754,71 +750,3 @@ func buildVM(t *testing.T) (*VM, ids.ID, error) { | |||
|
|||
return vm, testSubnet1.ID(), nil | |||
} | |||
|
|||
func buildCustomGenesis(avaxAssetID ids.ID) ([]byte, error) { |
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.
1
// Returns: | ||
// 1) The genesis state | ||
// 2) The byte representation of the default genesis for tests | ||
func defaultGenesis(t *testing.T, avaxAssetID ids.ID) (*api.BuildGenesisArgs, []byte) { |
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.
2
@@ -342,60 +320,3 @@ func defaultFx(t *testing.T, clk *mockable.Clock, log logging.Logger, isBootstra | |||
} | |||
return res | |||
} | |||
|
|||
func buildGenesisTest(t *testing.T, ctx *snow.Context) []byte { |
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.
3
@@ -372,69 +347,6 @@ func defaultFx(clk *mockable.Clock, log logging.Logger, isBootstrapped bool) fx. | |||
return res | |||
} | |||
|
|||
func buildGenesisTest(ctx *snow.Context) []byte { |
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.
4
@@ -322,66 +302,3 @@ func defaultFx(clk *mockable.Clock, log logging.Logger, isBootstrapped bool) fx. | |||
} | |||
return res | |||
} | |||
|
|||
func buildGenesisTest(ctx *snow.Context) []byte { |
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.
5
|
||
buildGenesisResponse := api.BuildGenesisReply{} | ||
platformvmSS := api.StaticService{} | ||
require.NoError(platformvmSS.BuildGenesis(nil, &buildGenesisArgs, &buildGenesisResponse)) |
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.
6
Why this should be merged
There are currently 6 instances of the same (slightly modified) piece of code. This unifies all of them with the
genesistest.New
function.How this works
How this was tested