OSDN Git Service

Merge pull request #15 from Bytom/dev_ci
[bytom/vapor.git] / test / block_test.go
index b837c94..c31d44c 100644 (file)
@@ -30,7 +30,6 @@ func TestBlockHeader(t *testing.T) {
                prevHeight func() uint64
                timestamp  func() uint64
                prevHash   func() *bc.Hash
-               bits       func() uint64
                solve      bool
                valid      bool
        }{
@@ -40,7 +39,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      false,
                },
@@ -50,7 +48,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      true,
                },
@@ -60,7 +57,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: func() uint64 { return chain.BestBlockHeight() + 1 },
                        timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      false,
                },
@@ -70,17 +66,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
                        prevHash:   func() *bc.Hash { hash := genesisHeader.Hash(); return &hash },
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
-                       solve:      true,
-                       valid:      false,
-               },
-               {
-                       desc:       "invalid bits",
-                       version:    func() uint64 { return chain.BestBlockHeader().Version },
-                       prevHeight: chain.BestBlockHeight,
-                       timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp + 1 },
-                       prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits + 100 },
                        solve:      true,
                        valid:      false,
                },
@@ -90,7 +75,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return uint64(time.Now().Unix()) + consensus.MaxTimeOffsetSeconds + 60 },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      false,
                },
@@ -100,7 +84,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp + 3 },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      true,
                },
@@ -110,7 +93,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return chain.BestBlockHeader().Timestamp - 1 },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      true,
                },
@@ -120,7 +102,6 @@ func TestBlockHeader(t *testing.T) {
                        prevHeight: chain.BestBlockHeight,
                        timestamp:  func() uint64 { return genesisHeader.Timestamp },
                        prevHash:   chain.BestBlockHash,
-                       bits:       func() uint64 { return chain.BestBlockHeader().Bits },
                        solve:      true,
                        valid:      false,
                },
@@ -136,15 +117,7 @@ func TestBlockHeader(t *testing.T) {
                block.Height = c.prevHeight() + 1
                block.Timestamp = c.timestamp()
                block.PreviousBlockHash = *c.prevHash()
-               block.Bits = c.bits()
-               seed, err := chain.CalcNextSeed(&block.PreviousBlockHash)
-               if err != nil && c.valid {
-                       t.Fatal(err)
-               }
 
-               if c.solve {
-                       Solve(seed, block)
-               }
                _, err = chain.ProcessBlock(block)
                result := err == nil
                if result != c.valid {