Skip to content

Commit

Permalink
Issue #27: adding assembly testing function
Browse files Browse the repository at this point in the history
  • Loading branch information
lialan committed Nov 18, 2019
1 parent 034a250 commit 1a9fa54
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tools/evm-test/evm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,26 @@ def generate_asm_file(infilename: str, outfilename: str) -> str:
return


def run_assembly(name: str, inputs: List[str], output: str, filename: str) -> None:
assembly_filename = filename + ".s"
generate_asm_file(filename, assembly_filename)

cleaned_content = None
with open(assembly_filename, "r") as f:
content = f.read()
cleaned_content = remove_directives_in_assembly(content)
os.remove(assembly_filename)

contract = generate_contract(
inputs=inputs, func=cleaned_content)

try:
execute_in_evm(code=contract, expected=output)
except:
raise Error("Running test error: " + name)


'''
generate_asm_file("./test.ll", "./test.s")
f=open("./test.s", "r")
content = f.read()
Expand All @@ -150,4 +169,10 @@ def generate_asm_file(infilename: str, outfilename: str) -> str:
contract = generate_contract(
inputs=["0x12345678", "0x87654321"], func=cleaned_content)
result = execute_in_evm(contract, "")
print("generated contract:")
print(contract)
result = execute_in_evm(contract, "")
'''

run_assembly(name="test", inputs=[
"0x12345678", "0x87654321"], output=None, filename="./test.ll")

0 comments on commit 1a9fa54

Please sign in to comment.