github.com/iotexproject/iotex-core@v1.14.1-rc1/blockchain/block/genesis_block_test.go (about) 1 // Copyright (c) 2021 IoTeX Foundation 2 // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability 3 // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. 4 // This source code is governed by Apache License 2.0 that can be found in the LICENSE file. 5 6 package block 7 8 import ( 9 "encoding/hex" 10 "testing" 11 12 "github.com/iotexproject/go-pkgs/hash" 13 "github.com/stretchr/testify/require" 14 15 "github.com/iotexproject/iotex-core/blockchain/genesis" 16 "github.com/iotexproject/iotex-core/pkg/version" 17 ) 18 19 func TestGenesisBlock(t *testing.T) { 20 r := require.New(t) 21 22 g := genesis.Default 23 genesis.SetGenesisTimestamp(g.Timestamp) 24 blk := GenesisBlock() 25 r.EqualValues(version.ProtocolVersion, blk.Version()) 26 r.Zero(blk.Height()) 27 r.Equal(genesis.Default.Timestamp, blk.Timestamp().Unix()) 28 r.Equal(hash.ZeroHash256, blk.PrevHash()) 29 r.Equal(hash.ZeroHash256, blk.TxRoot()) 30 r.Equal(hash.ZeroHash256, blk.DeltaStateDigest()) 31 r.Equal(hash.ZeroHash256, blk.ReceiptRoot()) 32 33 r.Equal(hash.ZeroHash256, GenesisHash()) 34 LoadGenesisHash(&g) 35 h := GenesisHash() 36 r.Equal("e825cf0df9c72bc8cc74b23485af65c4d8a8ba691db335e44de7362cd86bac7f", hex.EncodeToString(h[:])) 37 }