Skip to content

Commit

Permalink
Fix build errors in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed Mar 17, 2024
1 parent ab1351c commit fcece84
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hex = "0.4.3"
jsonrpsee = "0.20.1"
reth = { git = "https://github.com/paradigmxyz/reth", rev = "3b4726a714c3b3bf693dfae1b00da8c06e832c9a" }
reth-db = { features = ["test-utils"], git = "https://github.com/paradigmxyz/reth", rev = "3b4726a714c3b3bf693dfae1b00da8c06e832c9a"}
reth-provider = { git = "https://github.com/paradigmxyz/reth", rev = "3b4726a714c3b3bf693dfae1b00da8c06e832c9a", features=["test-utils"]}
reth-tracing = { git = "https://github.com/paradigmxyz/reth", rev = "3b4726a714c3b3bf693dfae1b00da8c06e832c9a"}
reth-interfaces = { git = "https://github.com/paradigmxyz/reth", rev = "3b4726a714c3b3bf693dfae1b00da8c06e832c9a"}
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", rev = "3b4726a714c3b3bf693dfae1b00da8c06e832c9a"}
Expand All @@ -34,6 +35,7 @@ serde_json = "1.0.107"
serde_with = "3.3.0"
tokio = "1.35"
uuid = "1.6.1"
ruint = "1.12.1"

[dev-dependencies]
tokio = "1.32.0"
33 changes: 18 additions & 15 deletions tests/integration/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ use reth::providers::{
};
use reth::revm::{database::StateProviderDatabase, processor::EVMProcessor};
use reth::rpc::compat::engine::payload::try_into_block;
use reth_db::test_utils::{create_test_rw_db, TempDatabase};
use reth_db::test_utils::TempDatabase;
use reth_db::transaction::{DbTx, DbTxMut};
use reth_db::{tables, DatabaseEnv};
use reth_payload_validator::rpc::{
ValidationApiClient, ValidationApiServer, ValidationRequestBody,
};
use reth_payload_validator::ValidationApi;
use reth_provider::test_utils::create_test_provider_factory_with_chain_spec;
use reth_node_ethereum::EthEvmConfig;

use secp256k1::{rand, PublicKey, Secp256k1, SecretKey};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use ruint::Uint;

type TestProviderFactory = ProviderFactory<Arc<TempDatabase<DatabaseEnv>>>;

Expand Down Expand Up @@ -207,7 +211,7 @@ async fn test_tx_nonce_too_low() {
nonce: 0, // Invalid Tx because nonce is too low
gas_limit: 21000,
to: TransactionKind::Call(receiver_address),
value: 1_000_000_u128.into(),
value: Uint::from(1_000_000),
input: Bytes::default(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down Expand Up @@ -269,7 +273,7 @@ async fn test_proposer_payment_validation_via_balance_change() {
nonce: 0,
gas_limit: 21000,
to: TransactionKind::Call(receiver_address),
value: 1_000_000_u128.into(),
value: Uint::from(1_000_000),
input: Bytes::default(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down Expand Up @@ -346,7 +350,7 @@ async fn test_proposer_spent_in_same_block() {
nonce: 0,
gas_limit: 21000,
to: TransactionKind::Call(receiver_address),
value: 1_000_000_u128.into(),
value: Uint::from(1_000_000),
input: Bytes::default(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down Expand Up @@ -409,7 +413,7 @@ async fn test_proposer_spent_in_same_block_but_payment_tx_last() {
nonce: 0,
gas_limit: 21000,
to: TransactionKind::Call(receiver_address),
value: amount_to_send.into(),
value: Uint::from(amount_to_send),
input: Bytes::default(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand All @@ -424,7 +428,7 @@ async fn test_proposer_spent_in_same_block_but_payment_tx_last() {
nonce: 0,
gas_limit: 21000,
to: TransactionKind::Call(receiver_address),
value: 1_000_000_u128.into(),
value: Uint::from(1_000_000),
input: Bytes::default(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down Expand Up @@ -567,7 +571,7 @@ fn generate_valid_request(
nonce: 0,
gas_limit: 21000,
to: TransactionKind::Call(fee_recipient),
value: proposer_payment.into(),
value: Uint::from(proposer_payment),
input: Bytes::default(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down Expand Up @@ -673,7 +677,7 @@ fn calculate_receipts_root(
let chain_spec = GOERLI.clone();
let state_provider_db = StateProviderDatabase::new(provider_factory.latest().unwrap());

let mut executor = EVMProcessor::new_with_db(chain_spec.clone(), state_provider_db);
let mut executor = EVMProcessor::new_with_db(chain_spec.clone(), state_provider_db, EthEvmConfig::default());
let block_with_senders = block
.clone()
.with_recovered_senders()
Expand All @@ -699,7 +703,7 @@ fn calculate_receipts_root(
.expect("failed to recover senders");

let state_provider_db = StateProviderDatabase::new(provider_factory.latest().unwrap());
let mut block_executor = EVMProcessor::new_with_db(chain_spec.clone(), state_provider_db);
let mut block_executor = EVMProcessor::new_with_db(chain_spec.clone(), state_provider_db, EthEvmConfig::default());
block_executor
.execute_and_verify_receipt(&new_block, U256::MAX)
.unwrap();
Expand Down Expand Up @@ -729,15 +733,14 @@ fn sign_transaction(secret_key: &SecretKey, transaction: Transaction) -> Transac
}

fn get_provider_factory() -> TestProviderFactory {
let db = create_test_rw_db();
ProviderFactory::new(db, GOERLI.clone())
create_test_provider_factory_with_chain_spec(GOERLI.clone())
}

fn add_account(provider_factory: &TestProviderFactory, address: Address, account: Account) {
let hashed_address = keccak256(address);
let provider = provider_factory.provider_rw().unwrap();
let tx = provider.into_tx();
tx.put::<tables::HashedAccount>(hashed_address, account)
tx.put::<tables::HashedAccounts>(hashed_address, account)
.unwrap();
tx.commit().unwrap();

Expand All @@ -756,11 +759,11 @@ fn add_block_with_hash(provider_factory: &TestProviderFactory, hash: B256, block
.unwrap();
tx.put::<tables::CanonicalHeaders>(header.clone().number, hash)
.unwrap();
tx.put::<tables::HeaderTD>(header.number, U256::MAX.into())
.unwrap();
// tx.put::<tables::HeaderTD>(header.number, U256::MAX.into())
// .unwrap();
tx.put::<tables::HeaderNumbers>(hash, header.number)
.unwrap();
tx.put::<tables::SyncStage>(
tx.put::<tables::StageCheckpoints>(
StageId::Finish.to_string(),
StageCheckpoint {
block_number: header.number,
Expand Down

0 comments on commit fcece84

Please sign in to comment.