import unittest import os from manticore.ethereum import ManticoreEVM, IntegerOverflow THIS_DIR = os.path.dirname(os.path.abspath(__file__)) # FIXME(mark): Remove these two lines when logging works for ManticoreEVM from manticore.utils.log import init_logging init_logging() class EthDetectors(unittest.TestCase): def test_int_ovf(self): mevm = ManticoreEVM() mevm.register_detector(IntegerOverflow()) filename = os.path.join(THIS_DIR, 'binaries/int_overflow.sol') mevm.multi_tx_analysis(filename) self.assertEqual(len(mevm.global_findings), 3) all_findings = ''.join(map(lambda x: x[2], mevm.global_findings)) self.assertIn('underflow at SUB', all_findings) self.assertIn('overflow at ADD', all_findings) self.assertIn('overflow at MUL', all_findings)