Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Oct 3, 2024
1 parent 73735ff commit c538635
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
28 changes: 14 additions & 14 deletions test/e2e/btc_staking_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ func (s *BTCStakingTestSuite) Test2SubmitCovenantSignature() {
bbn.NewBIP340SignatureFromBTCSig(covUnbondingSigs[i]),
covenantUnbondingSlashingSigs[i].AdaptorSigs,
)
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()
})
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()
}

// wait for a block so that above txs take effect
Expand Down Expand Up @@ -352,17 +352,17 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat
nonValidatorNode.SubmitRefundableTxWithAssertion(func() {
// submit finality signature
nonValidatorNode.AddFinalitySig(s.cacheFP.BtcPk, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig)
})

// ensure vote is eventually cast
var finalizedBlocks []*ftypes.IndexedBlock
s.Eventually(func() bool {
finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED)
return len(finalizedBlocks) > 0
}, time.Minute, time.Millisecond*50)
s.Equal(activatedHeight, finalizedBlocks[0].Height)
s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash)
s.T().Logf("the block %d is finalized", activatedHeight)
// ensure vote is eventually cast
var finalizedBlocks []*ftypes.IndexedBlock
s.Eventually(func() bool {
finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED)
return len(finalizedBlocks) > 0
}, time.Minute, time.Millisecond*50)
s.Equal(activatedHeight, finalizedBlocks[0].Height)
s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash)
s.T().Logf("the block %d is finalized", activatedHeight)
})

// ensure finality provider has received rewards after the block is finalised
fpRewardGauges, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr)
Expand Down Expand Up @@ -472,9 +472,9 @@ func (s *BTCStakingTestSuite) Test5SubmitStakerUnbonding() {
nonValidatorNode.SubmitRefundableTxWithAssertion(func() {
// submit the message for creating BTC undelegation
nonValidatorNode.BTCUndelegate(&stakingTxHash, delUnbondingSig)
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()
})
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()

// Wait for unbonded delegations to be created
var unbondedDelsResp []*bstypes.BTCDelegationResponse
Expand Down
34 changes: 16 additions & 18 deletions test/e2e/btc_staking_pre_approval_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,9 @@ func (s *BTCStakingPreApprovalTestSuite) Test2SubmitCovenantSignature() {
bbn.NewBIP340SignatureFromBTCSig(covUnbondingSigs[i]),
covenantUnbondingSlashingSigs[i].AdaptorSigs,
)
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()
})

// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()
}

// wait for a block so that above txs take effect
Expand Down Expand Up @@ -274,11 +273,10 @@ func (s *BTCStakingPreApprovalTestSuite) Test3SendStakingTransctionInclusionProo
&stakingTxHash,
s.cachedInclusionProof,
)
nonValidatorNode.WaitForNextBlock()
nonValidatorNode.WaitForNextBlock()
})

nonValidatorNode.WaitForNextBlock()
nonValidatorNode.WaitForNextBlock()

activeBTCDelegations := nonValidatorNode.QueryActiveDelegations()
s.Len(activeBTCDelegations, 1)
nonValidatorNode.WaitForNextBlock()
Expand Down Expand Up @@ -373,17 +371,17 @@ func (s *BTCStakingPreApprovalTestSuite) Test4CommitPublicRandomnessAndSubmitFin
// submit finality signature
nonValidatorNode.SubmitRefundableTxWithAssertion(func() {
nonValidatorNode.AddFinalitySig(s.cacheFP.BtcPk, activatedHeight, &randListInfo.PRList[idx], *randListInfo.ProofList[idx].ToProto(), appHash, eotsSig)
})

// ensure vote is eventually cast
var finalizedBlocks []*ftypes.IndexedBlock
s.Eventually(func() bool {
finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED)
return len(finalizedBlocks) > 0
}, time.Minute, time.Millisecond*50)
s.Equal(activatedHeight, finalizedBlocks[0].Height)
s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash)
s.T().Logf("the block %d is finalized", activatedHeight)
// ensure vote is eventually cast
var finalizedBlocks []*ftypes.IndexedBlock
s.Eventually(func() bool {
finalizedBlocks = nonValidatorNode.QueryListBlocks(ftypes.QueriedBlockStatus_FINALIZED)
return len(finalizedBlocks) > 0
}, time.Minute, time.Millisecond*50)
s.Equal(activatedHeight, finalizedBlocks[0].Height)
s.Equal(appHash.Bytes(), finalizedBlocks[0].AppHash)
s.T().Logf("the block %d is finalized", activatedHeight)
})

// ensure finality provider has received rewards after the block is finalised
fpRewardGauges, err := nonValidatorNode.QueryRewardGauge(fpBabylonAddr)
Expand Down Expand Up @@ -493,9 +491,9 @@ func (s *BTCStakingPreApprovalTestSuite) Test5SubmitStakerUnbonding() {
nonValidatorNode.SubmitRefundableTxWithAssertion(func() {
// submit the message for creating BTC undelegation
nonValidatorNode.BTCUndelegate(&stakingTxHash, delUnbondingSig)
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()
})
// wait for a block so that above txs take effect
nonValidatorNode.WaitForNextBlock()

// Wait for unbonded delegations to be created
var unbondedDelsResp []*bstypes.BTCDelegationResponse
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/configurer/chain/commands_btcstaking.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (n *NodeConfig) AddCovenantSigs(covPK *bbn.BIP340PubKey, stakingTxHash stri
// used key
cmd = append(cmd, "--from=val")
// gas
cmd = append(cmd, "--gas=auto", "--gas-adjustment=1.3")
cmd = append(cmd, "--gas=auto", "--gas-adjustment=2")

_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd)
require.NoError(n.t, err)
Expand Down
3 changes: 1 addition & 2 deletions x/incentive/keeper/refund_tx_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ func (d *RefundTxDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate, suc

// remove the refundable messages from the index, regardless whether the tx is refunded or not
// NOTE: If the message with same hash shows up again, the refunding rule will
// consider it duplicated
// and the tx will not be refunded
// consider it duplicated and the tx will not be refunded
for _, msgHash := range refundableMsgHashList {
d.k.RemoveRefundableMsg(ctx, msgHash)
}
Expand Down
5 changes: 5 additions & 0 deletions x/incentive/keeper/refundable_msg_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import (
// RefundTx refunds the given tx by sending the fee back to the fee payer.
func (k Keeper) RefundTx(ctx context.Context, tx sdk.FeeTx) error {
txFee := tx.GetFee()
if txFee.IsZero() {
// not possible with the global min gas price mechanism
// but having this check for compatibility in the future
return nil
}
txFeePayer := tx.FeePayer()

return k.bankKeeper.SendCoinsFromModuleToAccount(ctx, k.feeCollectorName, txFeePayer, txFee)
Expand Down

0 comments on commit c538635

Please sign in to comment.