-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathgen_fuzzing_config.go
172 lines (166 loc) · 6.77 KB
/
gen_fuzzing_config.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package config
import (
"encoding/json"
"math/big"
"github.com/crytic/medusa/chain/config"
"github.com/ethereum/go-ethereum/common/hexutil"
)
var _ = (*fuzzingConfigMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (f FuzzingConfig) MarshalJSON() ([]byte, error) {
type FuzzingConfig struct {
Workers int `json:"workers"`
WorkerResetLimit int `json:"workerResetLimit"`
Timeout int `json:"timeout"`
TestLimit uint64 `json:"testLimit"`
ShrinkLimit uint64 `json:"shrinkLimit"`
CallSequenceLength int `json:"callSequenceLength"`
CorpusDirectory string `json:"corpusDirectory"`
CoverageEnabled bool `json:"coverageEnabled"`
HtmlReportFile string `json:"htmlReportPath"`
JsonReportFile string `json:"jsonReportPath"`
TargetContracts []string `json:"targetContracts"`
PredeployedContracts map[string]string `json:"predeployedContracts"`
TargetContractsBalances []*hexutil.Big `json:"targetContractsBalances"`
ConstructorArgs map[string]map[string]any `json:"constructorArgs"`
DeployerAddress string `json:"deployerAddress"`
SenderAddresses []string `json:"senderAddresses"`
MaxBlockNumberDelay uint64 `json:"blockNumberDelayMax"`
MaxBlockTimestampDelay uint64 `json:"blockTimestampDelayMax"`
BlockGasLimit uint64 `json:"blockGasLimit"`
TransactionGasLimit uint64 `json:"transactionGasLimit"`
Testing TestingConfig `json:"testing"`
TestChainConfig config.TestChainConfig `json:"chainConfig"`
}
var enc FuzzingConfig
enc.Workers = f.Workers
enc.WorkerResetLimit = f.WorkerResetLimit
enc.Timeout = f.Timeout
enc.TestLimit = f.TestLimit
enc.ShrinkLimit = f.ShrinkLimit
enc.CallSequenceLength = f.CallSequenceLength
enc.CorpusDirectory = f.CorpusDirectory
enc.CoverageEnabled = f.CoverageEnabled
enc.HtmlReportFile = f.HtmlReportFile
enc.JsonReportFile = f.JsonReportFile
enc.TargetContracts = f.TargetContracts
enc.PredeployedContracts = f.PredeployedContracts
if f.TargetContractsBalances != nil {
enc.TargetContractsBalances = make([]*hexutil.Big, len(f.TargetContractsBalances))
for k, v := range f.TargetContractsBalances {
enc.TargetContractsBalances[k] = (*hexutil.Big)(v)
}
}
enc.ConstructorArgs = f.ConstructorArgs
enc.DeployerAddress = f.DeployerAddress
enc.SenderAddresses = f.SenderAddresses
enc.MaxBlockNumberDelay = f.MaxBlockNumberDelay
enc.MaxBlockTimestampDelay = f.MaxBlockTimestampDelay
enc.BlockGasLimit = f.BlockGasLimit
enc.TransactionGasLimit = f.TransactionGasLimit
enc.Testing = f.Testing
enc.TestChainConfig = f.TestChainConfig
return json.Marshal(&enc)
}
// UnmarshalJSON unmarshals from JSON.
func (f *FuzzingConfig) UnmarshalJSON(input []byte) error {
type FuzzingConfig struct {
Workers *int `json:"workers"`
WorkerResetLimit *int `json:"workerResetLimit"`
Timeout *int `json:"timeout"`
TestLimit *uint64 `json:"testLimit"`
ShrinkLimit *uint64 `json:"shrinkLimit"`
CallSequenceLength *int `json:"callSequenceLength"`
CorpusDirectory *string `json:"corpusDirectory"`
CoverageEnabled *bool `json:"coverageEnabled"`
HtmlReportFile *string `json:"htmlReportPath"`
JsonReportFile *string `json:"jsonReportPath"`
TargetContracts []string `json:"targetContracts"`
PredeployedContracts map[string]string `json:"predeployedContracts"`
TargetContractsBalances []*hexutil.Big `json:"targetContractsBalances"`
ConstructorArgs map[string]map[string]any `json:"constructorArgs"`
DeployerAddress *string `json:"deployerAddress"`
SenderAddresses []string `json:"senderAddresses"`
MaxBlockNumberDelay *uint64 `json:"blockNumberDelayMax"`
MaxBlockTimestampDelay *uint64 `json:"blockTimestampDelayMax"`
BlockGasLimit *uint64 `json:"blockGasLimit"`
TransactionGasLimit *uint64 `json:"transactionGasLimit"`
Testing *TestingConfig `json:"testing"`
TestChainConfig *config.TestChainConfig `json:"chainConfig"`
}
var dec FuzzingConfig
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
if dec.Workers != nil {
f.Workers = *dec.Workers
}
if dec.WorkerResetLimit != nil {
f.WorkerResetLimit = *dec.WorkerResetLimit
}
if dec.Timeout != nil {
f.Timeout = *dec.Timeout
}
if dec.TestLimit != nil {
f.TestLimit = *dec.TestLimit
}
if dec.ShrinkLimit != nil {
f.ShrinkLimit = *dec.ShrinkLimit
}
if dec.CallSequenceLength != nil {
f.CallSequenceLength = *dec.CallSequenceLength
}
if dec.CorpusDirectory != nil {
f.CorpusDirectory = *dec.CorpusDirectory
}
if dec.CoverageEnabled != nil {
f.CoverageEnabled = *dec.CoverageEnabled
}
if dec.HtmlReportFile != nil {
f.HtmlReportFile = *dec.HtmlReportFile
}
if dec.JsonReportFile != nil {
f.JsonReportFile = *dec.JsonReportFile
}
if dec.TargetContracts != nil {
f.TargetContracts = dec.TargetContracts
}
if dec.PredeployedContracts != nil {
f.PredeployedContracts = dec.PredeployedContracts
}
if dec.TargetContractsBalances != nil {
f.TargetContractsBalances = make([]*big.Int, len(dec.TargetContractsBalances))
for k, v := range dec.TargetContractsBalances {
f.TargetContractsBalances[k] = (*big.Int)(v)
}
}
if dec.ConstructorArgs != nil {
f.ConstructorArgs = dec.ConstructorArgs
}
if dec.DeployerAddress != nil {
f.DeployerAddress = *dec.DeployerAddress
}
if dec.SenderAddresses != nil {
f.SenderAddresses = dec.SenderAddresses
}
if dec.MaxBlockNumberDelay != nil {
f.MaxBlockNumberDelay = *dec.MaxBlockNumberDelay
}
if dec.MaxBlockTimestampDelay != nil {
f.MaxBlockTimestampDelay = *dec.MaxBlockTimestampDelay
}
if dec.BlockGasLimit != nil {
f.BlockGasLimit = *dec.BlockGasLimit
}
if dec.TransactionGasLimit != nil {
f.TransactionGasLimit = *dec.TransactionGasLimit
}
if dec.Testing != nil {
f.Testing = *dec.Testing
}
if dec.TestChainConfig != nil {
f.TestChainConfig = *dec.TestChainConfig
}
return nil
}