# Path: tests/test_custom.py
# class CustomAssertions:
# 
#     def assertDictEqualExt(self, result_dict, expected_dict, none_allowed=None):
#         """
#         Compare dictionaries, skip items not found in expected dictionary.
# 
#         Lists and recursion's in dictionaries are allowed.
# 
#         :param result_dict: First dictionary with results
#         :type result_dict: dict
#         :param expected_dict: Second dictionary with expected values
#         :type expected_dict: dict
#         :param none_allowed: List of fields for which None value in result_dict is allowed
#         :type none_allowed: list
# 
#         :return bool: Dictionaries are identical?
#         """
#         if none_allowed is None:
#             none_allowed = []
#         if not isinstance(expected_dict, dict):
#             if expected_dict == result_dict:
#                 return True
#             else:
#                 raise AssertionError("Different value for %s != %s" % (result_dict, expected_dict))
#         expected_keys = expected_dict.keys()
#         for k in result_dict:
#             if k not in expected_keys:
#                 continue
#             if isinstance(result_dict[k], dict):
#                 self.assertDictEqualExt(result_dict[k], expected_dict[k], none_allowed)
#             elif isinstance(result_dict[k], list):
#                 for i in range(len(result_dict[k])):
#                     if not isinstance(expected_dict[k], list):
#                         raise AssertionError("No list expected for %s attribute, expected '%s' but received: '%s'" %
#                                              (k, expected_dict[k], result_dict[k]))
#                     self.assertDictEqualExt(result_dict[k][i], expected_dict[k][i], none_allowed)
#             elif result_dict[k] != expected_dict[k]:
#                 if isinstance(result_dict[k], datetime):
#                     if result_dict[k].date() == expected_dict[k].date():
#                         continue
#                 if result_dict[k] is not None or k not in none_allowed:
#                     raise AssertionError("Different value for '%s': %s != %s" % (k, result_dict[k], expected_dict[k]))


from bitcoinlib.scripts import *
from tests.test_custom import CustomAssertions
import unittest
        self.assertEqual(decode_num(s.stack[0]), 7)

        s = Script([op.op_5, op.op_0, op.op_if, op.op_2, op.op_else, op.op_5, op.op_endif, op.op_add, op.op_1])
        self.assertTrue(s.evaluate())
        self.assertEqual(decode_num(s.stack[0]), 10)

        s = Script([op.op_5, op.op_1, op.op_notif, op.op_2, op.op_else, op.op_5, op.op_endif, op.op_add, op.op_1])
        self.assertTrue(s.evaluate())
        self.assertEqual(decode_num(s.stack[0]), 10)

        s = Script([op.op_5, op.op_0, op.op_notif, op.op_2, op.op_else, op.op_5, op.op_endif, op.op_add, op.op_1])
        self.assertTrue(s.evaluate())
        self.assertEqual(decode_num(s.stack[0]), 7)


class TestScriptTypes(unittest.TestCase):

    def test_script_type_p2pkh(self):
        s = Script.parse_hex('76a914af8e14a2cecd715c363b3a72b55b59a31e2acac988ac')
        self.assertEqual(['p2pkh'], s.script_types)

    def test_script_type_p2pkh_2(self):
        s = Script.parse_hex('76a914a13fdfc301c89094f5dc1089e61888794130e38188ac')
        self.assertEqual(['p2pkh'], s.script_types)

    def test_script_type_p2sh(self):
        s = Script.parse_bytes(bytes.fromhex('a914e3bdbeab033c7e03fd4cbf3a03ff14533260f3f487'))
        self.assertEqual(['p2sh'], s.script_types)

    def test_script_type_nulldata(self):

# Path: tests/test_custom.py
# class CustomAssertions:
# 
#     def assertDictEqualExt(self, result_dict, expected_dict, none_allowed=None):
#         """
#         Compare dictionaries, skip items not found in expected dictionary.
# 
#         Lists and recursion's in dictionaries are allowed.
# 
#         :param result_dict: First dictionary with results
#         :type result_dict: dict
#         :param expected_dict: Second dictionary with expected values
#         :type expected_dict: dict
#         :param none_allowed: List of fields for which None value in result_dict is allowed
#         :type none_allowed: list
# 
#         :return bool: Dictionaries are identical?
#         """
#         if none_allowed is None:
#             none_allowed = []
#         if not isinstance(expected_dict, dict):
#             if expected_dict == result_dict:
#                 return True
#             else:
#                 raise AssertionError("Different value for %s != %s" % (result_dict, expected_dict))
#         expected_keys = expected_dict.keys()
#         for k in result_dict:
#             if k not in expected_keys:
#                 continue
#             if isinstance(result_dict[k], dict):
#                 self.assertDictEqualExt(result_dict[k], expected_dict[k], none_allowed)
#             elif isinstance(result_dict[k], list):
#                 for i in range(len(result_dict[k])):
#                     if not isinstance(expected_dict[k], list):
#                         raise AssertionError("No list expected for %s attribute, expected '%s' but received: '%s'" %
#                                              (k, expected_dict[k], result_dict[k]))
#                     self.assertDictEqualExt(result_dict[k][i], expected_dict[k][i], none_allowed)
#             elif result_dict[k] != expected_dict[k]:
#                 if isinstance(result_dict[k], datetime):
#                     if result_dict[k].date() == expected_dict[k].date():
#                         continue
#                 if result_dict[k] is not None or k not in none_allowed:
#                     raise AssertionError("Different value for '%s': %s != %s" % (k, result_dict[k], expected_dict[k]))


# Path: tests/test_script.py
from bitcoinlib.scripts import *
from tests.test_custom import CustomAssertions
import unittest

        self.assertEqual(decode_num(s.stack[0]), 7)

        s = Script([op.op_5, op.op_0, op.op_if, op.op_2, op.op_else, op.op_5, op.op_endif, op.op_add, op.op_1])
        self.assertTrue(s.evaluate())
        self.assertEqual(decode_num(s.stack[0]), 10)

        s = Script([op.op_5, op.op_1, op.op_notif, op.op_2, op.op_else, op.op_5, op.op_endif, op.op_add, op.op_1])
        self.assertTrue(s.evaluate())
        self.assertEqual(decode_num(s.stack[0]), 10)

        s = Script([op.op_5, op.op_0, op.op_notif, op.op_2, op.op_else, op.op_5, op.op_endif, op.op_add, op.op_1])
        self.assertTrue(s.evaluate())
        self.assertEqual(decode_num(s.stack[0]), 7)


class TestScriptTypes(unittest.TestCase):

    def test_script_type_p2pkh(self):
        s = Script.parse_hex('76a914af8e14a2cecd715c363b3a72b55b59a31e2acac988ac')
        self.assertEqual(['p2pkh'], s.script_types)

    def test_script_type_p2pkh_2(self):
        s = Script.parse_hex('76a914a13fdfc301c89094f5dc1089e61888794130e38188ac')
        self.assertEqual(['p2pkh'], s.script_types)

    def test_script_type_p2sh(self):
        s = Script.parse_bytes(bytes.fromhex('a914e3bdbeab033c7e03fd4cbf3a03ff14533260f3f487'))
        self.assertEqual(['p2sh'], s.script_types)

    def test_script_type_nulldata(self):

        s = Script.parse_bytes(bytes.fromhex('6a20985f23805edd2938e5bd9f744d36ccb8be643de00b369b901ae0b3fea911a1dd'))