feature_framework_unit_tests.py raw

   1  #!/usr/bin/env python3
   2  # Copyright (c) 2017-2024 The Limenka developers
   3  # Distributed under the MIT software license, see the accompanying
   4  # file COPYING or http://www.opensource.org/licenses/mit-license.php.
   5  """Framework unit tests
   6  
   7  Unit tests for the test framework.
   8  """
   9  
  10  import sys
  11  import unittest
  12  
  13  from test_framework.test_framework import TEST_EXIT_PASSED, TEST_EXIT_FAILED
  14  
  15  # List of framework modules containing unit tests. Should be kept in sync with
  16  # the output of `git grep unittest.TestCase ./test/functional/test_framework`
  17  TEST_FRAMEWORK_MODULES = [
  18      "address",
  19      "crypto.bip324_cipher",
  20      "blocktools",
  21      "crypto.chacha20",
  22      "crypto.ellswift",
  23      "key",
  24      "messages",
  25      "crypto.muhash",
  26      "crypto.poly1305",
  27      "crypto.ripemd160",
  28      "crypto.secp256k1",
  29      "script",
  30      "script_util",
  31      "segwit_addr",
  32      "wallet_util",
  33  ]
  34  
  35  
  36  def run_unit_tests():
  37      test_framework_tests = unittest.TestSuite()
  38      for module in TEST_FRAMEWORK_MODULES:
  39          test_framework_tests.addTest(
  40              unittest.TestLoader().loadTestsFromName(f"test_framework.{module}")
  41          )
  42      result = unittest.TextTestRunner(stream=sys.stdout, verbosity=1, failfast=True).run(
  43          test_framework_tests
  44      )
  45      if not result.wasSuccessful():
  46          sys.exit(TEST_EXIT_FAILED)
  47      sys.exit(TEST_EXIT_PASSED)
  48  
  49  
  50  if __name__ == "__main__":
  51      run_unit_tests()
  52  
  53