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

Drop Pending Stakers 4 - minimal UT infra cleanup #2332

Merged
merged 173 commits into from
Dec 15, 2023

Conversation

abi87
Copy link
Contributor

@abi87 abi87 commented Nov 17, 2023

Why this should be merged

P-chain UT are not great, especially when it comes to testing forks. There is a whole PRs thread that addresses the issue (see #2453). This PR does the bare minumim to allow testing of Drop pending in Durango fork

How this works

Mostly is editing test environments constructors to explicitly set the fork we target in the test and a sensible fork time (that respects forks ordering at the very least). Test environment are some UT helper structs that acts as a vm in packages where we cannot reference platformvm.VM (due to import cycles)

How this was tested

This is just fixing some UTs.

@@ -36,7 +36,7 @@ func TestBoundedBy(t *testing.T) {
End: bEndTime,
Wght: defaultWeight,
}
require.False(BoundedBy(a.StartTime(), b.EndTime(), b.StartTime(), b.EndTime()))
require.False(BoundedBy(a.StartTime(), a.EndTime(), b.StartTime(), b.EndTime()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a test fix

@abi87 abi87 self-assigned this Nov 17, 2023
Base automatically changed from post_durango_startTime_storing to dev December 14, 2023 18:57
@abi87 abi87 requested a review from marun December 14, 2023 21:19
Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits and suggestions only.

vms/platformvm/service_test.go Show resolved Hide resolved
@@ -691,8 +697,8 @@ func TestGetCurrentValidators(t *testing.T) {
require.Len(*innerVdr.Delegators, 1)
delegator := (*innerVdr.Delegators)[0]
require.Equal(delegator.NodeID, innerVdr.NodeID)
require.Equal(uint64(delegator.StartTime), delegatorStartTime)
require.Equal(uint64(delegator.EndTime), delegatorEndTime)
require.Equal(int64(delegator.StartTime), delegatorStartTime.Unix())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(No action required) Maybe call Unix() where these are defined rather than at each point of use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's annoying but I use delegatorStartTime as time.Time too, so can't redefine it as uint64

Copy link
Contributor

@marun marun Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you talking about for Add? Because adding (or comparing) seconds doesn't require a time type.

vms/platformvm/txs/executor/staker_tx_verification_test.go Outdated Show resolved Hide resolved
vms/platformvm/txs/executor/staker_tx_verification_test.go Outdated Show resolved Hide resolved
vms/platformvm/vm_regression_test.go Show resolved Hide resolved
vms/platformvm/vm_test.go Outdated Show resolved Hide resolved
vms/platformvm/vm_test.go Outdated Show resolved Hide resolved
vms/platformvm/vm_test.go Outdated Show resolved Hide resolved
vms/platformvm/txs/executor/helpers_test.go Outdated Show resolved Hide resolved
vms/platformvm/txs/executor/staker_tx_verification_test.go Outdated Show resolved Hide resolved
vms/platformvm/txs/executor/staker_tx_verification_test.go Outdated Show resolved Hide resolved
vms/platformvm/txs/executor/staker_tx_verification_test.go Outdated Show resolved Hide resolved
vms/platformvm/vm_test.go Outdated Show resolved Hide resolved
Comment on lines 412 to 417
balance := defaultBalance
if idx == 0 {
// we use the first key to fund a subnet creation in [defaultGenesis].
// As such we need to account for the subnet creation fee
balance = defaultBalance - service.vm.Config.GetCreateBlockchainTxFee(service.vm.clock.Time())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because the prior fee was 0 - now this test runs with a CreateSubnetTx fee that is non-0.

vms/platformvm/txs/executor/helpers_test.go Outdated Show resolved Hide resolved
@StephenButtolph StephenButtolph added this pull request to the merge queue Dec 15, 2023
Merged via the queue into dev with commit 5ce35ce Dec 15, 2023
17 checks passed
@StephenButtolph StephenButtolph deleted the post_durango_minimal_test_infra branch December 15, 2023 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Durango durango fork
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Drop Pending Stakers
5 participants