Skip to content

Commit

Permalink
Integration e2e test 3 (#71)
Browse files Browse the repository at this point in the history
Another follow-up to #68
  • Loading branch information
maurolacy authored Dec 16, 2024
1 parent eabe629 commit 940af19
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 59 deletions.
214 changes: 212 additions & 2 deletions go.work.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/e2e/bcd_consumer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package e2e
import (
"encoding/hex"
"fmt"
"github.com/babylonlabs-io/babylon-sdk/tests/e2e/cosmos-integration-e2e/clientcontroller/babylon"
cwconfig "github.com/babylonlabs-io/babylon-sdk/tests/e2e/cosmos-integration-e2e/clientcontroller/config"
"github.com/babylonlabs-io/babylon-sdk/tests/e2e/cosmos-integration-e2e/clientcontroller/cosmwasm"
"math/rand"
"os"
"os/exec"
Expand All @@ -21,9 +24,6 @@ import (
bbnparams "github.com/babylonlabs-io/babylon/app/params"
txformat "github.com/babylonlabs-io/babylon/btctxformatter"
"github.com/babylonlabs-io/babylon/client/config"
"github.com/babylonlabs-io/babylon/test/e2e/bcd_consumer_integration/clientcontroller/babylon"
cwconfig "github.com/babylonlabs-io/babylon/test/e2e/bcd_consumer_integration/clientcontroller/config"
"github.com/babylonlabs-io/babylon/test/e2e/bcd_consumer_integration/clientcontroller/cosmwasm"
"github.com/babylonlabs-io/babylon/test/e2e/initialization"
"github.com/babylonlabs-io/babylon/testutil/datagen"
bbn "github.com/babylonlabs-io/babylon/types"
Expand Down Expand Up @@ -333,7 +333,7 @@ func (s *BCDConsumerIntegrationTestSuite) Test6ConsumerFPRewardsGeneration() {
return false
}
return true
}, time.Minute, time.Second*5)
}, 30*time.Second, time.Second*5)

// Once the vote is cast, ensure the block is finalised
finalizedBlock, err := s.cosmwasmController.QueryIndexedBlock(uint64(czActivatedHeight))
Expand All @@ -354,7 +354,7 @@ func (s *BCDConsumerIntegrationTestSuite) Test6ConsumerFPRewardsGeneration() {
}
fmt.Println("Consumer rewards: ", rewards)
return true
}, time.Minute, time.Second*5)
}, 30*time.Second, time.Second*5)
}

