diff --git a/test/e2e/btc_rewards_distribution_e2e_test.go b/test/e2e/btc_rewards_distribution_e2e_test.go index 87faaa87..04e31b1c 100644 --- a/test/e2e/btc_rewards_distribution_e2e_test.go +++ b/test/e2e/btc_rewards_distribution_e2e_test.go @@ -11,6 +11,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" + "github.com/cometbft/cometbft/libs/bytes" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -354,6 +355,8 @@ func (s *BtcRewardsDistribution) Test6ActiveLastDelegation() { // fp2Del2 s.CreateBTCDelegationAndCheck(n2, wDel2, s.fp2, s.del2BTCSK, s.del2Addr, s.fp2Del2StakingAmt) + s.AddFinalityVote() + allDelegations := n2.QueryFinalityProvidersDelegations(s.fp1.BtcPk.MarshalHex(), s.fp2.BtcPk.MarshalHex()) s.Equal(len(allDelegations), 4) @@ -374,6 +377,8 @@ func (s *BtcRewardsDistribution) Test6ActiveLastDelegation() { // wait for a block so that above txs take effect n1.WaitForNextBlock() + s.AddFinalityVote() + // ensure the BTC delegation has covenant sigs now allDelegations = n1.QueryFinalityProvidersDelegations(s.fp1.BtcPk.MarshalHex(), s.fp2.BtcPk.MarshalHex()) s.Len(allDelegations, 4) @@ -397,11 +402,10 @@ func (s *BtcRewardsDistribution) Test7FinalityVoteBlock() { n1, err := chainA.GetNodeAtIndex(1) s.NoError(err) - lastFinalizedEpoch, err := n1.QueryLastFinalizedEpoch() - s.NoError(err) - lastFinalizedEpoch++ - - n1.WaitUntilCurrentEpochIsSealedAndFinalized(lastFinalizedEpoch) + // lastFinalizedEpoch, err := n1.QueryLastFinalizedEpoch() + // s.NoError(err) + // lastFinalizedEpoch++ + // n1.WaitUntilCurrentEpochIsSealedAndFinalized(lastFinalizedEpoch) // submit finality signature s.finalityIdx++ @@ -508,6 +512,37 @@ func (s *BtcRewardsDistribution) Test8CheckRewards() { // TODO(rafilx): Slash a FP and expect rewards to be withdraw. +func (s *BtcRewardsDistribution) AddFinalityVote() (appHash bytes.HexBytes) { + chainA := s.configurer.GetChainConfig(0) + n2, err := chainA.GetNodeAtIndex(2) + s.NoError(err) + n1, err := chainA.GetNodeAtIndex(1) + s.NoError(err) + + s.finalityIdx++ + s.finalityBlockHeightVoted++ + + appHash = n1.AddFinalitySignatureToBlock( + s.fp1BTCSK, + s.fp1.BtcPk, + s.finalityBlockHeightVoted, + s.fp1RandListInfo.SRList[s.finalityIdx], + &s.fp1RandListInfo.PRList[s.finalityIdx], + *s.fp1RandListInfo.ProofList[s.finalityIdx].ToProto(), + ) + + n2.AddFinalitySignatureToBlock( + s.fp2BTCSK, + s.fp2.BtcPk, + s.finalityBlockHeightVoted, + s.fp2RandListInfo.SRList[s.finalityIdx], + &s.fp2RandListInfo.PRList[s.finalityIdx], + *s.fp2RandListInfo.ProofList[s.finalityIdx].ToProto(), + ) + + return appHash +} + // UpdateRewardGauges update the current reward gauges on the test suite func (s *BtcRewardsDistribution) UpdateRewardGauges(n *chain.NodeConfig) { s.fp1LastRewardGauge, s.fp2LastRewardGauge, s.btcDel1LastRewardGauge, s.btcDel2LastRewardGauge = s.QueryRewardGauges(n) diff --git a/test/e2e/initialization/config.go b/test/e2e/initialization/config.go index 003aeee5..4ce287fd 100644 --- a/test/e2e/initialization/config.go +++ b/test/e2e/initialization/config.go @@ -358,7 +358,8 @@ func updateBtccheckpointGenesis(btccheckpointGenState *btccheckpointtypes.Genesi func updateFinalityGenesis(finalityGenState *finalitytypes.GenesisState) { finalityGenState.Params = finalitytypes.DefaultParams() finalityGenState.Params.FinalityActivationHeight = 0 - finalityGenState.Params.SignedBlocksWindow = 2000 + finalityGenState.Params.SignedBlocksWindow = 500 + finalityGenState.Params.MinSignedPerWindow = sdkmath.LegacyMustNewDecFromStr("0.005000000000000000") } func updateGenUtilGenesis(c *internalChain) func(*genutiltypes.GenesisState) {