Skip to content
Merged
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
6 changes: 5 additions & 1 deletion dapptools/src/dapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ fn test<A: ArtifactOutput + 'static, S: Clone, E: evm_adapters::Evm<S>>(
) -> eyre::Result<HashMap<String, HashMap<String, dapp::TestResult>>> {
let mut runner = builder.build(project, evm)?;

let mut exit_code = 0;

let results = runner.test(pattern)?;

if json {
Expand All @@ -272,6 +274,8 @@ fn test<A: ArtifactOutput + 'static, S: Clone, E: evm_adapters::Evm<S>>(
let status = if result.success {
Colour::Green.paint("[PASS]")
} else {
// if an error is found, return a -1 exit code
exit_code = -1;
let txt = if let Some(ref reason) = result.reason {
format!("[FAIL: {}]", reason)
} else {
Expand Down Expand Up @@ -308,5 +312,5 @@ fn test<A: ArtifactOutput + 'static, S: Clone, E: evm_adapters::Evm<S>>(
}
}

Ok(results)
std::process::exit(exit_code);
}
7 changes: 6 additions & 1 deletion evm-adapters/src/blocking_provider.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ethers::{
prelude::BlockNumber,
providers::Middleware,
types::{Address, Block, BlockId, Bytes, TxHash, H256, U256, U64},
};
Expand Down Expand Up @@ -30,7 +31,11 @@ where
self.runtime.block_on(f)
}

pub fn block_and_chainid(&self, block_id: BlockId) -> eyre::Result<(Block<TxHash>, U256)> {
pub fn block_and_chainid(
&self,
block_id: Option<impl Into<BlockId>>,
) -> eyre::Result<(Block<TxHash>, U256)> {
let block_id = block_id.map(Into::into).unwrap_or(BlockId::Number(BlockNumber::Latest));
let f = async {
let block = self.provider.get_block(block_id);
let chain_id = self.provider.get_chainid();
Expand Down
3 changes: 1 addition & 2 deletions evm-adapters/src/sputnik/forked_backend/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ where
init_cache: BTreeMap<H160, MemoryAccount>,
) -> Self {
let provider = BlockingProvider::new(provider);
let pin_block = pin_block.unwrap_or_else(|| backend.block_number().as_u64()).into();

// get the remaining block metadata
let (block, chain_id) =
Expand All @@ -57,7 +56,7 @@ where
provider,
backend,
cache: RefCell::new(init_cache),
pin_block: Some(pin_block),
pin_block: pin_block.map(Into::into),
pin_block_meta: block,
chain_id,
}
Expand Down