Skip to content

Commit

Permalink
feat: add slot time as flag (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed May 10, 2024
1 parent 3a05fdd commit 75cb788
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/livefuzzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func spam(config *spammer.Config, spamFn spammer.Spam, airdropValue *big.Int) er
return err
}
spammer.SpamTransactions(config, spamFn)
time.Sleep(12 * time.Second)
time.Sleep(time.Duration(config.SlotTime) * time.Second)
}
}

Expand Down
7 changes: 7 additions & 0 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ var (
Value: 100_000,
}

SlotTimeFlag = &cli.IntFlag{
Name: "slot-time",
Usage: "Slot time in seconds",
Value: 12,
}

SpamFlags = []cli.Flag{
SkFlag,
SeedFlag,
Expand All @@ -59,5 +65,6 @@ var (
TxCountFlag,
CountFlag,
GasLimitFlag,
SlotTimeFlag,
}
)
4 changes: 4 additions & 0 deletions spammer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
corpus [][]byte // optional corpus to use elements from
accessList bool // whether to create accesslist transactions
gasLimit uint64 // gas limit per transaction
SlotTime uint64 // slot time in seconds

seed int64 // seed used for generating randomness
mut *mutator.Mutator // Mutator based on the seed
Expand Down Expand Up @@ -99,6 +100,8 @@ func NewConfigFromContext(c *cli.Context) (*Config, error) {
}
}

slotTime := c.Uint64(flags.SlotTimeFlag.Name)

// Setup seed
seed := c.Int64(flags.SeedFlag.Name)
if seed == 0 {
Expand Down Expand Up @@ -130,6 +133,7 @@ func NewConfigFromContext(c *cli.Context) (*Config, error) {
keys: keys,
corpus: corpus,
mut: mut,
SlotTime: slotTime,
}, nil
}

Expand Down

0 comments on commit 75cb788

Please sign in to comment.