Add test for a real arb
This commit is contained in:
parent
04ce01eb6b
commit
eb2530de45
1
tests/blocks/12914994.json
Normal file
1
tests/blocks/12914994.json
Normal file
File diff suppressed because one or more lines are too long
22
tests/test_arbitrage_integration.py
Normal file
22
tests/test_arbitrage_integration.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from mev_inspect.classifier_specs import CLASSIFIER_SPECS
|
||||||
|
from mev_inspect.trace_classifier import TraceClassifier
|
||||||
|
from mev_inspect.arbitrage import get_arbitrages
|
||||||
|
from mev_inspect.swaps import get_swaps
|
||||||
|
|
||||||
|
from .utils import load_test_block
|
||||||
|
|
||||||
|
|
||||||
|
def test_arbitrage_real_block():
|
||||||
|
block = load_test_block(12914994)
|
||||||
|
|
||||||
|
trace_clasifier = TraceClassifier(CLASSIFIER_SPECS)
|
||||||
|
classified_traces = trace_clasifier.classify(block.traces)
|
||||||
|
|
||||||
|
swaps = get_swaps(classified_traces)
|
||||||
|
arbitrages = get_arbitrages(swaps)
|
||||||
|
|
||||||
|
assert len(arbitrages) == 1
|
||||||
|
|
||||||
|
arbitrage = arbitrages[0]
|
||||||
|
|
||||||
|
assert len(arbitrage.swaps) == 3
|
@ -1,12 +1,8 @@
|
|||||||
import json
|
|
||||||
import os
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mev_inspect import tokenflow
|
from mev_inspect import tokenflow
|
||||||
from mev_inspect.schemas.blocks import Block
|
|
||||||
|
|
||||||
THIS_FILE_DIRECTORY = os.path.dirname(__file__)
|
from .utils import load_test_block
|
||||||
TEST_BLOCKS_DIRECTORY = os.path.join(THIS_FILE_DIRECTORY, "blocks")
|
|
||||||
|
|
||||||
|
|
||||||
class TestTokenFlow(unittest.TestCase):
|
class TestTokenFlow(unittest.TestCase):
|
||||||
@ -37,13 +33,5 @@ class TestTokenFlow(unittest.TestCase):
|
|||||||
self.assertEqual(res["dollar_flows"], [0, 0])
|
self.assertEqual(res["dollar_flows"], [0, 0])
|
||||||
|
|
||||||
|
|
||||||
def load_test_block(block_number):
|
|
||||||
block_path = f"{TEST_BLOCKS_DIRECTORY}/{block_number}.json"
|
|
||||||
|
|
||||||
with open(block_path, "r") as block_file:
|
|
||||||
block_json = json.load(block_file)
|
|
||||||
return Block(**block_json)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
16
tests/utils.py
Normal file
16
tests/utils.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
from mev_inspect.schemas.blocks import Block
|
||||||
|
|
||||||
|
|
||||||
|
THIS_FILE_DIRECTORY = os.path.dirname(__file__)
|
||||||
|
TEST_BLOCKS_DIRECTORY = os.path.join(THIS_FILE_DIRECTORY, "blocks")
|
||||||
|
|
||||||
|
|
||||||
|
def load_test_block(block_number: int) -> Block:
|
||||||
|
block_path = f"{TEST_BLOCKS_DIRECTORY}/{block_number}.json"
|
||||||
|
|
||||||
|
with open(block_path, "r") as block_file:
|
||||||
|
block_json = json.load(block_file)
|
||||||
|
return Block(**block_json)
|
Loading…
x
Reference in New Issue
Block a user