Skip to content

Commit 4409d58

Browse files
fix: Address review comments
- Imports at the top - Remove unnecessary chain_block_time logic - Fix uniswap v3 integration test by increasing the stop block a bit #time 2h 37m
1 parent 11cd92f commit 4409d58

File tree

5 files changed

+19
-38
lines changed

5 files changed

+19
-38
lines changed

protocol-testing/Cargo.lock

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol-testing/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ glob = "0.3.0"
88
miette = { version = "7.6.0", features = ["fancy"] }
99
# Logging & Tracing
1010
tracing = "0.1.37"
11-
tycho-simulation = { path = "../../tycho-simulation", features = ["evm"] }
12-
tycho-test = { path = "../../tycho-simulation/tycho-test" }
13-
tycho-execution = { path = "../../tycho-execution" }
11+
tycho-simulation = { git = "https://github.com/propeller-heads/tycho-simulation.git", tag = "0.197.0", features = ["evm"] }
12+
tycho-test = { git = "https://github.com/propeller-heads/tycho-simulation.git", tag = "0.197.0" }
13+
tycho-execution = ">=0.134.0"
1414
num-bigint = "0.4"
1515
num-traits = "0.2"
1616
num-rational = "0.4.2"

protocol-testing/src/test_runner.rs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use tycho_simulation::{
3232
tycho_client::feed::{synchronizer::StateSyncMessage, BlockHeader, FeedMessage},
3333
tycho_common::{
3434
dto::{Chain, ProtocolComponent, ResponseProtocolState},
35-
models::token::Token,
35+
models::{token::Token, Chain as ChainModel},
3636
Bytes,
3737
},
3838
};
@@ -63,16 +63,6 @@ static CLONE_TO_BASE_PROTOCOL: LazyLock<HashMap<&str, &str>> = LazyLock::new(||
6363
])
6464
});
6565

66-
/// Returns the approximate block time in seconds for different chains
67-
fn get_chain_block_time(chain: Chain) -> u64 {
68-
match chain {
69-
Chain::Ethereum => 12, // ~12 seconds
70-
Chain::Base => 2, // ~2 seconds
71-
Chain::Unichain => 1, // ~1 second
72-
_ => 12, // Default fallback to Ethereum timing
73-
}
74-
}
75-
7666
pub enum TestType {
7767
Full(TestTypeFull),
7868
Range(TestTypeRange),
@@ -277,7 +267,7 @@ impl TestRunner {
277267
async fn run_live_testing(&self, config: &IntegrationTestsConfig) -> miette::Result<()> {
278268
info!("Starting live testing for protocol {}", &config.protocol_system);
279269

280-
let chain = tycho_simulation::tycho_common::models::Chain::from(self.chain);
270+
let chain = ChainModel::from(self.chain);
281271
// Load tokens for the stream
282272
let all_tokens = tycho_simulation::utils::load_all_tokens(
283273
"http://localhost:4242",
@@ -396,11 +386,7 @@ impl TestRunner {
396386
execution_data.len()
397387
);
398388

399-
// Step 2: Sleep for block time (chain-specific)
400-
tokio::time::sleep(std::time::Duration::from_secs(self.get_chain_block_time()))
401-
.await;
402-
403-
// Step 3: Get the actual block from RPC
389+
// Step 2: Get the actual block from RPC
404390
let block = match self
405391
.rpc_provider
406392
.get_block(BlockNumberOrTag::Number(update.block_number_or_timestamp))
@@ -422,7 +408,7 @@ impl TestRunner {
422408
execution_data.len()
423409
);
424410

425-
// Step 4: Execute the batch against the real block
411+
// Step 3: Execute the batch against the real block
426412
match self
427413
.run_execution(
428414
execution_data,
@@ -1047,8 +1033,7 @@ impl TestRunner {
10471033
(protocol_system): EXECUTOR_ADDRESS
10481034
}
10491035
});
1050-
let chain_model =
1051-
tycho_simulation::tycho_common::models::Chain::from(self.chain);
1036+
let chain_model = ChainModel::from(self.chain);
10521037
let (solution, calldata) = encode_swap(
10531038
component,
10541039
None,
@@ -1137,7 +1122,7 @@ impl TestRunner {
11371122
return Ok(());
11381123
}
11391124

1140-
let chain_model = tycho_simulation::tycho_common::models::Chain::from(self.chain);
1125+
let chain_model = ChainModel::from(self.chain);
11411126
let rpc_tools = RPCTools::new(self.rpc_provider.url.as_ref(), &chain_model).await?;
11421127

11431128
// Prepare router overwrites data
@@ -1172,7 +1157,6 @@ impl TestRunner {
11721157
&rpc_tools,
11731158
batch.clone(),
11741159
block,
1175-
0,
11761160
router_overwrites_data.clone(),
11771161
)
11781162
.await;
@@ -1333,11 +1317,6 @@ impl TestRunner {
13331317
Ok(None)
13341318
}
13351319
}
1336-
1337-
/// Gets the block time for the current chain
1338-
fn get_chain_block_time(&self) -> u64 {
1339-
get_chain_block_time(self.chain)
1340-
}
13411320
}
13421321

13431322
#[cfg(test)]

protocol-testing/src/tycho_rpc.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::{collections::HashMap, error::Error as StdError, fmt};
22

3-
use tracing::{debug, info};
3+
use tokio::time::{sleep, Duration};
4+
use tracing::{debug, info, warn};
45
use tycho_simulation::{
56
tycho_client::{
67
feed::synchronizer::Snapshot,
@@ -165,9 +166,6 @@ impl TychoClient {
165166
protocol_system: &str,
166167
chain: Chain,
167168
) -> Result<(), RpcError> {
168-
use tokio::time::{sleep, Duration};
169-
use tracing::warn;
170-
171169
loop {
172170
match self
173171
.get_protocol_components(protocol_system, chain)

substreams/ethereum-uniswap-v3/integration_test.tycho.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ initialized_accounts:
88
tests:
99
- name: test_weth_now_pool
1010
start_block: 22182832
11-
stop_block: 22182834
11+
stop_block: 22182840
1212
expected_components:
1313
- id: "0x545b7db6632ab230fd84897488291def7912319c"
1414
tokens:

0 commit comments

Comments
 (0)