refactor: remove skip_balance_check from run_test signature
This field is redundant, as it can be read directly from `config`
This commit is contained in:
@@ -121,7 +121,7 @@ impl TestRunner {
|
|||||||
for test in &tests {
|
for test in &tests {
|
||||||
info!("TEST {}: {}", count, test.name);
|
info!("TEST {}: {}", count, test.name);
|
||||||
|
|
||||||
match self.run_test(test, &config, config.skip_balance_check) {
|
match self.run_test(test, &config) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
info!("✅ {} passed\n", test.name);
|
info!("✅ {} passed\n", test.name);
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,6 @@ impl TestRunner {
|
|||||||
&self,
|
&self,
|
||||||
test: &IntegrationTest,
|
test: &IntegrationTest,
|
||||||
config: &IntegrationTestsConfig,
|
config: &IntegrationTestsConfig,
|
||||||
skip_balance_check: bool,
|
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
self.empty_database()
|
self.empty_database()
|
||||||
.into_diagnostic()
|
.into_diagnostic()
|
||||||
@@ -195,12 +194,11 @@ impl TestRunner {
|
|||||||
.wrap_err("Failed to run Tycho")?;
|
.wrap_err("Failed to run Tycho")?;
|
||||||
|
|
||||||
tycho_runner.run_with_rpc_server(
|
tycho_runner.run_with_rpc_server(
|
||||||
|expected_components, start_block, stop_block, skip_balance_check| {
|
|expected_components, start_block, stop_block| {
|
||||||
validate_state(
|
validate_state(
|
||||||
expected_components,
|
expected_components,
|
||||||
start_block,
|
start_block,
|
||||||
stop_block,
|
stop_block,
|
||||||
skip_balance_check,
|
|
||||||
config,
|
config,
|
||||||
&self.adapter_contract_builder,
|
&self.adapter_contract_builder,
|
||||||
self.vm_traces,
|
self.vm_traces,
|
||||||
@@ -209,7 +207,6 @@ impl TestRunner {
|
|||||||
&test.expected_components,
|
&test.expected_components,
|
||||||
test.start_block,
|
test.start_block,
|
||||||
test.stop_block,
|
test.stop_block,
|
||||||
skip_balance_check,
|
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +230,6 @@ fn validate_state(
|
|||||||
expected_components: &Vec<ProtocolComponentWithTestConfig>,
|
expected_components: &Vec<ProtocolComponentWithTestConfig>,
|
||||||
start_block: u64,
|
start_block: u64,
|
||||||
stop_block: u64,
|
stop_block: u64,
|
||||||
skip_balance_check: bool,
|
|
||||||
config: &IntegrationTestsConfig,
|
config: &IntegrationTestsConfig,
|
||||||
adapter_contract_builder: &AdapterContractBuilder,
|
adapter_contract_builder: &AdapterContractBuilder,
|
||||||
vm_traces: bool,
|
vm_traces: bool,
|
||||||
@@ -290,7 +286,10 @@ fn validate_state(
|
|||||||
// Step 1: Validate that all expected components are present on Tycho after indexing
|
// Step 1: Validate that all expected components are present on Tycho after indexing
|
||||||
debug!("Validating {:?} expected components", expected_components.len());
|
debug!("Validating {:?} expected components", expected_components.len());
|
||||||
for expected_component in expected_components {
|
for expected_component in expected_components {
|
||||||
let component_id = expected_component.base.id.to_lowercase();
|
let component_id = expected_component
|
||||||
|
.base
|
||||||
|
.id
|
||||||
|
.to_lowercase();
|
||||||
|
|
||||||
let component = components_by_id
|
let component = components_by_id
|
||||||
.get(&component_id)
|
.get(&component_id)
|
||||||
@@ -315,7 +314,7 @@ fn validate_state(
|
|||||||
info!("All expected components were successfully found on Tycho and match the expected state");
|
info!("All expected components were successfully found on Tycho and match the expected state");
|
||||||
|
|
||||||
// Step 2: Validate Token Balances
|
// Step 2: Validate Token Balances
|
||||||
match skip_balance_check {
|
match config.skip_balance_check {
|
||||||
true => info!("Skipping balance check"),
|
true => info!("Skipping balance check"),
|
||||||
false => {
|
false => {
|
||||||
validate_token_balances(&components_by_id, &protocol_states_by_id, start_block, &rt)?;
|
validate_token_balances(&components_by_id, &protocol_states_by_id, start_block, &rt)?;
|
||||||
@@ -545,7 +544,6 @@ fn validate_state(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("✅ Simulation validation passed");
|
info!("✅ Simulation validation passed");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,10 +98,9 @@ impl TychoRunner {
|
|||||||
expected_components: &Vec<ProtocolComponentWithTestConfig>,
|
expected_components: &Vec<ProtocolComponentWithTestConfig>,
|
||||||
start_block: u64,
|
start_block: u64,
|
||||||
stop_block: u64,
|
stop_block: u64,
|
||||||
skip_balance_check: bool,
|
|
||||||
) -> miette::Result<R>
|
) -> miette::Result<R>
|
||||||
where
|
where
|
||||||
F: FnOnce(&Vec<ProtocolComponentWithTestConfig>, u64, u64, bool) -> R,
|
F: FnOnce(&Vec<ProtocolComponentWithTestConfig>, u64, u64) -> R,
|
||||||
{
|
{
|
||||||
let (tx, rx): (Sender<bool>, Receiver<bool>) = mpsc::channel();
|
let (tx, rx): (Sender<bool>, Receiver<bool>) = mpsc::channel();
|
||||||
let db_url = self.db_url.clone();
|
let db_url = self.db_url.clone();
|
||||||
@@ -141,7 +140,7 @@ impl TychoRunner {
|
|||||||
thread::sleep(Duration::from_secs(3));
|
thread::sleep(Duration::from_secs(3));
|
||||||
|
|
||||||
// Run the provided function
|
// Run the provided function
|
||||||
let result = func(expected_components, start_block, stop_block, skip_balance_check);
|
let result = func(expected_components, start_block, stop_block);
|
||||||
|
|
||||||
tx.send(true)
|
tx.send(true)
|
||||||
.expect("Failed to send termination message");
|
.expect("Failed to send termination message");
|
||||||
|
|||||||
Reference in New Issue
Block a user