Skip to content

Commit

Permalink
More unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Nov 1, 2024
1 parent 5a3fb74 commit 4b1ec6d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions txcache/wrappedTransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,35 @@ func TestWrappedTransaction_isTransactionMoreDesirableByProtocol(t *testing.T) {

require.True(t, a.isTransactionMoreDesirableByProtocol(b))
})

t.Run("decide by gas price (set them up to have the same PPU)", func(t *testing.T) {
a := createTx([]byte("a-2"), "a", 1).withGasPrice(oneBillion + 1)
b := createTx([]byte("b-2"), "b", 1).withGasPrice(oneBillion)

a.PricePerGasUnitQuotient = 42
b.PricePerGasUnitQuotient = 42
a.PricePerGasUnitRemainder = 0
b.PricePerGasUnitRemainder = 0

require.True(t, a.isTransactionMoreDesirableByProtocol(b))
})

t.Run("decide by gas limit (set them up to have the same PPU and gas price)", func(t *testing.T) {
a := createTx([]byte("a-2"), "a", 1).withGasLimit(55000)
b := createTx([]byte("b-2"), "b", 1).withGasLimit(60000)

a.PricePerGasUnitQuotient = 42
b.PricePerGasUnitQuotient = 42
a.PricePerGasUnitRemainder = 0
b.PricePerGasUnitRemainder = 0

require.True(t, a.isTransactionMoreDesirableByProtocol(b))
})

t.Run("decide by transaction hash (set them up to have the same PPU, gas price and gas limit)", func(t *testing.T) {
a := createTx([]byte("a-2"), "a", 1)
b := createTx([]byte("b-2"), "b", 1)

require.True(t, b.isTransactionMoreDesirableByProtocol(a))
})
}

0 comments on commit 4b1ec6d

Please sign in to comment.