"""release node formula == independent C per-checkpoint simulation (every checkpoint to END+5): all year-end cumulatives, every epoch's first reward, final, total""" import subprocess, os, sys, importlib.util as u, json HERE = os.path.dirname(os.path.abspath(__file__)) s = u.spec_from_file_location("n", os.path.join(HERE, "..", "..", "node", "eddycoin_node.py")); m = u.module_from_spec(s); s.loader.exec_module(m) out = subprocess.run([os.path.join(HERE, "emission_fullsim"), str(m.EM_F0), str(m.EM_C), str(m.EM_Q)], capture_output=True, text=True, check=True).stdout.splitlines() bad = n = 0 for l in out: p = l.split() if p[0] == "Y": n += 1; bad += int(p[2]) != m.emission_cum(int(p[1])) elif p[0] == "R": n += 1; bad += int(p[2]) != m.emission_reward(int(p[1])) elif p[0] == "FINAL": h = int(p[1].split("=")[1]); r = int(p[2].split("=")[1]); n += 1; bad += r != m.emission_reward(h) elif p[0] == "TOTAL": tot = int(p[1]); n += 1; bad += not (tot == m.MAX_SUPPLY == m.emission_cum(m.EM_END + 5) and "cap_exact=1" in l) else: bad += 1; print("C sim:", l) ok = bad == 0 and n > 13000 and m.emission_reward(1) == 15944366220 and m.reward_split(15944366220, 0) == (7972183110, 7972183110) res = {"test": "emission release node == C full simulation", "compared": n, "mismatches": bad, "first_reward": m.emission_reward(1), "split": m.reward_split(15944366220, 0), "PASS": ok} print(json.dumps(res)); sys.exit(0 if ok else 1)