Skip to content

Commit

Permalink
feat: fixes p2p test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Jul 8, 2024
1 parent fb18f26 commit 1a4badd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions p2p/pkg/preconfirmation/tracker/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ type Tracker struct {
newL1Blocks chan *blocktracker.BlocktrackerNewL1Block
enryptedCmts chan *preconfcommstore.PreconfcommitmentstoreEncryptedCommitmentStored
commitments chan *preconfcommstore.PreconfcommitmentstoreCommitmentStored
winners map[int64]*blocktracker.BlocktrackerNewL1Block
metrics *metrics
logger *slog.Logger
winners map[int64]*blocktracker.BlocktrackerNewL1Block
metrics *metrics
logger *slog.Logger
}

type OptsGetter func(context.Context) (*bind.TransactOpts, error)
Expand All @@ -60,6 +60,7 @@ type PreconfContract interface {
bid *big.Int,
blockNumber uint64,
txnHash string,
revertingTxHashes string,
decayStartTimeStamp uint64,
decayEndTimeStamp uint64,
bidSignature []byte,
Expand Down Expand Up @@ -89,9 +90,9 @@ func NewTracker(
newL1Blocks: make(chan *blocktracker.BlocktrackerNewL1Block),
enryptedCmts: make(chan *preconfcommstore.PreconfcommitmentstoreEncryptedCommitmentStored),
commitments: make(chan *preconfcommstore.PreconfcommitmentstoreCommitmentStored),
winners: make(map[int64]*blocktracker.BlocktrackerNewL1Block),
metrics: newMetrics(),
logger: logger,
winners: make(map[int64]*blocktracker.BlocktrackerNewL1Block),
metrics: newMetrics(),
logger: logger,
}
}

Expand Down Expand Up @@ -324,6 +325,7 @@ func (t *Tracker) handleNewL1Block(
bidAmt,
uint64(commitment.PreConfirmation.Bid.BlockNumber),
commitment.PreConfirmation.Bid.TxHash,
commitment.PreConfirmation.Bid.RevertingTxHashes,
uint64(commitment.PreConfirmation.Bid.DecayStartTimestamp),
uint64(commitment.PreConfirmation.Bid.DecayEndTimestamp),
commitment.PreConfirmation.Bid.Signature,
Expand Down
8 changes: 8 additions & 0 deletions p2p/pkg/preconfirmation/tracker/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func TestTracker(t *testing.T) {
DecayStartTimeStamp: uint64(commitments[4].PreConfirmation.Bid.DecayStartTimestamp),
DecayEndTimeStamp: uint64(commitments[4].PreConfirmation.Bid.DecayEndTimestamp),
TxnHash: commitments[4].PreConfirmation.Bid.TxHash,
RevertingTxHashes: commitments[4].PreConfirmation.Bid.RevertingTxHashes,
CommitmentHash: common.BytesToHash(commitments[4].PreConfirmation.Digest),
BidSignature: commitments[4].PreConfirmation.Bid.Signature,
CommitmentSignature: commitments[4].PreConfirmation.Signature,
Expand Down Expand Up @@ -280,6 +281,9 @@ func TestTracker(t *testing.T) {
oc.decayStartTimeStamp,
)
}
if c.PreConfirmation.Bid.RevertingTxHashes != oc.revertingTxHashes {
t.Fatalf("expected reverting tx hashes %s, got %s", c.PreConfirmation.Bid.RevertingTxHashes, oc.revertingTxHashes)
}
if c.PreConfirmation.Bid.DecayEndTimestamp != int64(oc.decayEndTimeStamp) {
t.Fatalf("expected decay end timestamp %d, got %d", c.PreConfirmation.Bid.DecayEndTimestamp, oc.decayEndTimeStamp)
}
Expand Down Expand Up @@ -316,6 +320,7 @@ type openedCommitment struct {
bid *big.Int
blockNumber uint64
txnHash string
revertingTxHashes string
decayStartTimeStamp uint64
decayEndTimeStamp uint64
bidSignature []byte
Expand All @@ -333,6 +338,7 @@ func (t *testPreconfContract) OpenCommitment(
bid *big.Int,
blockNumber uint64,
txnHash string,
revertingTxHashes string,
decayStartTimeStamp uint64,
decayEndTimeStamp uint64,
bidSignature []byte,
Expand All @@ -344,6 +350,7 @@ func (t *testPreconfContract) OpenCommitment(
bid: bid,
blockNumber: blockNumber,
txnHash: txnHash,
revertingTxHashes: revertingTxHashes,
decayStartTimeStamp: decayStartTimeStamp,
decayEndTimeStamp: decayEndTimeStamp,
bidSignature: bidSignature,
Expand Down Expand Up @@ -417,6 +424,7 @@ func publishCommitment(
c.DecayStartTimeStamp,
c.DecayEndTimeStamp,
c.TxnHash,
c.RevertingTxHashes,
c.CommitmentHash,
c.BidSignature,
c.CommitmentSignature,
Expand Down

0 comments on commit 1a4badd

Please sign in to comment.