• R/O
  • HTTP
  • SSH
  • HTTPS

bytom: Commit

Official Go implementation of the Bytom protocol


Commit MetaInfo

Revision19af3b90bc66aa91161fbd95d73dd61d49d501ea (tree)
Time2021-04-08 16:54:59
Authormingjingc <2595400537@qq.c...>
Commitermingjingc

Log Message

fix(remove pow):after merge btm2.0

Change Summary

Incremental Difference

--- a/protocol/bc/types/block_header_test.go
+++ b/protocol/bc/types/block_header_test.go
@@ -10,6 +10,7 @@ import (
1010 "github.com/davecgh/go-spew/spew"
1111
1212 "github.com/bytom/bytom/encoding/blockchain"
13+ "github.com/bytom/bytom/errors"
1314 "github.com/bytom/bytom/testutil"
1415 )
1516
@@ -231,49 +232,21 @@ func TestUnmarshalBlockHeader(t *testing.T) {
231232 "b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
232233 }, ""),
233234 wantError: hex.ErrLength,
234- }, //----
235- //{ // below test cases should be modified
236- // hexBlockHeader: strings.Join([]string{
237- // "01", // serialization flags
238- // "01", // version
239- // "ffffffffffffffff7f", // block height
240- // "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
241- // "e8b287d905", // timestamp
242- // "40", // commitment extensible field length
243- // "ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
244- // "b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
245- // }, ""),
246- // wantError: errors.New("binary: varint overflows a 64-bit integer"),
247- //},
248- //{
249- // hexBlockHeader: strings.Join([]string{
250- // "01", // serialization flags
251- // "01", // version
252- // "ffffffffffffffff7f", // block height
253- // "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
254- // "e8b287d905", // timestamp
255- // "40", // commitment extensible field length
256- // "ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
257- // "b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
258- // //"e19f8080a88d02", // nonce
259- // //"ffffffffffffffff80", // bits
260- // }, ""),
261- // wantError: fmt.Errorf("EOF"),
262- //},
263- //{
264- // hexBlockHeader: strings.Join([]string{
265- // "01", // serialization flags
266- // "01", // version
267- // "ffffffffffffffff7f", // block height
268- // "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
269- // "e8b287d905", // timestamp
270- // "40", // commitment extensible field length
271- // "ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
272- // "b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status ha sh
273- // }, ""),
274- // wantError: blockchain.ErrRange,
275- //},
276- { // ---
235+ },
236+ {
237+ hexBlockHeader: strings.Join([]string{
238+ "01", // serialization flags
239+ "01", // version
240+ "ffffffffffffffffff", // block height
241+ "c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0", // prev block hash
242+ "e8b287d905", // timestamp
243+ "40", // commitment extensible field length
244+ "ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
245+ "b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
246+ }, ""),
247+ wantError: errors.New("binary: varint overflows a 64-bit integer"),
248+ },
249+ {
277250 hexBlockHeader: strings.Join([]string{
278251 "01", // serialization flags
279252 "01", // version
@@ -283,16 +256,12 @@ func TestUnmarshalBlockHeader(t *testing.T) {
283256 "40", // commitment extensible field length
284257 "ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03", // transactions merkle root
285258 "b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470", // tx status hash
286- //"e19f8080a88d02", // nonce
287- //"cc99b3808080808020", // bits
288259 }, ""),
289260 wantBlockHeader: &BlockHeader{
290261 Version: 1,
291262 Height: 9223372036854775807, // MaxInt64(9223372036854775807)
292263 PreviousBlockHash: testutil.MustDecodeHash("c34048bd60c4c13144fd34f408627d1be68f6cb4fdd34e879d6d791060ea73a0"),
293264 Timestamp: 1528945000,
294- //Nonce: 9253507043297,
295- //Bits: 2305843009214532812,
296265 BlockCommitment: BlockCommitment{
297266 TransactionsMerkleRoot: testutil.MustDecodeHash("ad9ac003d08ff305181a345d64fe0b02311cc1a6ec04ab73f3318d90139bfe03"),
298267 TransactionStatusHash: testutil.MustDecodeHash("b94301ea4e316bee00109f68d25beaca90aeff08e9bf439a37d91d7a3b5a1470"),
--- a/test/protocol_test_util.go
+++ b/test/protocol_test_util.go
@@ -3,9 +3,9 @@ package test
33 import (
44 "fmt"
55
6+ dbm "github.com/bytom/bytom/database/leveldb"
67 "github.com/bytom/bytom/protocol"
78 "github.com/bytom/bytom/protocol/bc/types"
8- dbm "github.com/bytom/bytom/database/leveldb"
99 )
1010
1111 func declChain(name string, baseChain *protocol.Chain, baseHeight uint64, height uint64) (*protocol.Chain, error) {
@@ -23,7 +23,13 @@ func declChain(name string, baseChain *protocol.Chain, baseHeight uint64, height
2323 }
2424
2525 for i := uint64(1); i <= baseHeight; i++ {
26-
26+ block, err := baseChain.GetBlockByHeight(i)
27+ if err != nil {
28+ return nil, err
29+ }
30+ if _, err := chain.ProcessBlock(block); err != nil {
31+ return nil, err
32+ }
2733 }
2834
2935 err = AppendBlocks(chain, height-baseHeight)
Show on old repository browser