Skip to content

Commit

Permalink
call_trace
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 14, 2024
1 parent 4950618 commit 99c5eee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
release/
/build
coverage.txt
trace.out
__pycache__
/dist
/vendor
Expand Down
4 changes: 4 additions & 0 deletions integration_tests/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def w3_ws_endpoint(self, i=0):
port = ports.evmrpc_ws_port(self.base_port(i))
return f"ws://localhost:{port}"

def pprof_endpoint(self, i=0):
port = ports.pprof_port(self.base_port(i))
return f"http://localhost:{port}"

@property
def w3(self):
if self._w3 is None:
Expand Down
24 changes: 20 additions & 4 deletions integration_tests/test_upgrade_recent.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import concurrent.futures
from concurrent.futures import ThreadPoolExecutor, as_completed

import pytest
Expand All @@ -23,9 +24,8 @@ def call(url, params):
return rsp.json()


def call_check(url, address):
def call_check(url, address, concurrent):
batch = 10
concurrent = 10
param = {
"jsonrpc": "2.0",
"method": "eth_call",
Expand All @@ -47,10 +47,26 @@ def call_check(url, address):
assert len(results) == concurrent


def call_trace(url):
res = requests.get(f"{url}/debug/pprof/trace?seconds=3")
if res.status_code == 200:
with open("trace.out", "wb") as file:
file.write(res.content)
print("saved trace.out")
else:
print(f"failed to retrieve data: {res.status_code}")


def test_cosmovisor_upgrade(custom_cronos):
c = custom_cronos
cli = c.cosmos_cli()
cli = do_upgrade(c, "v1.4", cli.block_height() + 15)
res = deploy_contract(c.w3, CONTRACTS["CheckpointOracle"])
url = c.w3_http_endpoint()
[call_check(url, res.address) for _ in range(10)]
url0 = c.pprof_endpoint()
url1 = c.w3_http_endpoint()
with ThreadPoolExecutor() as exec:
futures = [
exec.submit(call_trace, url0),
exec.submit(call_check, url1, res.address, 100),
]
concurrent.futures.wait(futures)

0 comments on commit 99c5eee

Please sign in to comment.