mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-24 07:46:45 +00:00

* Mine JSON * [Reindex tests] add test_params and validate_mining flag to test_consensus * Rename file and extend tests * Ignore local test datasets * Use spaces over tabs * Reindex algorithm - full algorithm, initial commit, some tests fail * Reindex algorithm - a few critical fixes * Reindex algorithm - move reindex struct and all related operations to new file * Reindex algorithm - added a validateIntervals method and modified tests to use it (instead of exact comparisons) * Reindex algorithm - modified reindexIntervals to receive the new child as argument and fixed an important related bug * Reindex attack tests - move logic to helper function and add stretch test * Reindex algorithm - variable names and some comments * Reindex algorithm - minor changes * Reindex algorithm - minor changes 2 * Reindex algorithm - extended stretch test * Reindex algorithm - small fix to validate function * Reindex tests - move tests and add DAG files * go format fixes * TestParams doc comment * Reindex tests - exact comparisons are not needed * Update to version 0.8.6 * Remove TestParams and use AddUTXOInvalidHeader instead * Use gzipeed test files * This unintended change somehow slipped in through branch merges * Rename test * Move interval increase/decrease methods to reachability interval file * Addressing a bunch of minor review comments * Addressed a few more minor review comments * Make code of offsetSiblingsBefore and offsetSiblingsAfter symmetric * Optimize reindex logic in cases where reorg occurs + reorg test * Do not change reindex root too fast (on reorg) * Some comments * A few more comments * Addressing review comments * Remove TestNoAttackAlternateReorg and assert chain attack * Minor Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com> Co-authored-by: Mike Zak <feanorr@gmail.com> Co-authored-by: Ori Newman <orinewman1@gmail.com>
71 lines
2.9 KiB
Go
71 lines
2.9 KiB
Go
package testapi
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/dagconfig"
|
|
"github.com/kaspanet/kaspad/infrastructure/db/database"
|
|
"io"
|
|
)
|
|
|
|
// TestConsensus wraps the Consensus interface with some methods that are needed by tests only
|
|
type TestConsensus interface {
|
|
externalapi.Consensus
|
|
|
|
DAGParams() *dagconfig.Params
|
|
DatabaseContext() model.DBManager
|
|
Database() database.Database
|
|
|
|
BuildBlockWithParents(parentHashes []*externalapi.DomainHash, coinbaseData *externalapi.DomainCoinbaseData,
|
|
transactions []*externalapi.DomainTransaction) (*externalapi.DomainBlock, model.UTXODiff, error)
|
|
|
|
BuildHeaderWithParents(parentHashes []*externalapi.DomainHash) (externalapi.BlockHeader, error)
|
|
|
|
BuildUTXOInvalidBlock(parentHashes []*externalapi.DomainHash) (*externalapi.DomainBlock, error)
|
|
|
|
// AddBlock builds a block with given information, solves it, and adds to the DAG.
|
|
// Returns the hash of the added block
|
|
AddBlock(parentHashes []*externalapi.DomainHash, coinbaseData *externalapi.DomainCoinbaseData,
|
|
transactions []*externalapi.DomainTransaction) (*externalapi.DomainHash, *externalapi.BlockInsertionResult, error)
|
|
|
|
AddUTXOInvalidHeader(parentHashes []*externalapi.DomainHash) (*externalapi.DomainHash, *externalapi.BlockInsertionResult, error)
|
|
|
|
AddUTXOInvalidBlock(parentHashes []*externalapi.DomainHash) (*externalapi.DomainHash,
|
|
*externalapi.BlockInsertionResult, error)
|
|
|
|
MineJSON(r io.Reader) (tips []*externalapi.DomainHash, err error)
|
|
DiscardAllStores()
|
|
|
|
AcceptanceDataStore() model.AcceptanceDataStore
|
|
BlockHeaderStore() model.BlockHeaderStore
|
|
BlockRelationStore() model.BlockRelationStore
|
|
BlockStatusStore() model.BlockStatusStore
|
|
BlockStore() model.BlockStore
|
|
ConsensusStateStore() model.ConsensusStateStore
|
|
GHOSTDAGDataStore() model.GHOSTDAGDataStore
|
|
HeaderTipsStore() model.HeaderSelectedTipStore
|
|
MultisetStore() model.MultisetStore
|
|
PruningStore() model.PruningStore
|
|
ReachabilityDataStore() model.ReachabilityDataStore
|
|
UTXODiffStore() model.UTXODiffStore
|
|
HeadersSelectedChainStore() model.HeadersSelectedChainStore
|
|
|
|
BlockBuilder() TestBlockBuilder
|
|
BlockProcessor() model.BlockProcessor
|
|
BlockValidator() model.BlockValidator
|
|
CoinbaseManager() model.CoinbaseManager
|
|
ConsensusStateManager() TestConsensusStateManager
|
|
FinalityManager() model.FinalityManager
|
|
DAGTopologyManager() model.DAGTopologyManager
|
|
DAGTraversalManager() model.DAGTraversalManager
|
|
DifficultyManager() model.DifficultyManager
|
|
GHOSTDAGManager() model.GHOSTDAGManager
|
|
HeaderTipsManager() model.HeadersSelectedTipManager
|
|
MergeDepthManager() model.MergeDepthManager
|
|
PastMedianTimeManager() model.PastMedianTimeManager
|
|
PruningManager() model.PruningManager
|
|
ReachabilityManager() TestReachabilityManager
|
|
SyncManager() model.SyncManager
|
|
TransactionValidator() TestTransactionValidator
|
|
}
|