Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sequence sender unit tests #103

Merged
merged 12 commits into from
Oct 4, 2024
7 changes: 4 additions & 3 deletions sequencesender/ethtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/big"
"os"
"strings"
"sync/atomic"
"time"

"github.com/0xPolygon/cdk/log"
Expand Down Expand Up @@ -97,7 +98,7 @@ func (s *SequenceSender) sendTx(ctx context.Context, resend bool, txOldHash *com
log.Errorf("error getting result for tx %v: %v", txHash, err)
}
if !resend {
s.latestSentToL1Batch = valueToBatch
atomic.StoreUint64(&s.latestSentToL1Batch, valueToBatch)
} else {
s.ethTransactions[*txOldHash].Status = "*resent"
}
Expand All @@ -114,7 +115,7 @@ func (s *SequenceSender) sendTx(ctx context.Context, resend bool, txOldHash *com
// purgeEthTx purges transactions from memory structures
func (s *SequenceSender) purgeEthTx(ctx context.Context) {
// If sequence sending is stopped, do not purge
if s.seqSendingStopped {
if atomic.LoadUint32(&s.seqSendingStopped) == 1 {
return
}

Expand Down Expand Up @@ -275,7 +276,7 @@ func (s *SequenceSender) updateEthTxResult(txData *ethTxData, txResult types.Mon
txData.Status == types.MonitoredTxStatusFinalized.String()
if txData.Status == types.MonitoredTxStatusFailed.String() {
s.logFatalf("transaction %v result failed!")
} else if statusConsolidated && txData.ToBatch >= s.latestVirtualBatchNumber {
} else if statusConsolidated && txData.ToBatch >= atomic.LoadUint64(&s.latestVirtualBatchNumber) {
s.latestVirtualTime = txData.StatusTimestamp
}
}
Expand Down
Loading
Loading