def startGeth(test_file): testfile_path = os.path.abspath(test_file) mount_testfile = testfile_path + ":" + "/mounted_testfile" (name, isDocker) = getBaseCmd("geth") if isDocker: cmd = ["docker", "run", "--rm", "-t", "-v", mount_testfile, name, "--json", "--nomemory", "statetest", "/mounted_testfile"] return {'proc':VMUtils.startProc(cmd ), 'cmd': " ".join(cmd), 'output' : 'stdout'} else: cmd = [name,"--json", "--nomemory", "statetest", testfile_path] return {'proc':VMUtils.startProc(cmd ), 'cmd': " ".join(cmd), 'output' : 'stderr'}
def startCpp(test): testfile_path = os.path.abspath(test.tmpfile) (name, isDocker) = getBaseCmd("cpp") if isDocker: mounted_testfile = testfile_path + ":" + "/mounted_testfile" cmd = ["docker", "run", "--rm", "-t", "-v", mounted_testfile] testfile_to_execute = "/mounted_testfile" else: cmd = [] testfile_to_execute = testfile_path cmd.extend([ name, '-t', "GeneralStateTests", '--', '--singletest', testfile_to_execute, test.name, '--jsontrace', "'{ \"disableStorage\":true, \"disableMemory\":true }'", '--singlenet', cfg['FORK_CONFIG'], '-d', "0", '-g', "0", '-v', "0" ]) if cfg['FORK_CONFIG'] == 'Homestead' or cfg['FORK_CONFIG'] == 'Frontier': cmd.extend(['--all']) # cpp requires this for some reason return { 'proc': VMUtils.startProc(cmd), 'cmd': " ".join(cmd), 'output': 'stdout' }
def createRandomStateTest(): (name, isDocker) = getBaseCmd("testeth") if isDocker: cmd = ['docker', "run", "--rm", name] else: cmd = [name] cmd.extend(["-t", "GeneralStateTests", "--", "--createRandomTest"]) outp = "".join(VMUtils.finishProc(VMUtils.startProc(cmd))) #Validate that it's json try: test = json.loads(outp) test['randomStatetest']['_info'] = { 'sourceHash': "0000000000000000000000000000000000000000000000000000000000001337", "comment": "x" } return test except: print("Exception generating test") print('-' * 60) traceback.print_exc(file=sys.stdout) print('-' * 60) return None
def startPython(test_file, test_tx): tx_encoded = json.dumps(test_tx) tx_double_encoded = json.dumps( tx_encoded) # double encode to escape chars for command line # command if not using a docker container # pyeth_process = subprocess.Popen(["python", "run_statetest.py", test_file, tx_double_encoded], shell=False, stdout=subprocess.PIPE, close_fds=True) # command to run docker container # docker run --volume=/absolute/path/prestate.json:/mounted_prestate cdetrio/pyethereum run_statetest.py mounted_prestate "{\"data\": \"\", \"gasLimit\": \"0x0a00000000\", \"gasPrice\": \"0x01\", \"nonce\": \"0x00\", \"secretKey\": \"0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8\", \"to\": \"0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6\", \"value\": \"0x00\"}" prestate_path = os.path.abspath(test_file) mount_flag = prestate_path + ":" + "/mounted_prestate" cmd = [ "docker", "run", "--rm", "-t", "-v", mount_flag, cfg['PYETH_DOCKER_NAME'], "run_statetest.py", "/mounted_prestate", tx_double_encoded ] return { 'proc': VMUtils.startProc(cmd), 'cmd': " ".join(cmd), 'output': 'stdout' }
def startCpp(test_subfolder, test_name, test_dgv): [d,g,v] = test_dgv (name, isDocker) = getBaseCmd("cpp") if isDocker: cpp_mount_tests = cfg['TESTS_PATH'] + ":" + "/mounted_tests" cmd = ["docker", "run", "--rm", "-t", "-v", cpp_mount_tests, name ,'-t',"GeneralStateTests/%s" % test_subfolder ,'--' ,'--singletest', test_name ,'--jsontrace',"'{ \"disableStorage\":true, \"disableMemory\":true }'" ,'--singlenet',cfg['FORK_CONFIG'] ,'-d',str(d),'-g',str(g), '-v', str(v) ,'--testpath', '"/mounted_tests"'] else: cmd = [name ,'-t',"GeneralStateTests/%s" % test_subfolder ,'--' ,'--singletest', test_name ,'--jsontrace',"'{ \"disableStorage\":true, \"disableMemory\":true }'" ,'--singlenet',cfg['FORK_CONFIG'] ,'-d',str(d),'-g',str(g), '-v', str(v) ,'--testpath', cfg['TESTS_PATH']] if cfg['FORK_CONFIG'] == 'Homestead' or cfg['FORK_CONFIG'] == 'Frontier': cmd.extend(['--all']) # cpp requires this for some reason return {'proc':VMUtils.startProc(cmd ), 'cmd': " ".join(cmd), 'output' : 'stdout'}
def startJs(single_test_tmp_file): logger.info("running state test in EthereumJS.") testfile_path = os.path.abspath(single_test_tmp_file) mount_testfile = testfile_path+":/ethereum/"+single_test_tmp_file js_docker_cmd = ["docker", "run", "--rm", "-t", "-v", mount_testfile, getBaseCmd('js')[0], "-s", "--customStateTest", single_test_tmp_file] js_docker_cmd.extend(['--jsontrace']) js_docker_cmd.extend(['--fork', cfg['FORK_CONFIG']]) logger.info("js_cmd: %s " % " ".join(js_docker_cmd)) return {'proc':VMUtils.startProc(js_docker_cmd), 'cmd': " ".join(js_docker_cmd), 'output' : 'stdout'}
def startParity(test_file): logger.info("running state test in parity.") testfile_path = os.path.abspath(test_file) mount_testfile = testfile_path + ":" + "/mounted_testfile" parity_docker_cmd = [ "docker", "run", "--rm", "-t", "-v", mount_testfile, cfg['PARITY_DOCKER_NAME'], "--json", "--statetest", "/mounted_testfile" ] logger.info(" ".join(parity_docker_cmd)) return VMUtils.startProc(parity_docker_cmd)
def startPython(test): tx_encoded = json.dumps(test.tx) tx_double_encoded = json.dumps( tx_encoded) # double encode to escape chars for command line prestate_path = os.path.abspath(test.prestate_tmpfile) mount_flag = prestate_path + ":" + "/mounted_prestate" cmd = [ "docker", "run", "--rm", "-t", "-v", mount_flag, cfg['PYETH_DOCKER_NAME'], "run_statetest.py", "/mounted_prestate", tx_double_encoded ] return { 'proc': VMUtils.startProc(cmd), 'cmd': " ".join(cmd), 'output': 'stdout' }
def startParity(test): testfile_path = os.path.abspath(test.tmpfile) mount_testfile = testfile_path + ":" + "/mounted_testfile" (name, isDocker) = getBaseCmd("parity") if isDocker: cmd = [ "docker", "run", "--rm", "-t", "-v", mount_testfile, name, "state-test", "/mounted_testfile", "--json" ] else: cmd = [name, "state-test", testfile_path, "--json"] return { 'proc': VMUtils.startProc(cmd), 'cmd': " ".join(cmd), 'output': 'stdout' }
def startCpp(test_subfolder, test_name, test_dgv): logger.info("running state test in cpp-ethereum.") [d, g, v] = test_dgv cpp_mount_tests = cfg['TESTS_PATH'] + ":" + "/mounted_tests" cmd = [ "docker", "run", "--rm", "-t", "-v", cpp_mount_tests, cfg['CPP_DOCKER_NAME'] ] cmd.extend(['-t', "StateTestsGeneral/%s" % test_subfolder, '--']) cmd.extend(['--singletest', test_name]) cmd.extend(['--jsontrace', "'{ \"disableStorage\":true }'"]) cmd.extend(['--singlenet', cfg['FORK_CONFIG']]) if cfg['FORK_CONFIG'] == 'Homestead' or cfg['FORK_CONFIG'] == 'Frontier': cmd.extend(['--all']) # cpp requires this for some reason cmd.extend(['-d', str(d), '-g', str(g), '-v', str(v)]) cmd.extend(['--testpath', '"/mounted_tests"']) logger.info("cpp_cmd: %s " % " ".join(cmd)) return VMUtils.startProc(cmd)