-func TestCalcReorganizeNodes(t *testing.T) {
- c := &Chain{index: state.NewBlockIndex()}
- config.CommonConfig = config.DefaultConfig()
- config.CommonConfig.Consensus.Dpos.SelfVoteSigners = append(config.CommonConfig.Consensus.Dpos.SelfVoteSigners, "vsm1qkm743xmgnvh84pmjchq2s4tnfpgu9ae2f9slep")
- config.CommonConfig.Consensus.Dpos.XPrv = "a8e281b615809046698fb0b0f2804a36d824d48fa443350f10f1b80649d39e5f1e85cf9855548915e36137345910606cbc8e7dd8497c831dce899ee6ac112445"
- for _, v := range config.CommonConfig.Consensus.Dpos.SelfVoteSigners {
- address, err := common.DecodeAddress(v, &consensus.SoloNetParams)
- if err != nil {
- t.Fatal(err)
- }
- config.CommonConfig.Consensus.Dpos.Signers = append(config.CommonConfig.Consensus.Dpos.Signers, address)
- }
- header := config.GenesisBlock().BlockHeader
- initNode, err := state.NewBlockNode(&header, nil)
- if err != nil {
- t.Fatal(err)
+type mStore struct {
+ blockHeaders map[bc.Hash]*types.BlockHeader
+}
+
+func (s *mStore) BlockExist(hash *bc.Hash) bool { return false }
+func (s *mStore) GetBlock(*bc.Hash) (*types.Block, error) { return nil, nil }
+func (s *mStore) GetBlockHeader(hash *bc.Hash) (*types.BlockHeader, error) {
+ return s.blockHeaders[*hash], nil
+}
+func (s *mStore) GetStoreStatus() *BlockStoreState { return nil }
+func (s *mStore) GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error) { return nil, nil }
+func (s *mStore) GetTransactionsUtxo(*state.UtxoViewpoint, []*bc.Tx) error { return nil }
+func (s *mStore) GetUtxo(*bc.Hash) (*storage.UtxoEntry, error) { return nil, nil }
+func (s *mStore) GetConsensusResult(uint64) (*state.ConsensusResult, error) { return nil, nil }
+func (s *mStore) GetMainChainHash(uint64) (*bc.Hash, error) { return nil, nil }
+func (s *mStore) GetBlockHashesByHeight(uint64) ([]*bc.Hash, error) { return nil, nil }
+func (s *mStore) SaveBlock(*types.Block, *bc.TransactionStatus) error { return nil }
+func (s *mStore) SaveBlockHeader(blockHeader *types.BlockHeader) error {
+ s.blockHeaders[blockHeader.Hash()] = blockHeader
+ return nil
+}
+func (s *mStore) SaveChainStatus(*types.BlockHeader, *types.BlockHeader, []*types.BlockHeader, *state.UtxoViewpoint, []*state.ConsensusResult) error {
+ return nil
+}
+
+func TestCalcReorganizeChain(t *testing.T) {
+ c := &Chain{
+ store: &mStore{
+ blockHeaders: make(map[bc.Hash]*types.BlockHeader),
+ },