OSDN Git Service

Seed (#415)
[bytom/bytom.git] / config / genesis_test.go
1 package config
2
3 import (
4         "testing"
5
6         "github.com/bytom/consensus"
7         "github.com/bytom/consensus/difficulty"
8 )
9
10 // test genesis
11 func TestGenerateGenesisTx(t *testing.T) {
12         if tx := GenerateGenesisTx(); tx == nil {
13                 t.Errorf("Generate genesis tx failed")
14         }
15 }
16
17 func TestGenerateGenesisBlock(t *testing.T) {
18         block := GenerateGenesisBlock()
19         nonce := block.Nonce
20         for {
21                 hash := block.Hash()
22                 if difficulty.CheckProofOfWork(&hash, consensus.InitialSeed, block.Bits) {
23                         break
24                 }
25                 block.Nonce++
26         }
27         if block.Nonce != nonce {
28                 t.Errorf("correct nonce is %d, but get %d", block.Nonce, nonce)
29         }
30 }