Skip to content

Conversation

@dylanlott
Copy link
Contributor

@dylanlott dylanlott commented Nov 20, 2025

testing: adds a full test harness

This PR adds a test harness to the builder. This test harness will facilitate deeper block lifecycle testing and assertions around smart contract calls and simulation between host and rollup chains.

  • adds a test harness with host and rollup Anvil chains
  • sets up initial lifecycle methods

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@dylanlott dylanlott changed the title feat: adds a flashbots provider and submitter testing: adds a full test harness Nov 20, 2025
constants: SignetSystemConstants::pecorino(),
};
Ok(config)
Ok(pecorino_config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test config is not a pecorino config. if we want a pecorino config it should be a separate setupd function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit and integration tests should generally NOT be run against pecorino. the test config is for local uni ttesting

use trevm::revm::{context::BlockEnv, context_interface::block::BlobExcessGasAndPrice};

/// Sets up a block builder with test values
pub fn setup_test_config() -> Result<BuilderConfig> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should base this branch on the config changes in #174

Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the harness needs design work. Can you spec out its interface and behavior a bit more?

also, we should rebase work onto #174

Some open design questions:

  • why anvil instances at all? what are we hoping to learn/control, that we can't with local dummy envs?
  • the anvil instances don't seem to be fork wrapping pecorino based on the anvil instantiation. why are we using pecorino test values anywhere?
  • why are slot times changing? this is fundamental to the builder and will definitely cause unintended behavior.
  • the harness is "simulating" an env task. why not just make an env task?

@@ -0,0 +1,307 @@
//! Test harness for end-to-end simulation flow.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our style for this is to have it in tests/common/mod.rs

constants: SignetSystemConstants::pecorino(),
};
Ok(config)
Ok(pecorino_config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unit and integration tests should generally NOT be run against pecorino. the test config is for local uni ttesting

) -> Result<TxEnvelope> {
let tx = TxEip1559 {
chain_id: 11155111,
chain_id: pecorino::RU_CHAIN_ID,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while we're fixing this, let's read it from the config by basing this work on #174 and using crate::config()

sync::Arc,
time::{Duration, SystemTime, UNIX_EPOCH},
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove newline

}

/// Tick a new `SimEnv` computed from the current latest rollup and host headers.
pub async fn tick_from_headers(&self, prev_ru_header: Header, prev_host_header: Header) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now duplicating env construction code from the env task. is there a reason we're not using an EnvTask here? it seems like we could easily have one running but control anvil to only produce WS notifications when a tick function is called

}

/// Receive the next SimResult with a timeout.
pub async fn recv_result(&mut self, timeout: Duration) -> Option<SimResult> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the basic version of the api shouldn't include a timeout. that can be added by the caller or extended with a recv_with_timeout function

}

/// Returns a host provider configured with the builder's wallet and blob gas params
async fn host_provider(&self) -> HostProvider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this duplicative with the config connection logic?

}
}

// This function sets the slot timing to start now with a 10 second slot duration for tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 is not correct

pub async fn new() -> eyre::Result<Self> {
setup_logging();
let mut config = setup_test_config()?;
configure_slot_timing(&mut config)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an anti-pattern. if we want the config to have a specific value, we should set it up that way. i;m not sure why we want to change this at all. we should be using either the test value in constants, or the pecorino value in constants

@dylanlott dylanlott closed this Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants