def test_complex_policy_1(self):
        expected_result = bytearray.fromhex(
            "DFFDB6C8EAFCBE691E358882B18703121EAB40DE2386F7A8E7B4A06591E1F0EE")

        # Computation details:
        #   A = TPM2_PolicyLocality(3 & 4)
        #   B = TPM2_PolicyCommandCode(TPM_CC_NV_UndefineSpaceSpecial)
        #   C = TPM2_PolicyCommandCode(TPM_CC_NV_Write)
        #   policy = {{A} AND {C}} OR {{A} AND {B}}

        a = t2pc.PolicyLocality([3, 4])
        b = t2pc.PolicyCommandCode('TPM_CC_NV_UndefineSpaceSpecial')
        c = t2pc.PolicyCommandCode('TPM_CC_NV_Write')

        leg1 = t2pc.PolicyTreeAnd([a, c])
        leg2 = t2pc.PolicyTreeAnd([a, b])
        final = t2pc.PolicyTreeOr([leg1, leg2])

        phash = t2pc.PolicyHasher('sha256')
        self.assertEqual(final.get_policy(phash), expected_result)
    def test_single_and_should_match_solo(self):
        soloTest = t2pc.PolicyTreeSolo(t2pc.PolicyCommandCode("TPM_CC_Clear"))
        andTest = t2pc.PolicyTreeAnd([t2pc.PolicyCommandCode("TPM_CC_Clear")])

        phash = t2pc.PolicyHasher('sha256')
        self.assertEqual(soloTest.get_policy(phash), andTest.get_policy(phash))