feat(testing): Nicer cli; expose trace parameter
Nicer name for the cli args and expose the vm_traces flag to quickly enable/disable tracing.
This commit is contained in:
@@ -10,17 +10,25 @@ def main() -> None:
|
|||||||
"--package", type=str, help="Name of the package to test."
|
"--package", type=str, help="Name of the package to test."
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--with_binary_logs",
|
"--tycho-logs",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Flag to activate logs from Tycho.",
|
help="Flag to activate logs from Tycho.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--db_url", type=str, help="Postgres database URL for the Tycho indexer."
|
"--db-url", type=str, help="Postgres database URL for the Tycho indexer."
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--vm-traces",
|
||||||
|
action="store_true",
|
||||||
|
help="Enable tracing during vm simulations.",
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
test_runner = TestRunner(
|
test_runner = TestRunner(
|
||||||
args.package, args.with_binary_logs, db_url=args.db_url
|
args.package,
|
||||||
|
args.tycho_logs,
|
||||||
|
db_url=args.db_url,
|
||||||
|
vm_traces=args.vm_traces,
|
||||||
)
|
)
|
||||||
test_runner.run_tests()
|
test_runner.run_tests()
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class SimulationFailure(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class TestRunner:
|
class TestRunner:
|
||||||
def __init__(self, package: str, with_binary_logs: bool, db_url: str):
|
def __init__(self, package: str, with_binary_logs: bool, db_url: str, vm_traces: bool):
|
||||||
self.repo_root = os.getcwd()
|
self.repo_root = os.getcwd()
|
||||||
config_path = os.path.join(self.repo_root, "substreams", package, "test_assets.yaml")
|
config_path = os.path.join(self.repo_root, "substreams", package, "test_assets.yaml")
|
||||||
self.config = load_config(config_path)
|
self.config = load_config(config_path)
|
||||||
@@ -55,6 +55,7 @@ class TestRunner:
|
|||||||
self.tycho_runner = TychoRunner(db_url, with_binary_logs, self.config["initialized_accounts"])
|
self.tycho_runner = TychoRunner(db_url, with_binary_logs, self.config["initialized_accounts"])
|
||||||
self.tycho_rpc_client = TychoRPCClient()
|
self.tycho_rpc_client = TychoRPCClient()
|
||||||
self.db_url = db_url
|
self.db_url = db_url
|
||||||
|
self._vm_traces = vm_traces
|
||||||
self._chain = Blockchain.ethereum
|
self._chain = Blockchain.ethereum
|
||||||
|
|
||||||
def run_tests(self) -> None:
|
def run_tests(self) -> None:
|
||||||
@@ -198,7 +199,7 @@ class TestRunner:
|
|||||||
self.adapters_src, "out", f"{self.config['adapter_contract']}.sol",
|
self.adapters_src, "out", f"{self.config['adapter_contract']}.sol",
|
||||||
f"{self.config['adapter_contract']}.evm.runtime"
|
f"{self.config['adapter_contract']}.evm.runtime"
|
||||||
)
|
)
|
||||||
decoder = ThirdPartyPoolTychoDecoder(adapter_contract, 0)
|
decoder = ThirdPartyPoolTychoDecoder(adapter_contract, 0, trace=self._vm_traces)
|
||||||
stream_adapter = TychoPoolStateStreamAdapter(
|
stream_adapter = TychoPoolStateStreamAdapter(
|
||||||
tycho_url="0.0.0.0:4242",
|
tycho_url="0.0.0.0:4242",
|
||||||
protocol=protocol,
|
protocol=protocol,
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ log = getLogger(__name__)
|
|||||||
class ThirdPartyPoolTychoDecoder:
|
class ThirdPartyPoolTychoDecoder:
|
||||||
"""ThirdPartyPool decoder for protocol messages from the Tycho feed"""
|
"""ThirdPartyPool decoder for protocol messages from the Tycho feed"""
|
||||||
|
|
||||||
def __init__(self, adapter_contract: str, minimum_gas: int):
|
def __init__(self, adapter_contract: str, minimum_gas: int, trace: bool):
|
||||||
self.adapter_contract = adapter_contract
|
self.adapter_contract = adapter_contract
|
||||||
self.minimum_gas = minimum_gas
|
self.minimum_gas = minimum_gas
|
||||||
|
self.trace = trace
|
||||||
|
|
||||||
def decode_snapshot(
|
def decode_snapshot(
|
||||||
self,
|
self,
|
||||||
@@ -67,7 +68,7 @@ class ThirdPartyPoolTychoDecoder:
|
|||||||
exchange=exchange,
|
exchange=exchange,
|
||||||
adapter_contract_name=self.adapter_contract,
|
adapter_contract_name=self.adapter_contract,
|
||||||
minimum_gas=self.minimum_gas,
|
minimum_gas=self.minimum_gas,
|
||||||
trace=False,
|
trace=self.trace,
|
||||||
**optional_attributes,
|
**optional_attributes,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user