Skip to content

Commit

Permalink
feat: remove unused test code in vote_ext and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
wnjoon committed Jan 31, 2025
1 parent e7dd698 commit 848829e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 37 deletions.
1 change: 1 addition & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TmpAppOptions() simsutils.AppOptionsMap {
return appOpts
}

// NewTmpBabylonApp returns a new BabylonApp
func NewTmpBabylonApp() *BabylonApp {
tbs, _ := signer.SetupTestBlsSigner()
blsSigner := checkpointingtypes.BlsSigner(tbs)
Expand Down
1 change: 1 addition & 0 deletions app/signer/private.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types"
)

// ConsensusKey represents the consensus keys
type ConsensusKey struct {
Comet *cmtprivval.FilePVKey
Bls *privval.BlsPVKey
Expand Down
1 change: 1 addition & 0 deletions x/checkpointing/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ var (
ErrConflictingCheckpoint = errorsmod.Register(ModuleName, 1213, "Conflicting checkpoint is found")
ErrInvalidAppHash = errorsmod.Register(ModuleName, 1214, "Provided app hash is Invalid")
ErrInsufficientVotingPower = errorsmod.Register(ModuleName, 1215, "Accumulated voting power is not greater than 2/3 of total power")
ErrValAddrDoesNotExist = errorsmod.Register(ModuleName, 1216, "Validator address does not exist")
)
37 changes: 0 additions & 37 deletions x/checkpointing/vote_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,40 +175,3 @@ func FuzzExtendVote_InvalidBlockHash(f *testing.F) {
require.NoError(t, err)
})
}

// FuzzExtendVote_EmptyBLSPrivKey tests the case where the
// BLS private key of the private signer is missing
func FuzzExtendVote_EmptyBLSPrivKey(f *testing.F) {
datagen.AddRandomSeedsToFuzzer(f, 10)

f.Fuzz(func(t *testing.T, seed int64) {
r := rand.New(rand.NewSource(seed))
// generate the validator set with 10 validators as genesis
genesisValSet, ps, err := datagen.GenesisValidatorSetWithPrivSigner(10)
require.NoError(t, err)

// set the BLS private key to be nil to trigger panic
ps.PV.Bls.PrivKey = nil
helper := testhelper.NewHelperWithValSet(t, genesisValSet, ps)
ek := helper.App.EpochingKeeper

epoch := ek.GetEpoch(helper.Ctx)
require.Equal(t, uint64(1), epoch.EpochNumber)

// go to block 10, reaching epoch boundary
interval := ek.GetParams(helper.Ctx).EpochInterval
for i := uint64(0); i < interval-2; i++ {
_, err := helper.ApplyEmptyBlockWithVoteExtension(r)
require.NoError(t, err)
}

req := &abci.RequestExtendVote{
Hash: datagen.GenRandomByteArray(r, types.HashSize),
Height: 10,
}

// error is expected due to nil BLS private key
_, err = helper.App.ExtendVote(helper.Ctx, req)
require.Error(t, err)
})
}

0 comments on commit 848829e

Please sign in to comment.