diff --git a/components/dashboard/jsonresponse.go b/components/dashboard/jsonresponse.go index f8b1558ce..4819642b6 100644 --- a/components/dashboard/jsonresponse.go +++ b/components/dashboard/jsonresponse.go @@ -99,10 +99,10 @@ func NewOutputID(outputID iotago.OutputID) *OutputID { // } // // NewOutputMetadata returns the OutputMetadata from the given mempool.OutputMetadata. -// func NewOutputMetadata(outputMetadata *mempool.OutputMetadata, confirmedConsumerID utxo.SignedTransactionID) *OutputMetadata { +// func NewOutputMetadata(outputMetadata *mempool.OutputMetadata, confirmedConsumerID utxo.TransactionID) *OutputMetadata { // return &OutputMetadata{ // OutputID: NewOutputID(outputMetadata.ID()), -// ConflictIDs: lo.Map(lo.Map(outputMetadata.ConflictIDs().Slice(), func(t utxo.SignedTransactionID) []byte { +// ConflictIDs: lo.Map(lo.Map(outputMetadata.ConflictIDs().Slice(), func(t utxo.TransactionID) []byte { // return lo.PanicOnErr(t.Bytes()) // }), base58.Encode), // FirstConsumer: outputMetadata.FirstConsumer().Base58(), diff --git a/pkg/testsuite/transactions.go b/pkg/testsuite/transactions.go index bea757ef6..08fe93fb5 100644 --- a/pkg/testsuite/transactions.go +++ b/pkg/testsuite/transactions.go @@ -12,31 +12,31 @@ import ( iotago "github.com/iotaledger/iota.go/v4" ) -func (t *TestSuite) AssertTransaction(transaction *iotago.SignedTransaction, node *mock.Node) mempool.Transaction { - var loadedTransaction mempool.TransactionMetadata - transactionID, err := transaction.ID() +func (t *TestSuite) AssertTransaction(signedTransaction *iotago.SignedTransaction, node *mock.Node) mempool.Transaction { + var loadedTransactionMetadata mempool.TransactionMetadata + signedTransactionID, err := signedTransaction.ID() require.NoError(t.Testing, err) t.Eventually(func() error { var exists bool - loadedTransaction, exists = node.Protocol.MainEngineInstance().Ledger.TransactionMetadata(transactionID) + loadedTransactionMetadata, exists = node.Protocol.MainEngineInstance().Ledger.TransactionMetadata(signedTransactionID) if !exists { - return ierrors.Errorf("AssertTransaction: %s: transaction %s does not exist", node.Name, transactionID) + return ierrors.Errorf("AssertTransaction: %s: signedTransaction %s does not exist", node.Name, signedTransactionID) } - if transactionID != loadedTransaction.ID() { - return ierrors.Errorf("AssertTransaction: %s: expected ID %s, got %s", node.Name, transactionID, loadedTransaction.ID()) + if signedTransactionID != loadedTransactionMetadata.ID() { + return ierrors.Errorf("AssertTransaction: %s: expected ID %s, got %s", node.Name, signedTransactionID, loadedTransactionMetadata.ID()) } //nolint: forcetypeassert // we are in a test and want to assert it anyway - if !cmp.Equal(transaction.Transaction, loadedTransaction.Transaction().(*iotago.SignedTransaction).Transaction) { - return ierrors.Errorf("AssertTransaction: %s: expected %s, got %s", node.Name, transaction, loadedTransaction.Transaction()) + if !cmp.Equal(signedTransaction.Transaction, loadedTransactionMetadata.Transaction().(*iotago.SignedTransaction).Transaction) { + return ierrors.Errorf("AssertTransaction: %s: expected %s, got %s", node.Name, signedTransaction, loadedTransactionMetadata.Transaction()) } return nil }) - return loadedTransaction.Transaction() + return loadedTransactionMetadata.Transaction() } func (t *TestSuite) AssertTransactionsExist(transactions []*iotago.SignedTransaction, expectedExist bool, nodes ...*mock.Node) { diff --git a/tools/evil-spammer/spammer/spammer.go b/tools/evil-spammer/spammer/spammer.go index f7f0b70ab..19333aa2d 100644 --- a/tools/evil-spammer/spammer/spammer.go +++ b/tools/evil-spammer/spammer/spammer.go @@ -224,16 +224,16 @@ func (s *Spammer) StopSpamming() { // PostTransaction use provided client to issue a transaction. It chooses API method based on Spammer options. Counts errors, // counts transactions and provides debug logs. -func (s *Spammer) PostTransaction(tx *iotago.SignedTransaction, clt wallet.Client) { - if tx == nil { +func (s *Spammer) PostTransaction(signedTx *iotago.SignedTransaction, clt wallet.Client) { + if signedTx == nil { s.log.Debug(ErrTransactionIsNil) s.ErrCounter.CountError(ErrTransactionIsNil) return } - txID := lo.PanicOnErr(tx.ID()) - allSolid := s.handleSolidityForReuseOutputs(clt, tx) + txID := lo.PanicOnErr(signedTx.ID()) + allSolid := s.handleSolidityForReuseOutputs(clt, signedTx) if !allSolid { s.log.Debug(ErrInputsNotSolid) s.ErrCounter.CountError(ierrors.Wrapf(ErrInputsNotSolid, "txID: %s", txID.ToHex())) @@ -241,7 +241,7 @@ func (s *Spammer) PostTransaction(tx *iotago.SignedTransaction, clt wallet.Clien return } - blockID, err := clt.PostTransaction(tx) + blockID, err := clt.PostTransaction(signedTx) if err != nil { s.log.Debug(ierrors.Wrapf(ErrFailPostTransaction, err.Error())) s.ErrCounter.CountError(ierrors.Wrapf(ErrFailPostTransaction, err.Error())) @@ -250,7 +250,7 @@ func (s *Spammer) PostTransaction(tx *iotago.SignedTransaction, clt wallet.Clien } if s.EvilScenario.OutputWallet.Type() == wallet.Reuse { var outputIDs iotago.OutputIDs - for index := range tx.Transaction.Outputs { + for index := range signedTx.Transaction.Outputs { outputIDs = append(outputIDs, iotago.OutputIDFromTransactionIDAndIndex(txID, uint16(index))) } s.EvilWallet.SetTxOutputsSolid(outputIDs, clt.URL()) diff --git a/tools/evil-spammer/wallet/evilwallet.go b/tools/evil-spammer/wallet/evilwallet.go index d07edbf19..05e41ae6f 100644 --- a/tools/evil-spammer/wallet/evilwallet.go +++ b/tools/evil-spammer/wallet/evilwallet.go @@ -291,27 +291,27 @@ func (e *EvilWallet) requestFaucetFunds(wallet *Wallet) (outputID *Output, err e txBuilder.AddTaggedDataPayload(&iotago.TaggedData{Tag: []byte("faucet funds"), Data: []byte("to addr" + receiveAddr.String())}) txBuilder.SetCreationSlot(clt.CurrentAPI().TimeProvider().SlotFromTime(time.Now())) - tx, err := txBuilder.Build(e.faucet.AddressSigner(faucetAddr)) + signedTx, err := txBuilder.Build(e.faucet.AddressSigner(faucetAddr)) if err != nil { return nil, err } // send transaction - _, err = clt.PostTransaction(tx) + _, err = clt.PostTransaction(signedTx) if err != nil { return nil, err } // requested output to split and use in spammer - output := e.outputManager.CreateOutputFromAddress(wallet, receiveAddr, faucetTokensPerRequest, iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(tx.ID()), 0), tx.Transaction.Outputs[0]) + output := e.outputManager.CreateOutputFromAddress(wallet, receiveAddr, faucetTokensPerRequest, iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(signedTx.ID()), 0), signedTx.Transaction.Outputs[0]) // set remainder output to be reused by the faucet wallet e.faucet.AddUnspentOutput(&Output{ - OutputID: iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(tx.ID()), 1), + OutputID: iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(signedTx.ID()), 1), Address: faucetAddr, Index: 0, - Balance: tx.Transaction.Outputs[1].BaseTokenAmount(), - OutputStruct: tx.Transaction.Outputs[1], + Balance: signedTx.Transaction.Outputs[1].BaseTokenAmount(), + OutputStruct: signedTx.Transaction.Outputs[1], }) return output, nil @@ -325,18 +325,18 @@ func (e *EvilWallet) splitOutputs(splitOutput *Output, inputWallet, outputWallet input, outputs := e.handleInputOutputDuringSplitOutputs(splitOutput, FaucetRequestSplitNumber, outputWallet) - tx, err := e.CreateTransaction(WithInputs(input), WithOutputs(outputs), WithIssuer(inputWallet), WithOutputWallet(outputWallet)) + signedTx, err := e.CreateTransaction(WithInputs(input), WithOutputs(outputs), WithIssuer(inputWallet), WithOutputWallet(outputWallet)) if err != nil { return iotago.TransactionID{}, err } - _, err = e.connector.GetClient().PostTransaction(tx) + _, err = e.connector.GetClient().PostTransaction(signedTx) if err != nil { fmt.Println(err) return iotago.TransactionID{}, err } - return lo.PanicOnErr(tx.ID()), nil + return lo.PanicOnErr(signedTx.ID()), nil } func (e *EvilWallet) handleInputOutputDuringSplitOutputs(splitOutput *Output, splitNumber int, receiveWallet *Wallet) (input *Output, outputs []*OutputOption) { @@ -396,9 +396,9 @@ func (e *EvilWallet) SendCustomConflicts(conflictsMaps []ConflictSlice) (err err wg := sync.WaitGroup{} for i, tx := range txs { wg.Add(1) - go func(clt Client, tx *iotago.SignedTransaction) { + go func(clt Client, signedTx *iotago.SignedTransaction) { defer wg.Done() - _, _ = clt.PostTransaction(tx) + _, _ = clt.PostTransaction(signedTx) }(clients[i], tx) } wg.Wait() @@ -414,7 +414,7 @@ func (e *EvilWallet) SendCustomConflicts(conflictsMaps []ConflictSlice) (err err // Inputs of the transaction are determined in three ways: // 1 - inputs are provided directly without associated alias, 2- alias is provided, and input is already stored in an alias manager, // 3 - alias is provided, and there are no inputs assigned in Alias manager, so aliases are assigned to next ready inputs from input wallet. -func (e *EvilWallet) CreateTransaction(options ...Option) (tx *iotago.SignedTransaction, err error) { +func (e *EvilWallet) CreateTransaction(options ...Option) (signedTx *iotago.SignedTransaction, err error) { buildOptions, err := NewOptions(options...) if err != nil { return nil, err @@ -445,23 +445,23 @@ func (e *EvilWallet) CreateTransaction(options ...Option) (tx *iotago.SignedTran } } - tx, err = e.makeTransaction(inputs, outputs, buildOptions.inputWallet) + signedTx, err = e.makeTransaction(inputs, outputs, buildOptions.inputWallet) if err != nil { return nil, err } - e.addOutputsToOutputManager(tx, buildOptions.outputWallet, tempWallet, tempAddresses) - e.registerOutputAliases(tx, addrAliasMap) + e.addOutputsToOutputManager(signedTx, buildOptions.outputWallet, tempWallet, tempAddresses) + e.registerOutputAliases(signedTx, addrAliasMap) return } // addOutputsToOutputManager adds output to the OutputManager if. -func (e *EvilWallet) addOutputsToOutputManager(tx *iotago.SignedTransaction, outWallet, tmpWallet *Wallet, tempAddresses map[string]types.Empty) { - for idx, o := range tx.Transaction.Outputs { +func (e *EvilWallet) addOutputsToOutputManager(signedTx *iotago.SignedTransaction, outWallet, tmpWallet *Wallet, tempAddresses map[string]types.Empty) { + for idx, o := range signedTx.Transaction.Outputs { addr := o.UnlockConditionSet().Address().Address out := &Output{ - OutputID: iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(tx.ID()), uint16(idx)), + OutputID: iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(signedTx.ID()), uint16(idx)), Address: addr, Balance: o.BaseTokenAmount(), OutputStruct: o, @@ -498,13 +498,13 @@ func (e *EvilWallet) updateInputWallet(buildOptions *Options) error { return nil } -func (e *EvilWallet) registerOutputAliases(tx *iotago.SignedTransaction, addrAliasMap map[string]string) { +func (e *EvilWallet) registerOutputAliases(signedTx *iotago.SignedTransaction, addrAliasMap map[string]string) { if len(addrAliasMap) == 0 { return } - for idx := range tx.Transaction.Outputs { - id := iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(tx.ID()), uint16(idx)) + for idx := range signedTx.Transaction.Outputs { + id := iotago.OutputIDFromTransactionIDAndIndex(lo.PanicOnErr(signedTx.ID()), uint16(idx)) out := e.outputManager.GetOutput(id) // register output alias @@ -741,9 +741,9 @@ func (e *EvilWallet) makeTransaction(inputs []*Output, outputs iotago.Outputs[io return txBuilder.Build(iotago.NewInMemoryAddressSigner(walletKeys...)) } -func (e *EvilWallet) PrepareCustomConflictsSpam(scenario *EvilScenario) (txs [][]*iotago.SignedTransaction, allAliases ScenarioAlias, err error) { +func (e *EvilWallet) PrepareCustomConflictsSpam(scenario *EvilScenario) (signedTxs [][]*iotago.SignedTransaction, allAliases ScenarioAlias, err error) { conflicts, allAliases := e.prepareConflictSliceForScenario(scenario) - txs, err = e.PrepareCustomConflicts(conflicts) + signedTxs, err = e.PrepareCustomConflicts(conflicts) return }