github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/bft/state/export_test.go (about)

     1  package state
     2  
     3  import (
     4  	abci "github.com/gnolang/gno/tm2/pkg/bft/abci/types"
     5  	"github.com/gnolang/gno/tm2/pkg/bft/types"
     6  	dbm "github.com/gnolang/gno/tm2/pkg/db"
     7  )
     8  
     9  //
    10  // TODO: Remove dependence on all entities exported from this file.
    11  //
    12  // Every entity exported here is dependent on a private entity from the `state`
    13  // package. Currently, these functions are only made available to tests in the
    14  // `state_test` package, but we should not be relying on them for our testing.
    15  // Instead, we should be exclusively relying on exported entities for our
    16  // testing, and should be refactoring exported entities to make them more
    17  // easily testable from outside of the package.
    18  //
    19  
    20  const ValSetCheckpointInterval = valSetCheckpointInterval
    21  
    22  // UpdateState is an alias for updateState exported from execution.go,
    23  // exclusively and explicitly for testing.
    24  func UpdateState(
    25  	state State,
    26  	blockID types.BlockID,
    27  	header *types.Header,
    28  	abciResponses *ABCIResponses,
    29  ) (State, error) {
    30  	return updateState(state, blockID, header, abciResponses)
    31  }
    32  
    33  // ValidateValidatorUpdates is an alias for validateValidatorUpdates exported
    34  // from execution.go, exclusively and explicitly for testing.
    35  func ValidateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, params abci.ValidatorParams) error {
    36  	return validateValidatorUpdates(abciUpdates, params)
    37  }
    38  
    39  // CalcValidatorsKey is an alias for the private calcValidatorsKey method in
    40  // store.go, exported exclusively and explicitly for testing.
    41  func CalcValidatorsKey(height int64) []byte {
    42  	return calcValidatorsKey(height)
    43  }
    44  
    45  // SaveABCIResponses is an alias for the private saveABCIResponses method in
    46  // store.go, exported exclusively and explicitly for testing.
    47  func SaveABCIResponses(db dbm.DB, height int64, abciResponses *ABCIResponses) {
    48  	saveABCIResponses(db, height, abciResponses)
    49  }
    50  
    51  // SaveConsensusParamsInfo is an alias for the private saveConsensusParamsInfo
    52  // method in store.go, exported exclusively and explicitly for testing.
    53  func SaveConsensusParamsInfo(db dbm.DB, nextHeight, changeHeight int64, params abci.ConsensusParams) {
    54  	saveConsensusParamsInfo(db, nextHeight, changeHeight, params)
    55  }
    56  
    57  // SaveValidatorsInfo is an alias for the private saveValidatorsInfo method in
    58  // store.go, exported exclusively and explicitly for testing.
    59  func SaveValidatorsInfo(db dbm.DB, height, lastHeightChanged int64, valSet *types.ValidatorSet) {
    60  	saveValidatorsInfo(db, height, lastHeightChanged, valSet)
    61  }