Skip to content

Commit

Permalink
Re-add test, comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hbandura committed Jan 22, 2024
1 parent 9635114 commit 3a9fda2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/tx_multicurrency_priceheap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,34 @@ func TestClear(t *testing.T) {
assert.Nil(t, m.Pop())
}

func TestIsCheaper_FwdFields(t *testing.T) {
// Tests that the CurrencyCmpFn receives the
// proper fields for comparison in a gas fee cap cmp
curr1 := common.BigToAddress(big.NewInt(123))
price1 := big.NewInt(100)
curr2 := common.BigToAddress(big.NewInt(123))
price2 := big.NewInt(200)
tx1 := types.NewTx(&types.LegacyTx{
GasPrice: price1,
FeeCurrency: &curr1,
})
tx2 := types.NewTx(&types.LegacyTx{
GasPrice: price2,
FeeCurrency: &curr2,
})
var cmp CurrencyCmpFn = func(p1 *big.Int, c1 *common.Address, p2 *big.Int, c2 *common.Address) int {
assert.Equal(t, price1, p1)
assert.Equal(t, price2, p2)
assert.Equal(t, curr1, *c1)
assert.Equal(t, curr2, *c2)
return -1
}
assert.True(t, cmp.Cmp(tx1, tx2, nil, nil) == -1)
}

func TestIsCheaper(t *testing.T) {
// Tests that the result of the currency comparison function is
// properly being returned in the tx comparison function
tx1 := types.NewTx(&types.LegacyTx{})
tx2 := types.NewTx(&types.LegacyTx{})
var cheaper CurrencyCmpFn = func(p1 *big.Int, c1 *common.Address, p2 *big.Int, c2 *common.Address) int {
Expand Down

0 comments on commit 3a9fda2

Please sign in to comment.