-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuzzing_config.go
53 lines (44 loc) · 1.68 KB
/
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
package tbft
import (
"fmt"
"gopkg.in/yaml.v3"
"os"
)
var addr = "./fuzzing_config.yml"
type NodeConfig struct {
IsFuzzNode bool `yaml:"isFuzzNode"`
ProcProposeFuzz bool `yaml:"procProposeFuzz"`
SendProposeStateFuzz bool `yaml:"sendProposeStateFuzz"`
CommitBlockFuzz bool `yaml:"commitBlockFuzz"`
DelInvalidTxsFuzz bool `yaml:"delInvalidTxsFuzz"`
EnterPrevoteFuzz bool `yaml:"enterPrevoteFuzz"`
EnterPrecommitFuzz bool `yaml:"enterPrecommitFuzz"`
SendStateFuzz bool `yaml:"sendStateFuzz"`
SendRoundQCFuzz bool `yaml:"sendRoundQCFuzz"`
sendPrecommitInStateFuzz bool `yaml:"sendPrecommitInStateFuzz"`
sendPrevoteInStateFuzz bool `yaml:"sendPrevoteInStateFuzz"`
sendProposalInStateFuzz bool `yaml:"sendProposalInStateFuzz"`
sendPrecommitOfRoundFuzz bool `yaml:"sendPrecommitOfRoundFuzz"`
sendPrevoteOfRoundFuzz bool `yaml:"sendPrevoteOfRoundFuzz"`
sendProposalOfRoundFuzz bool `yaml:"sendProposalOfRoundFuzz"`
OthersFuzz bool `yaml:"othersFuzz"`
Delay bool `yaml:"delay"`
DelayBase int `yaml:"delayBase"`
DelayLim int `yaml:"delayLim"`
}
func GetConfig() *NodeConfig {
config := NodeConfig{}
dataBytes, err := os.ReadFile(addr)
if err != nil {
return nil
}
err = yaml.Unmarshal(dataBytes, &config)
if err != nil {
return nil
}
return &config
}
func (c *NodeConfig) ToString() string {
return fmt.Sprintf("FuzzConfig{IsFuzzNode:%t, procProposeFuzz:%t, SendProposeStateFuzz:%t, CommitBlockFuzz:%t, delInvalidTxsFuzz:%t, enterPrevoteFuzz:%t, enterPrecommitFuzz:%t, delay:%t}",
c.IsFuzzNode, c.ProcProposeFuzz, c.SendProposeStateFuzz, c.CommitBlockFuzz, c.DelInvalidTxsFuzz, c.EnterPrevoteFuzz, c.EnterPrecommitFuzz, c.Delay)
}