From 75cb78863fbea6021d08622276255699eba1aaf0 Mon Sep 17 00:00:00 2001 From: Lorenzo <60553286+thedevbirb@users.noreply.github.com> Date: Fri, 10 May 2024 13:27:49 +0200 Subject: [PATCH] feat: add slot time as flag (#51) --- cmd/livefuzzer/main.go | 2 +- flags/flags.go | 7 +++++++ spammer/config.go | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/livefuzzer/main.go b/cmd/livefuzzer/main.go index 85be261..a0e5d32 100644 --- a/cmd/livefuzzer/main.go +++ b/cmd/livefuzzer/main.go @@ -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) } } diff --git a/flags/flags.go b/flags/flags.go index e96845d..76d8d42 100644 --- a/flags/flags.go +++ b/flags/flags.go @@ -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, @@ -59,5 +65,6 @@ var ( TxCountFlag, CountFlag, GasLimitFlag, + SlotTimeFlag, } ) diff --git a/spammer/config.go b/spammer/config.go index 33fc86a..e642a2c 100644 --- a/spammer/config.go +++ b/spammer/config.go @@ -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 @@ -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 { @@ -130,6 +133,7 @@ func NewConfigFromContext(c *cli.Context) (*Config, error) { keys: keys, corpus: corpus, mut: mut, + SlotTime: slotTime, }, nil }