@@ -1420,3 +1420,72 @@ def test_multi_transaction_via_compare_traces(
14201420 result = comparator .compare_traces (baseline , current )
14211421 assert result .equivalent is False
14221422 assert all (d .transaction_index == 1 for d in result .differences )
1423+
1424+ @pytest .mark .parametrize (
1425+ "error" ,
1426+ ["out of gas" , "Out Of Gas" , "OutOfGasError" ],
1427+ )
1428+ def test_oog_detected_for_each_convention (
1429+ self ,
1430+ comparator : GasExhaustionTraceComparator ,
1431+ error : str ,
1432+ ) -> None :
1433+ """OOG detection covers both geth-style and EELS-style errors."""
1434+ baseline = _make_transaction_traces (
1435+ [_make_trace_line (), _make_trace_line (error = error )]
1436+ )
1437+ current = _make_transaction_traces (
1438+ [_make_trace_line (), _make_trace_line ()]
1439+ )
1440+ result = comparator .compare_transaction_traces (baseline , current , 0 )
1441+ assert result .equivalent is False
1442+ assert len (result .differences ) == 1
1443+ assert result .differences [0 ].trace_line_index == 1
1444+
1445+ def test_mixed_geth_and_eels_oog_is_equivalent (
1446+ self , comparator : GasExhaustionTraceComparator
1447+ ) -> None :
1448+ """
1449+ Baseline (geth-style "out of gas") and current (EELS-style
1450+ "OutOfGasError") describe the same OOG event and are equivalent.
1451+ """
1452+ baseline = _make_transaction_traces (
1453+ [_make_trace_line (), _make_trace_line (error = "out of gas" )]
1454+ )
1455+ current = _make_transaction_traces (
1456+ [_make_trace_line (), _make_trace_line (error = "OutOfGasError" )]
1457+ )
1458+ result = comparator .compare_transaction_traces (baseline , current , 0 )
1459+ assert result .equivalent is True
1460+
1461+ def test_all_eels_oog_at_same_line_is_equivalent (
1462+ self , comparator : GasExhaustionTraceComparator
1463+ ) -> None :
1464+ """Two EELS-style traces with OOG at the same line are equivalent."""
1465+ oog_line = _make_trace_line (error = "OutOfGasError" )
1466+ baseline = _make_transaction_traces ([_make_trace_line (), oog_line ])
1467+ current = _make_transaction_traces ([_make_trace_line (), oog_line ])
1468+ result = comparator .compare_transaction_traces (baseline , current , 0 )
1469+ assert result .equivalent is True
1470+
1471+ def test_all_eels_oog_at_different_lines (
1472+ self , comparator : GasExhaustionTraceComparator
1473+ ) -> None :
1474+ """Two EELS-style traces with OOG at different lines differ."""
1475+ baseline = _make_transaction_traces (
1476+ [
1477+ _make_trace_line (),
1478+ _make_trace_line (error = "OutOfGasError" ),
1479+ _make_trace_line (),
1480+ ]
1481+ )
1482+ current = _make_transaction_traces (
1483+ [
1484+ _make_trace_line (),
1485+ _make_trace_line (),
1486+ _make_trace_line (error = "OutOfGasError" ),
1487+ ]
1488+ )
1489+ result = comparator .compare_transaction_traces (baseline , current , 0 )
1490+ assert result .equivalent is False
1491+ assert len (result .differences ) == 2
0 commit comments