This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
/
block_test_wrap.go
121 lines (99 loc) · 2.62 KB
/
block_test_wrap.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package core
import (
"github.com/medibloc/go-medibloc/common"
"github.com/medibloc/go-medibloc/util"
)
// BlockTestWrap wraps Block and exports setters.
type BlockTestWrap struct {
*Block
}
// Clone copies block.
func (b *BlockTestWrap) Clone() (*BlockTestWrap, error) {
bd, err := b.Block.BlockData.Clone()
if err != nil {
return nil, err
}
bs, err := b.Block.state.Clone()
if err != nil {
return nil, err
}
return &BlockTestWrap{
&Block{
BlockData: bd,
state: bs,
sealed: b.Block.sealed,
}}, nil
}
// InitChild wraps block's InitChild.
func (b *BlockTestWrap) InitChild(coinbase common.Address) (*BlockTestWrap, error) {
bb, err := b.Block.InitChild(coinbase)
if err != nil {
return nil, err
}
return &BlockTestWrap{Block: bb}, nil
}
// SetSealed set sealed
func (b *BlockTestWrap) SetSealed(sealed bool) {
b.sealed = sealed
}
// SetHeight sets height.
func (b *BlockTestWrap) SetHeight(height uint64) {
b.height = height
}
// SetTransactions sets transactions TO BE REMOVED: For test without block pool
func (b *BlockTestWrap) SetTransactions(txs []*Transaction) error {
b.transactions = txs
return nil
}
// SetHash set block header's hash
func (b *BlockTestWrap) SetHash(hash []byte) {
b.hash = hash
}
// SetParentHash set block header's parent hash
func (b *BlockTestWrap) SetParentHash(parentHash []byte) {
b.parentHash = parentHash
}
// SetAccStateRoot set block header's accStateRoot
func (b *BlockTestWrap) SetAccStateRoot(accStateRoot []byte) {
b.accStateRoot = accStateRoot
}
// SetTxStateRoot set block header's txsRoot
func (b *BlockTestWrap) SetTxStateRoot(txStateRoot []byte) {
b.txStateRoot = txStateRoot
}
// SetDposRoot set block header's dposRoot
func (b *BlockTestWrap) SetDposRoot(dposRoot []byte) {
b.dposRoot = dposRoot
}
// SetCoinbase set coinbase
func (b *BlockTestWrap) SetCoinbase(coinbase common.Address) {
b.coinbase = coinbase
}
// SetReward sets reward
func (b *BlockTestWrap) SetReward(reward *util.Uint128) {
b.reward = reward
}
// SetSupply sets supply
func (b *BlockTestWrap) SetSupply(supply *util.Uint128) {
b.supply = supply
}
// SetTimestamp sets timestamp of block
func (b *BlockTestWrap) SetTimestamp(timestamp int64) {
b.timestamp = timestamp
}
// SetChainID sets chainID
func (b *BlockTestWrap) SetChainID(chainID uint32) {
b.chainID = chainID
}
// SetCPUPrice sets cpuPrice
func (b *BlockTestWrap) SetCPUPrice(cpuPrice *util.Uint128) {
b.cpuPrice = cpuPrice
}
// SetNetPrice sets netPrice
func (b *BlockTestWrap) SetNetPrice(netPrice *util.Uint128) {
b.netPrice = netPrice
}
// SetSign sets sign
func (b *BlockTestWrap) SetSign(sign []byte) {
b.sign = sign
}