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

chore: refactor op e2e tests - part 6 #186

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Changes from all commits
Commits
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
36 changes: 36 additions & 0 deletions itest/opstackl2/op_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,39 @@ func TestFinalitySigSubmission(t *testing.T) {
require.Equal(t, 1, len(voters))
require.Equal(t, consumerFpPk.MarshalHex(), voters[0])
}

// TestFinalityProviderHasPower tests the consumer controller's function:
// - QueryFinalityProviderHasPower
func TestFinalityProviderHasPower(t *testing.T) {
ctm := StartOpL2ConsumerManager(t)
defer ctm.Stop(t)

// create and register Babylon FP and OP consumer FP
fps := ctm.setupBabylonAndConsumerFp(t)
consumerFpPk := fps[1]

// query the finality provider has power
hasPower, err := ctm.OpConsumerController.QueryFinalityProviderHasPower(consumerFpPk.MustToBTCPK(), 1)
require.NoError(t, err)
require.False(t, hasPower)

// send a BTC delegation and wait for activation
ctm.delegateBTCAndWaitForActivation(t, fps[0], consumerFpPk)

// query the finality provider has power again
// fp has 0 voting power b/c there is no public randomness at this height
hasPower, err = ctm.OpConsumerController.QueryFinalityProviderHasPower(consumerFpPk.MustToBTCPK(), 1)
require.NoError(t, err)
require.False(t, hasPower)

// commit pub rand with start height 1
consumerFpInstance := ctm.getConsumerFpInstance(t, consumerFpPk)
_, err = consumerFpInstance.CommitPubRand(1)
require.NoError(t, err)

// query the finality provider has power again
// fp has voting power now
hasPower, err = ctm.OpConsumerController.QueryFinalityProviderHasPower(consumerFpPk.MustToBTCPK(), 1)
require.NoError(t, err)
require.True(t, hasPower)
}
Loading