Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 11, 2024
1 parent be6672e commit a1940c3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions op-batcher/batcher/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ func TestChannelTimeout(t *testing.T) {
channel := m.currentChannel
require.NotNil(t, channel)

// add some pending txs, to be confirmed below
channel.pendingTransactions[zeroFrameTxID(0).String()] = txData{}
channel.pendingTransactions[zeroFrameTxID(1).String()] = txData{}
channel.pendingTransactions[zeroFrameTxID(2).String()] = txData{}

// There are no confirmed transactions so
// the pending channel cannot be timed out
timeout := channel.isTimedOut()
require.False(t, timeout)

// Manually set a confirmed transactions
// To avoid other methods clearing state
channel.confirmedTransactions[zeroFrameTxID(0).String()] = eth.BlockID{Number: 0}
channel.confirmedTransactions[zeroFrameTxID(1).String()] = eth.BlockID{Number: 99}
channel.updateInclusionBlocks()
// Manually confirm transactions
channel.TxConfirmed(zeroFrameTxID(0).String(), eth.BlockID{Number: 0})
channel.TxConfirmed(zeroFrameTxID(1).String(), eth.BlockID{Number: 99})

// Since the ChannelTimeout is 100, the
// pending channel should not be timed out
Expand All @@ -62,10 +65,7 @@ func TestChannelTimeout(t *testing.T) {

// Add a confirmed transaction with a higher number
// than the ChannelTimeout
channel.confirmedTransactions[zeroFrameTxID(2).String()] = eth.BlockID{
Number: 101,
}
channel.updateInclusionBlocks()
channel.TxConfirmed(zeroFrameTxID(2).String(), eth.BlockID{Number: 101})

// Now the pending channel should be timed out
timeout = channel.isTimedOut()
Expand Down

0 comments on commit a1940c3

Please sign in to comment.