def init_environment(): """ This runs before every test """ global interface interface = make_interface("ganache") mainblocks = 100 fork_index = 50 forkblocks = 100 pt = ProofTool("../data/proofs/") ( proof_name, fork_name, lca, fork_header, fork_header_map, fork_interlink_map, ) = pt.create_proof_and_forkproof(mainblocks, fork_index, forkblocks) global proof proof = Proof() proof.set(pt.fetch_proof_by_name(proof_name)) global fork fork = Proof() fork.set( pt.fetch_proof_by_name(fork_name), header=fork_header, header_map=fork_header_map, interlink_map=fork_interlink_map, )
def main(): """ Test for backends """ proof_tool = ProofTool("../data/proofs/") proof_tool.fetch_proof(80) (submit_n, contest_n, _, _, _, _) = proof_tool.create_proof_and_forkproof(80, 10, 25) proof = Proof() proof.set(proof_tool.fetch_proof_by_name(submit_n)) c_proof = Proof() c_proof.set(proof_tool.fetch_proof_by_name(contest_n)) interface = ContractInterface(contract={ "path": "../OldContract.sol", "ctor": [] }, backend="geth") result = interface.call( "submitEventProof", function_args=[proof.headers, proof.siblings, proof.headers[-1]], value=pow(10, 17), ) sum = 0 print(result) for e in result["events"]: print(e[0], "\t", e[1]) sum += e[1] print("Sum:", sum) result = interface.call( "submitContestingProof", function_args=[c_proof.headers, c_proof.siblings, c_proof.headers[-1]], ) interface.end() sum = 0 print(result) for e in result["events"]: print(e[0], "\t", e[1]) sum += e[1] print("Sum:", sum)