Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(api): Add more TxSender tests #3001

Merged
merged 7 commits into from
Oct 7, 2024
Merged
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
11 changes: 11 additions & 0 deletions core/lib/types/src/api/state_override.rs
Original file line number Diff line number Diff line change
@@ -21,6 +21,11 @@ impl StateOverride {
self.0.get(address)
}

/// Gets mutable overrides for the specified account.
pub fn get_mut(&mut self, address: &Address) -> Option<&mut OverrideAccount> {
self.0.get_mut(address)
}

/// Iterates over all account overrides.
pub fn iter(&self) -> impl Iterator<Item = (&Address, &OverrideAccount)> + '_ {
self.0.iter()
@@ -48,6 +53,12 @@ impl Bytecode {
}
}

impl AsRef<[u8]> for Bytecode {
fn as_ref(&self) -> &[u8] {
&self.0 .0
}
}

impl Serialize for Bytecode {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
self.0.serialize(serializer)
24 changes: 19 additions & 5 deletions core/node/api_server/src/execution_sandbox/tests.rs
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ use zksync_node_test_utils::{create_l2_block, prepare_recovery_snapshot};
use zksync_state::PostgresStorageCaches;
use zksync_types::{
api::state_override::{OverrideAccount, StateOverride},
fee::Fee,
fee_model::BatchFeeInput,
K256PrivateKey, ProtocolVersionId, Transaction, U256,
};
@@ -210,11 +211,16 @@ async fn test_instantiating_vm(connection: Connection<'static, Core>, block_args
let fee_input = BatchFeeInput::l1_pegged(55, 555);
let (base_fee, gas_per_pubdata) =
derive_base_fee_and_gas_per_pubdata(fee_input, ProtocolVersionId::latest().into());
let tx = Transaction::from(K256PrivateKey::random().create_transfer(
let tx = K256PrivateKey::random().create_transfer_with_fee(
0.into(),
base_fee,
gas_per_pubdata,
));
Fee {
gas_limit: 200_000.into(),
max_fee_per_gas: base_fee.into(),
max_priority_fee_per_gas: 0.into(),
gas_per_pubdata_limit: gas_per_pubdata.into(),
},
);
let tx = Transaction::from(tx);

let (limiter, _) = VmConcurrencyLimiter::new(1);
let vm_permit = limiter.acquire().await.unwrap();
@@ -253,7 +259,15 @@ async fn validating_transaction(set_balance: bool) {
let fee_input = BatchFeeInput::l1_pegged(55, 555);
let (base_fee, gas_per_pubdata) =
derive_base_fee_and_gas_per_pubdata(fee_input, ProtocolVersionId::latest().into());
let tx = K256PrivateKey::random().create_transfer(0.into(), base_fee, gas_per_pubdata);
let tx = K256PrivateKey::random().create_transfer_with_fee(
0.into(),
Fee {
gas_limit: 200_000.into(),
max_fee_per_gas: base_fee.into(),
max_priority_fee_per_gas: 0.into(),
gas_per_pubdata_limit: gas_per_pubdata.into(),
},
);

let (limiter, _) = VmConcurrencyLimiter::new(1);
let vm_permit = limiter.acquire().await.unwrap();
Loading