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

add debug trace transaction test #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions flood/generators/object_generators/call_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,33 @@ def generate_calls_trace_replay_transaction(
]


def generate_calls_debug_trace_transaction(
n_calls: int | None = None,
*,
transaction_hashes: typing.Sequence[str] | None = None,
network: str | None = None,
random_seed: flood.RandomSeed | None = None,
) -> typing.Sequence[flood.Call]:
import ctc.rpc

if transaction_hashes is None:
if n_calls is None:
raise Exception('must floodify more parameters')
if network is None:
raise Exception('must floodify network')
transaction_hashes = transaction_generators.generate_transaction_hashes(
n=n_calls,
random_seed=random_seed,
network=network,
)
return [
ctc.rpc.construct_debug_trace_transaction(
transaction_hash
)
for transaction_hash in transaction_hashes
]


def generate_calls_trace_replay_transaction_state_diff(
n_calls: int | None = None,
*,
Expand Down
1 change: 1 addition & 0 deletions flood/generators/test_generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from .multi_test_generators import *
from .transaction_test_generators import *
from .trace_test_generators import *
from .debug_test_generators import *
31 changes: 31 additions & 0 deletions flood/generators/test_generators/debug_test_generators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

import typing

import flood
from flood.tests import load_tests

def generate_test_debug_trace_transaction(
*,
network: str,
rates: typing.Sequence[int],
duration: int | None = None,
durations: typing.Sequence[int] | None = None,
vegeta_args: flood.VegetaArgsShorthand | None = None,
random_seed: flood.RandomSeed | None = None,
) -> typing.Sequence[flood.VegetaAttack]:
n_calls = load_tests.estimate_call_count(
rates=rates, duration=duration, durations=durations
)
calls = flood.generators.generate_calls_debug_trace_transaction(
n_calls=n_calls,
network=network,
random_seed=random_seed,
)
return load_tests.create_load_test(
calls=calls,
rates=rates,
duration=duration,
durations=durations,
vegeta_args=vegeta_args,
)