// Test7BabylonFPCascadedSlashing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ package babylon
import (
"context"
"fmt"
"github.com/babylonlabs-io/babylon-sdk/tests/e2e/cosmos-integration-e2e/clientcontroller/types"
"math/rand"

sdkErr "cosmossdk.io/errors"
"cosmossdk.io/math"
bbnclient "github.com/babylonlabs-io/babylon/client/client"
"github.com/babylonlabs-io/babylon/client/config"
"github.com/babylonlabs-io/babylon/crypto/eots"
types2 "github.com/babylonlabs-io/babylon/test/e2e/bcd_consumer_integration/clientcontroller/types"
"github.com/babylonlabs-io/babylon/testutil/datagen"
bbntypes "github.com/babylonlabs-io/babylon/types"
btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"
Expand Down Expand Up @@ -124,7 +124,7 @@ func (bc *BabylonController) RegisterFinalityProvider(
pop []byte,
commission *math.LegacyDec,
description []byte,
) (*types2.TxResponse, error) {
) (*types.TxResponse, error) {
var bbnPop btcstakingtypes.ProofOfPossessionBTC
if err := bbnPop.Unmarshal(pop); err != nil {
return nil, fmt.Errorf("invalid proof-of-possession: %w", err)
Expand All @@ -150,7 +150,7 @@ func (bc *BabylonController) RegisterFinalityProvider(
return nil, err
}

return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) QueryFinalityProviderSlashed(fpPk *btcec.PublicKey) (bool, error) {
Expand Down Expand Up @@ -191,7 +191,7 @@ func (bc *BabylonController) QueryFinalityProviderHasPower(fpPk *btcec.PublicKey
return res.VotingPower > 0, nil
}

func (bc *BabylonController) QueryLatestFinalizedBlocks(count uint64) ([]*types2.BlockInfo, error) {
func (bc *BabylonController) QueryLatestFinalizedBlocks(count uint64) ([]*types.BlockInfo, error) {
return bc.queryLatestBlocks(nil, count, finalitytypes.QueriedBlockStatus_FINALIZED, true)
}

Expand All @@ -208,7 +208,7 @@ func (bc *BabylonController) QueryCometBlock(height uint64) (*coretypes.ResultBl
return bc.bbnClient.GetBlock(int64(height))
}

func (bc *BabylonController) QueryBlocks(startHeight, endHeight, limit uint64) ([]*types2.BlockInfo, error) {
func (bc *BabylonController) QueryBlocks(startHeight, endHeight, limit uint64) ([]*types.BlockInfo, error) {
if endHeight < startHeight {
return nil, fmt.Errorf("the startHeight %v should not be higher than the endHeight %v", startHeight, endHeight)
}
Expand Down Expand Up @@ -237,8 +237,8 @@ func (bc *BabylonController) QueryLastCommittedPublicRand(fpPk *btcec.PublicKey,
return res.PubRandCommitMap, nil
}

func (bc *BabylonController) queryLatestBlocks(startKey []byte, count uint64, status finalitytypes.QueriedBlockStatus, reverse bool) ([]*types2.BlockInfo, error) {
var blocks []*types2.BlockInfo
func (bc *BabylonController) queryLatestBlocks(startKey []byte, count uint64, status finalitytypes.QueriedBlockStatus, reverse bool) ([]*types.BlockInfo, error) {
var blocks []*types.BlockInfo
pagination := &sdkquery.PageRequest{
Limit: count,
Reverse: reverse,
Expand All @@ -251,7 +251,7 @@ func (bc *BabylonController) queryLatestBlocks(startKey []byte, count uint64, st
}

for _, b := range res.Blocks {
ib := &types2.BlockInfo{
ib := &types.BlockInfo{
Height: b.Height,
Hash: b.AppHash,
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func (bc *BabylonController) CreateBTCDelegation(
unbondingValue int64,
unbondingSlashingTx *btcstakingtypes.BTCSlashingTx,
delUnbondingSlashingSig *bbntypes.BIP340Signature,
) (*types2.TxResponse, error) {
) (*types.TxResponse, error) {
fpBtcPks := make([]bbntypes.BIP340PubKey, 0, len(fpPks))
for _, v := range fpPks {
fpBtcPks = append(fpBtcPks, *bbntypes.NewBIP340PubKeyFromBTCPK(v))
Expand Down Expand Up @@ -316,7 +316,7 @@ func (bc *BabylonController) CreateBTCDelegation(
return nil, err
}

return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) InsertWBTCHeaders(r *rand.Rand) error {
Expand Down Expand Up @@ -498,7 +498,7 @@ func (bc *BabylonController) queryDelegationsWithStatus(status btcstakingtypes.B
return res.BtcDelegations, nil
}

func (bc *BabylonController) QueryStakingParams() (*types2.StakingParams, error) {
func (bc *BabylonController) QueryStakingParams() (*types.StakingParams, error) {
// query btc checkpoint params
ckptParamRes, err := bc.bbnClient.QueryClient.BTCCheckpointParams()
if err != nil {
Expand All @@ -520,7 +520,7 @@ func (bc *BabylonController) QueryStakingParams() (*types2.StakingParams, error)
covenantPks = append(covenantPks, covPk)
}

return &types2.StakingParams{
return &types.StakingParams{
ComfirmationTimeBlocks: ckptParamRes.Params.BtcConfirmationDepth,
FinalizationTimeoutBlocks: ckptParamRes.Params.CheckpointFinalizationTimeout,
MinSlashingTxFeeSat: btcutil.Amount(stakingParamRes.Params.MinSlashingTxFeeSat),
Expand All @@ -547,7 +547,7 @@ func (bc *BabylonController) SubmitCovenantSigs(
slashingSigs [][]byte,
unbondingSig *schnorr.Signature,
unbondingSlashingSigs [][]byte,
) (*types2.TxResponse, error) {
) (*types.TxResponse, error) {
bip340UnbondingSig := bbntypes.NewBIP340SignatureFromBTCSig(unbondingSig)

msg := &btcstakingtypes.MsgAddCovenantSigs{
Expand All @@ -564,7 +564,7 @@ func (bc *BabylonController) SubmitCovenantSigs(
return nil, err
}

return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) InsertSpvProofs(submitter string, proofs []*btcctypes.BTCSpvProof) (*provider.RelayerTxResponse, error) {
Expand All @@ -582,7 +582,7 @@ func (bc *BabylonController) InsertSpvProofs(submitter string, proofs []*btcctyp
}

// RegisterConsumerChain registers a consumer chain via a MsgRegisterChain to Babylon
func (bc *BabylonController) RegisterConsumerChain(id, name, description string) (*types2.TxResponse, error) {
func (bc *BabylonController) RegisterConsumerChain(id, name, description string) (*types.TxResponse, error) {
msg := &bsctypes.MsgRegisterConsumer{
Signer: bc.MustGetTxSigner(),
ConsumerId: id,
Expand All @@ -595,20 +595,20 @@ func (bc *BabylonController) RegisterConsumerChain(id, name, description string)
return nil, err
}

return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) CommitPublicRandomness(
msgCommitPubRandList *finalitytypes.MsgCommitPubRandList,
) (*types2.TxResponse, error) {
) (*types.TxResponse, error) {
signerAddr := bc.MustGetTxSigner()
msgCommitPubRandList.Signer = signerAddr
res, err := bc.reliablySendMsg(msgCommitPubRandList, emptyErrs, emptyErrs)
if err != nil {
return nil, err
}

return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) SubmitFinalitySignature(
Expand All @@ -618,7 +618,7 @@ func (bc *BabylonController) SubmitFinalitySignature(
pubRand *bbntypes.SchnorrPubRand,
proof *cmtcrypto.Proof,
heightToVote uint64,
) (*types2.TxResponse, error) {
) (*types.TxResponse, error) {
block, err := bc.bbnClient.QueryClient.GetBlock(int64(heightToVote))
if err != nil {
return nil, err
Expand All @@ -645,7 +645,7 @@ func (bc *BabylonController) SubmitFinalitySignature(
if err != nil {
return nil, err
}
return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) SubmitInvalidFinalitySignature(
Expand All @@ -656,7 +656,7 @@ func (bc *BabylonController) SubmitInvalidFinalitySignature(
pubRand *bbntypes.SchnorrPubRand,
proof *cmtcrypto.Proof,
heightToVote uint64,
) (*types2.TxResponse, error) {
) (*types.TxResponse, error) {
invalidAppHash := datagen.GenRandomByteArray(r, 32)
invalidMsgToSign := append(sdk.Uint64ToBigEndian(heightToVote), invalidAppHash...)
invalidSig, err := eots.Sign(fpSK, privateRand, invalidMsgToSign)
Expand All @@ -680,7 +680,7 @@ func (bc *BabylonController) SubmitInvalidFinalitySignature(
if err != nil {
return nil, err
}
return &types2.TxResponse{TxHash: res.TxHash}, nil
return &types.TxResponse{TxHash: res.TxHash}, nil
}

// IBCChannels queries the IBC channels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
sdkErr "cosmossdk.io/errors"
wasmdparams "github.com/CosmWasm/wasmd/app/params"
wasmdtypes "github.com/CosmWasm/wasmd/x/wasm/types"
cwconfig "github.com/babylonlabs-io/babylon-sdk/tests/e2e/cosmos-integration-e2e/clientcontroller/config"
"github.com/babylonlabs-io/babylon-sdk/tests/e2e/cosmos-integration-e2e/clientcontroller/types"
"github.com/babylonlabs-io/babylon/crypto/eots"
cwconfig "github.com/babylonlabs-io/babylon/test/e2e/bcd_consumer_integration/clientcontroller/config"
"github.com/babylonlabs-io/babylon/test/e2e/bcd_consumer_integration/clientcontroller/types"
"github.com/babylonlabs-io/babylon/testutil/datagen"
bbntypes "github.com/babylonlabs-io/babylon/types"
cwcclient "github.com/babylonlabs-io/cosmwasm-client/client"
Expand Down
18 changes: 9 additions & 9 deletions tests/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ require (

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
github.com/babylonlabs-io/babylon v0.9.3-0.20241207063157-930046144fa3
cosmossdk.io/math v1.4.0
github.com/babylonlabs-io/babylon v0.9.3-0.20241213004323-72654c8c8406
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240814002132-55e711397a82
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240814002132-55e711397a82
github.com/babylonlabs-io/cosmwasm-client v0.0.0-20240908181148-88f10f0917e6
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.6
github.com/cometbft/cometbft v0.38.14
github.com/cometbft/cometbft v0.38.15
github.com/cosmos/btcutil v1.0.5
github.com/cosmos/relayer/v2 v2.5.2
go.uber.org/zap v1.26.0
Expand Down Expand Up @@ -112,7 +112,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/dot v1.6.1 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/ethereum/go-ethereum v1.13.14 // indirect
github.com/ethereum/go-ethereum v1.13.15 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand Down Expand Up @@ -218,14 +218,14 @@ require (
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
Expand Down
Loading

0 comments on commit 940af19

Please sign in to comment.