Skip to content

Commit

Permalink
URLs clean
Browse files Browse the repository at this point in the history
up
  • Loading branch information
daria305 committed Jan 29, 2024
1 parent d676b99 commit e09decb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
4 changes: 3 additions & 1 deletion components/accounts/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func run() error {
}),
)
if err != nil {
Component.LogPanic(err.Error())
Component.LogError(err.Error())

return err
}

accountsSubcommandsFlags := parseAccountCommands(getCommands(os.Args[2:]), ParamsAccounts)
Expand Down
1 change: 1 addition & 0 deletions components/info/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func Run() error {
if err != nil {
return err
}

err = info.Run(ParamsTool, ParamsInfo, logger)
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion components/spammer/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ func run() error {
}),
)
if err != nil {
Component.LogPanic(err.Error())
Component.LogErrorf(err.Error())

return err
}

programs.RunSpammer(
Component.Daemon().ContextStopped(),
Component.Logger,
ParamsTool.NodeURLs,
ParamsTool.FaucetURL,
ParamsSpammer,
accWallet)

Expand Down
3 changes: 3 additions & 0 deletions pkg/accountmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func newManager(logger log.Logger, opts ...options.Option[Manager]) (*Manager, e
err := m.setupClient()
if err != nil {
innerErr = err

return
}

m.setupGenesisAccount()
Expand All @@ -92,6 +94,7 @@ func (m *Manager) setupClient() error {

return ierrors.Wrap(err, "failed to create web client")
}

m.API = m.Client.LatestAPI()

return nil
Expand Down
11 changes: 6 additions & 5 deletions pkg/evilwallet/evilwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const (
)

var (
defaultClientsURLs = []string{"http://localhost:8050"}
defaultFaucetURL = "http://localhost:8088"

NoFreshOutputsAvailable = ierrors.New("no fresh wallet is available")
)

Expand Down Expand Up @@ -62,8 +59,6 @@ func NewEvilWallet(logger log.Logger, opts ...options.Option[EvilWallet]) *EvilW
wallets: NewWallets(),
aliasManager: NewAliasManager(),
minOutputStorageDeposit: MinOutputStorageDeposit,
optsClientURLs: defaultClientsURLs,
optsFaucetURL: defaultFaucetURL,
}, opts, func(w *EvilWallet) {
connector := lo.PanicOnErr(models.NewWebClients(w.optsClientURLs, w.optsFaucetURL))
w.connector = connector
Expand Down Expand Up @@ -672,6 +667,12 @@ func WithClients(urls ...string) options.Option[EvilWallet] {
}
}

func WithFaucetClient(url string) options.Option[EvilWallet] {
return func(opts *EvilWallet) {
opts.optsFaucetURL = url
}
}

func WithAccountsManager(manager *accountmanager.Manager) options.Option[EvilWallet] {
return func(opts *EvilWallet) {
opts.accManager = manager
Expand Down
5 changes: 2 additions & 3 deletions pkg/spammer/spammer.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@ func (s *Spammer) setup() {
switch s.SpamType {
case SpamEvilWallet:
if s.EvilWallet == nil {
s.EvilWallet = evilwallet.NewEvilWallet(s.Logger)
panic("evil wallet is nil")
}

s.Clients = s.EvilWallet.Connector()
// case SpamCommitments:
// s.CommitmentManager.Setup(s.log)
}
s.setupSpamDetails()

Expand Down
9 changes: 5 additions & 4 deletions programs/spammers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
"github.com/iotaledger/evil-tools/pkg/spammer"
)

func RunSpammer(ctx context.Context, logger log.Logger, nodeURLs []string, paramsSpammer *spammer.ParametersSpammer, accManager *accountmanager.Manager) {
w := evilwallet.NewEvilWallet(logger, evilwallet.WithClients(nodeURLs...), evilwallet.WithAccountsManager(accManager))
func RunSpammer(ctx context.Context, logger log.Logger, nodeURLs []string, faucetURL string, paramsSpammer *spammer.ParametersSpammer, accManager *accountmanager.Manager) {
fmt.Println("RunSpammer")
w := evilwallet.NewEvilWallet(logger, evilwallet.WithClients(nodeURLs...), evilwallet.WithAccountsManager(accManager), evilwallet.WithFaucetClient(faucetURL))
wg := sync.WaitGroup{}

logger.LogInfof("Start spamming with rate: %d, spamming type: %s.", paramsSpammer.Rate, paramsSpammer.Type)
Expand Down Expand Up @@ -125,8 +126,8 @@ func SpamTransaction(logger log.Logger, w *evilwallet.EvilWallet, paramsSpammer
}

func SpamDoubleSpends(logger log.Logger, w *evilwallet.EvilWallet, paramsSpammer *spammer.ParametersSpammer) *spammer.Spammer {
if w.NumOfClient() < 2 {
logger.LogInfof("Warning: At least two client are needed to spam, and %d was provided", w.NumOfClient())
if w.NumOfClient() < 1 {
logger.LogInfo("Warning: At least one client are needed to spam")
}

scenarioOptions := []evilwallet.ScenarioOption{
Expand Down

0 comments on commit e09decb

Please sign in to comment.