Skip to content

Commit

Permalink
Fix test. Remove comments. Update comment docs for estimate_gas_impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
MexicanAce committed Aug 9, 2023
1 parent 0eda41a commit e97b616
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
7 changes: 1 addition & 6 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ pub const TEST_NODE_NETWORK_ID: u16 = 260;
pub const L1_GAS_PRICE: u64 = 50_000_000_000;
/// L2 Gas Price (0.25 gwei)
pub const L2_GAS_PRICE: u64 = 250_000_000;
// pub const MAX_TX_ERGS_LIMIT: u32 = 80_000_000;
// pub const BLOCK_OVERHEAD_GAS: u32 = 1_200_000;
// pub const BLOCK_OVERHEAD_L1_GAS: u32 = 1_000_000;
// pub const L1_GAS_PER_PUBDATA_BYTE: u32 = 17;
// pub const BLOCK_OVERHEAD_PUBDATA: U256 = BLOCK_OVERHEAD_L1_GAS / L1_GAS_PER_PUBDATA_BYTE;

/// Basic information about the generated block (which is block l1 batch and miniblock).
/// Currently, this test node supports exactly one transaction per block.
Expand Down Expand Up @@ -151,7 +146,7 @@ impl InMemoryNodeInner {
///
/// # Returns
///
/// A `BoxFuture` containing a `Result` with a `Fee` representing the estimated gas related data.
/// A `Result` with a `Fee` representing the estimated gas related data.
pub fn estimate_gas_impl(
&self,
req: zksync_types::transaction_request::CallRequest,
Expand Down
31 changes: 16 additions & 15 deletions src/zks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,37 +193,38 @@ mod tests {

#[tokio::test]
async fn test_estimate_fee() {
let node = InMemoryNode::new(Default::default(), crate::ShowCalls::None, false, false);
let node = InMemoryNode::new(None, crate::ShowCalls::None, false, false);
let namespace = ZkMockNamespaceImpl::new(node.get_inner());

let mock_request = CallRequest {
from: Some(
"0x0000000000000000000000000000000000000000"
"0xa61464658afeaf65cccaafd3a512b69a83b77618"
.parse()
.unwrap(),
),
to: Some(
"0x0000000000000000000000000000000000000001"
"0x36615cf349d7f6344891b1e7ca7c72883f5dc049"
.parse()
.unwrap(),
),
gas: Some(U256::from(21000)),
gas_price: Some(U256::from(20)),
max_fee_per_gas: Some(U256::from(30)),
max_priority_fee_per_gas: Some(U256::from(10)),
value: Some(U256::from(1000)),
data: Some(vec![1, 2, 3, 4].into()),
nonce: Some(U256::from(1)),
transaction_type: Some(zksync_basic_types::U64::from(1)),
gas: Some(U256::from(0)),
gas_price: Some(U256::from(0)),
max_fee_per_gas: None,
max_priority_fee_per_gas: None,
value: Some(U256::from(0)),
data: Some(vec![0, 0].into()),
nonce: Some(U256::from(0)),
transaction_type: None,
access_list: None,
eip712_meta: None,
};

let result = namespace.estimate_fee(mock_request).await.unwrap();
println!("result: {:?}", result);

assert_eq!(result.gas_limit, U256::from(1000000000));
assert_eq!(result.max_fee_per_gas, U256::from(1000000000));
assert_eq!(result.max_priority_fee_per_gas, U256::from(1000000000));
assert_eq!(result.gas_per_pubdata_limit, U256::from(1000000000));
assert_eq!(result.gas_limit, U256::from(904431));
assert_eq!(result.max_fee_per_gas, U256::from(250000000));
assert_eq!(result.max_priority_fee_per_gas, U256::from(0));
assert_eq!(result.gas_per_pubdata_limit, U256::from(4080));
}
}

0 comments on commit e97b616

Please sign in to comment.