-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.go
46 lines (42 loc) · 1.25 KB
/
setup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package testutil
import (
"time"
"github.com/tendermint/tendermint/crypto/tmhash"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
"github.com/tendermint/tendermint/version"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewHeader creates a new Tendermint header for testing purposes.
func NewHeader(
height int64,
blockTime time.Time,
chainID string,
proposer sdk.ConsAddress,
appHash,
validatorHash []byte,
) tmproto.Header {
return tmproto.Header{
ChainID: chainID,
Height: height,
Time: blockTime,
ValidatorsHash: validatorHash,
AppHash: appHash,
ProposerAddress: proposer.Bytes(),
Version: tmversion.Consensus{
Block: version.BlockProtocol,
},
LastBlockId: tmproto.BlockID{
Hash: tmhash.Sum([]byte("block_id")),
PartSetHeader: tmproto.PartSetHeader{
Total: 11,
Hash: tmhash.Sum([]byte("partset_header")),
},
},
DataHash: tmhash.Sum([]byte("data")),
NextValidatorsHash: tmhash.Sum([]byte("next_validators")),
ConsensusHash: tmhash.Sum([]byte("consensus")),
LastResultsHash: tmhash.Sum([]byte("last_result")),
EvidenceHash: tmhash.Sum([]byte("evidence")),
}
}