diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..e44b8108 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +ignore = E501 diff --git a/.github/workflows/construction_native.yml b/.github/workflows/construction_native.yml new file mode 100644 index 00000000..e7c6795f --- /dev/null +++ b/.github/workflows/construction_native.yml @@ -0,0 +1,29 @@ +name: Test construction (native currency) + +on: + pull_request: + workflow_dispatch: + +jobs: + localnet: + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - uses: actions/checkout@v4 + + - name: Install mesh-cli + run: | + curl -sSfL https://raw.githubusercontent.com/coinbase/mesh-cli/master/scripts/install.sh | sh -s + + - name: Build rosetta + run: | + cd cmd/rosetta && go build . + + - name: Smoke test + run: | + cd cmd/rosetta && ./rosetta --version + rosetta-cli version diff --git a/systemtests/devnet-construction.ros b/systemtests/devnet-construction.ros index d47d7cea..cb74afba 100644 --- a/systemtests/devnet-construction.ros +++ b/systemtests/devnet-construction.ros @@ -12,12 +12,22 @@ transfer(1){ } }; + max_fee = "50000000000000"; max_transfer_amount = "10000000000000000"; recipient_amount = random_number({"minimum": "1", "maximum": {{max_transfer_amount}}}); print_message({"recipient_amount":{{recipient_amount}}}); sender_amount = 0-{{recipient_amount}}; + recipient = { + "account_identifier": { + "address": "erd1xtslmt67utuewwv8jsx729mxjxaa8dvyyzp7492hy99dl7hvcuqq30l98v" + }, + "currency": { + "symbol": "EGLD", + "decimals": 18 + } + }; transfer.confirmation_depth = "10"; transfer.operations = [ { @@ -28,10 +38,17 @@ transfer(1){ "value":{{sender_amount}}, "currency":{{native_currency}} } + }, + { + "operation_identifier":{"index":1}, + "related_operations": [{"index": 0}], + "type":"Transfer", + "account":{{recipient.account_identifier}}, + "amount":{ + "value":{{recipient_amount}}, + "currency":{{native_currency}} + } } ]; - transfer.preprocess_metadata = { - "receiver": "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th" - }; } } diff --git a/systemtests/proxy_to_observer_adapter.py b/systemtests/proxy_to_observer_adapter.py new file mode 100644 index 00000000..0ae78528 --- /dev/null +++ b/systemtests/proxy_to_observer_adapter.py @@ -0,0 +1,111 @@ +import logging +from argparse import ArgumentParser +from typing import Any + +import requests +from bottle import Bottle, request, response # type: ignore + +app: Any = Bottle() + + +class Configuration: + def __init__(self): + self.shard = 0 + self.proxy = "" + + +configuration = Configuration() + +logging.basicConfig(level=logging.DEBUG) + + +@app.route("/node/status") +def get_node_status() -> Any: + url = f"{configuration.proxy}/network/status/{configuration.shard}" + logging.info(f"get_node_status(): {url}") + + proxy_response = requests.get(url) + proxy_response.raise_for_status() + proxy_response_json = proxy_response.json() + + proxy_response_json["data"]["metrics"] = proxy_response_json["data"]["status"] + proxy_response_json["data"]["metrics"]["erd_app_version"] = "v1.2.3" + proxy_response_json["data"]["metrics"]["erd_public_key_block_sign"] = "abba" + del proxy_response_json["data"]["status"] + + return proxy_response_json + + +@app.route("/node/epoch-start/") +def get_epoch_start(epoch: int) -> Any: + url = f"{configuration.proxy}/network/epoch-start/{configuration.shard}/by-epoch/{epoch}" + logging.info(f"get_epoch_start(): {url}") + + proxy_response = requests.get(url) + proxy_response.raise_for_status() + return proxy_response.json() + + +@app.route("/block/by-nonce/") +def get_block_by_nonce(nonce: int) -> Any: + url = f"{configuration.proxy}/block/{configuration.shard}/by-nonce/{nonce}" + logging.info(f"get_block_by_nonce(): {url}") + + params: Any = dict(request.query) # type: ignore + proxy_response = requests.get(url, params=params) + proxy_response.raise_for_status() + return proxy_response.json() + + +@app.route("/address/
/esdt/") +def get_account_esdt(address: str, token: str) -> Any: + url = f"{configuration.proxy}/address/{address}/esdt/{token}" + logging.info(f"get_account_esdt(): {url}") + + params: Any = dict(request.query) # type: ignore + proxy_response = requests.get(url, params=params) + proxy_response.raise_for_status() + return proxy_response.json() + + +@app.route("/address/
") +def get_account(address: str) -> Any: + url = f"{configuration.proxy}/address/{address}" + logging.info(f"get_account(): {url}") + + params: Any = dict(request.query) # type: ignore + proxy_response = requests.get(url, params=params) + proxy_response_json = proxy_response.json() + proxy_response.raise_for_status() + + return proxy_response_json + + +@app.route("/transaction/send", method="POST") +def send_transaction(): + url = f"{configuration.proxy}/transaction/send" + logging.info(f"send_transaction(): {url}") + + data = request.json + proxy_response = requests.post(url, json=data) + proxy_response_json = proxy_response.json() + + response.status = proxy_response.status_code + + return proxy_response_json + + +def main(): + parser = ArgumentParser() + parser.add_argument("--proxy", default="https://devnet-gateway.multiversx.com") + parser.add_argument("--shard", type=int, default=0) + args = parser.parse_args() + + configuration.proxy = args.proxy + configuration.shard = args.shard + + app.run(host="localhost", port=8080) + + +if __name__ == "__main__": + main()