@ -22,8 +22,9 @@ import (
"github.com/tendermint/tendermint/libs/bytes"
"github.com/tendermint/tendermint/libs/bytes"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/proto/tendermint/version"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
tmtime "github.com/tendermint/tendermint/types/time"
tmtime "github.com/tendermint/tendermint/types/time"
"github.com/tendermint/tendermint/version"
)
)
func TestMain ( m * testing . M ) {
func TestMain ( m * testing . M ) {
@ -86,6 +87,9 @@ func TestBlockValidateBasic(t *testing.T) {
{ "Tampered EvidenceHash" , func ( blk * Block ) {
{ "Tampered EvidenceHash" , func ( blk * Block ) {
blk . EvidenceHash = [ ] byte ( "something else" )
blk . EvidenceHash = [ ] byte ( "something else" )
} , true } ,
} , true } ,
{ "Incorrect block protocol version" , func ( blk * Block ) {
blk . Version . Block = 1
} , true } ,
}
}
for i , tc := range testCases {
for i , tc := range testCases {
tc := tc
tc := tc
@ -260,7 +264,7 @@ func TestHeaderHash(t *testing.T) {
expectHash bytes . HexBytes
expectHash bytes . HexBytes
} {
} {
{ "Generates expected hash" , & Header {
{ "Generates expected hash" , & Header {
Version : version . Consensus { Block : 1 , App : 2 } ,
Version : tm version. Consensus { Block : 1 , App : 2 } ,
ChainID : "chainId" ,
ChainID : "chainId" ,
Height : 3 ,
Height : 3 ,
Time : time . Date ( 2019 , 10 , 13 , 16 , 14 , 44 , 0 , time . UTC ) ,
Time : time . Date ( 2019 , 10 , 13 , 16 , 14 , 44 , 0 , time . UTC ) ,
@ -277,7 +281,7 @@ func TestHeaderHash(t *testing.T) {
} , hexBytesFromString ( "F740121F553B5418C3EFBD343C2DBFE9E007BB67B0D020A0741374BAB65242A4" ) } ,
} , hexBytesFromString ( "F740121F553B5418C3EFBD343C2DBFE9E007BB67B0D020A0741374BAB65242A4" ) } ,
{ "nil header yields nil" , nil , nil } ,
{ "nil header yields nil" , nil , nil } ,
{ "nil ValidatorsHash yields nil" , & Header {
{ "nil ValidatorsHash yields nil" , & Header {
Version : version . Consensus { Block : 1 , App : 2 } ,
Version : tm version. Consensus { Block : 1 , App : 2 } ,
ChainID : "chainId" ,
ChainID : "chainId" ,
Height : 3 ,
Height : 3 ,
Time : time . Date ( 2019 , 10 , 13 , 16 , 14 , 44 , 0 , time . UTC ) ,
Time : time . Date ( 2019 , 10 , 13 , 16 , 14 , 44 , 0 , time . UTC ) ,
@ -317,7 +321,7 @@ func TestHeaderHash(t *testing.T) {
bz , err := gogotypes . StdTimeMarshal ( f )
bz , err := gogotypes . StdTimeMarshal ( f )
require . NoError ( t , err )
require . NoError ( t , err )
byteSlices = append ( byteSlices , bz )
byteSlices = append ( byteSlices , bz )
case version . Consensus :
case tm version. Consensus :
bz , err := f . Marshal ( )
bz , err := f . Marshal ( )
require . NoError ( t , err )
require . NoError ( t , err )
byteSlices = append ( byteSlices , bz )
byteSlices = append ( byteSlices , bz )
@ -352,7 +356,7 @@ func TestMaxHeaderBytes(t *testing.T) {
timestamp := time . Date ( math . MaxInt64 , 0 , 0 , 0 , 0 , 0 , math . MaxInt64 , time . UTC )
timestamp := time . Date ( math . MaxInt64 , 0 , 0 , 0 , 0 , 0 , math . MaxInt64 , time . UTC )
h := Header {
h := Header {
Version : version . Consensus { Block : math . MaxInt64 , App : math . MaxInt64 } ,
Version : tm version. Consensus { Block : math . MaxInt64 , App : math . MaxInt64 } ,
ChainID : maxChainID ,
ChainID : maxChainID ,
Height : math . MaxInt64 ,
Height : math . MaxInt64 ,
Time : timestamp ,
Time : timestamp ,
@ -696,7 +700,7 @@ func makeRandHeader() Header {
randBytes := tmrand . Bytes ( tmhash . Size )
randBytes := tmrand . Bytes ( tmhash . Size )
randAddress := tmrand . Bytes ( crypto . AddressSize )
randAddress := tmrand . Bytes ( crypto . AddressSize )
h := Header {
h := Header {
Version : version . Consensus { Block : 1 , App : 1 } ,
Version : tm version. Consensus { Block : version . BlockProtocol , App : 1 } ,
ChainID : chainID ,
ChainID : chainID ,
Height : height ,
Height : height ,
Time : t ,
Time : t ,