OSDN Git Service

modify ci
[bytom/vapor.git] / protocol / validation / block_test.go
index 01df93c..6cc0427 100644 (file)
@@ -4,11 +4,9 @@ import (
        "testing"
 
        "github.com/vapor/consensus"
-       "github.com/vapor/mining/tensority"
        "github.com/vapor/protocol/bc"
        "github.com/vapor/protocol/bc/types"
        "github.com/vapor/protocol/state"
-       "github.com/vapor/testutil"
 )
 
 func TestCheckBlockTime(t *testing.T) {
@@ -89,102 +87,3 @@ func TestCheckCoinbaseAmount(t *testing.T) {
                }
        }
 }
-
-func TestValidateBlockHeader(t *testing.T) {
-       // add (hash, seed) --> (tensority hash) to the  tensority cache for avoid
-       // real matrix calculate cost.
-       tensority.AIHash.AddCache(&bc.Hash{V0: 0}, &bc.Hash{}, testutil.MaxHash)
-       tensority.AIHash.AddCache(&bc.Hash{V0: 1}, &bc.Hash{}, testutil.MinHash)
-       tensority.AIHash.AddCache(&bc.Hash{V0: 1}, consensus.InitialSeed, testutil.MinHash)
-
-       cases := []struct {
-               block  *bc.Block
-               parent *state.BlockNode
-               err    error
-       }{
-               {
-                       block: &bc.Block{BlockHeader: &bc.BlockHeader{
-                               Version: 1,
-                       }},
-                       parent: &state.BlockNode{
-                               Version: 2,
-                       },
-                       err: errVersionRegression,
-               },
-               {
-                       block: &bc.Block{BlockHeader: &bc.BlockHeader{
-                               Height: 20,
-                       }},
-                       parent: &state.BlockNode{
-                               Height: 18,
-                       },
-                       err: errMisorderedBlockHeight,
-               },
-               {
-                       block: &bc.Block{BlockHeader: &bc.BlockHeader{
-                               Height: 20,
-                               Bits:   0,
-                       }},
-                       parent: &state.BlockNode{
-                               Height: 19,
-                               Bits:   2305843009214532812,
-                       },
-                       err: errBadBits,
-               },
-               {
-                       block: &bc.Block{BlockHeader: &bc.BlockHeader{
-                               Height:          20,
-                               PreviousBlockId: &bc.Hash{V0: 18},
-                       }},
-                       parent: &state.BlockNode{
-                               Height: 19,
-                               Hash:   bc.Hash{V0: 19},
-                       },
-                       err: errMismatchedBlock,
-               },
-               {
-                       block: &bc.Block{
-                               ID: bc.Hash{V0: 0},
-                               BlockHeader: &bc.BlockHeader{
-                                       Height:          1,
-                                       Timestamp:       1523352601,
-                                       PreviousBlockId: &bc.Hash{V0: 0},
-                                       Bits:            2305843009214532812,
-                               },
-                       },
-                       parent: &state.BlockNode{
-                               Height:    0,
-                               Timestamp: 1523352600,
-                               Hash:      bc.Hash{V0: 0},
-                               Seed:      &bc.Hash{V1: 1},
-                               Bits:      2305843009214532812,
-                       },
-                       err: errWorkProof,
-               },
-               {
-                       block: &bc.Block{
-                               ID: bc.Hash{V0: 1},
-                               BlockHeader: &bc.BlockHeader{
-                                       Height:          1,
-                                       Timestamp:       1523352601,
-                                       PreviousBlockId: &bc.Hash{V0: 0},
-                                       Bits:            2305843009214532812,
-                               },
-                       },
-                       parent: &state.BlockNode{
-                               Height:    0,
-                               Timestamp: 1523352600,
-                               Hash:      bc.Hash{V0: 0},
-                               Seed:      &bc.Hash{V1: 1},
-                               Bits:      2305843009214532812,
-                       },
-                       err: nil,
-               },
-       }
-
-       for i, c := range cases {
-               if err := ValidateBlockHeader(c.block, c.parent); rootErr(err) != c.err {
-                       t.Errorf("case %d got error %s, want %s", i, err, c.err)
-               }
-       }
-}