Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kayan brownie integration #335

Open
wants to merge 17 commits into
base: release/1.0
Choose a base branch
from
14 changes: 14 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@ jobs:
cd test_run_root
${{ steps.evm-node-build.outputs.EVM_NODE_BUILD }}/tests/nodeos_eos_evm_test.py -v --eos-evm-contract-root ${{ steps.evm-contract.outputs.EVM_CONTRACT }} --eos-evm-build-root ${{ steps.evm-node-build.outputs.EVM_NODE_BUILD }} --use-miner ${{ steps.eos-evm-miner-build.outputs.EVM_MINER_ROOT }}

- name: Test Leap Integration - with Brownie Framework
run: |
mkdir -p test_run_root
cd test_run_root
pip install --upgrade web3
pip install otree
pip install websocket-client
pip install eth-brownie
npm install -g ganache
pip install flask
pip install flask-cors --upgrade
brownie networks add Ethereum localhost5000 host=http://127.0.0.1:5000 chainid=15555
${{ steps.evm-node-build.outputs.EVM_NODE_BUILD }}/tests/nodeos_eos_evm_brownietest.py -v --eos-evm-contract-root ${{ steps.evm-contract.outputs.EVM_CONTRACT }} --eos-evm-build-root ${{ steps.evm-node-build.outputs.EVM_NODE_BUILD }} --use-miner ${{ steps.eos-evm-miner-build.outputs.EVM_MINER_ROOT }} --flask-proxy-root ${{ steps.evm-node-build.outputs.EVM_NODE_BUILD }}/tests/

- name: Test Leap Integration - different gas token
run: |
mkdir -p test_run_root
Expand Down
2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ configure_file(nodeos_eos_evm_server.py . COPYONLY)
configure_file(nodeos_eos_evm_test.py . COPYONLY)
configure_file(nodeos_eos_evm_different_token_test.py . COPYONLY)
configure_file(nodeos_eos_evm_gasparam_fork_test.py . COPYONLY)
configure_file(nodeos_eos_evm_brownietest.py . COPYONLY)
configure_file(flask_proxy.py . COPYONLY)
configure_file(defertest.wasm . COPYONLY)
configure_file(defertest.abi . COPYONLY)
configure_file(defertest2.wasm . COPYONLY)
Expand Down
43 changes: 43 additions & 0 deletions tests/flask_proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
import os
from flask import Flask, request, jsonify
from flask_cors import CORS
import requests
import json

app = Flask(__name__)
CORS(app)
writemethods = {"eth_sendRawTransaction","eth_gasPrice"}
readEndpoint = "http://127.0.0.1:8881"
writeEndpoint = os.getenv("WRITE_RPC_ENDPOINT", "http://127.0.0.1:18888")
flaskListenPort = os.getenv("FLASK_SERVER_PORT", 5000)

import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

@app.route("/", methods=["POST"])
def default():
def forward_request(req):
if type(req) == dict and ("method" in req) and (req["method"] in writemethods):
#print("send req to miner:" + str(req))
resp = requests.post(writeEndpoint, json.dumps(req), headers={"Accept":"application/json","Content-Type":"application/json"}).json()
#print("got resp from miner:" + str(resp))
return resp
else:
#print("send req to eos-evm-rpc:" + str(req))
resp = requests.post(readEndpoint, json.dumps(req), headers={"Accept":"application/json","Content-Type":"application/json"}).json()
#print("got from eos-evm-rpc:" + str(resp))
return resp

request_data = request.get_json()
if type(request_data) == dict:
return jsonify(forward_request(request_data))

res = []
for r in request_data:
res.append(forward_request(r))

return jsonify(res)

app.run(host='0.0.0.0', port=flaskListenPort)
Loading
Loading