diff --git a/vm/e2e-tests/src/gas_costs.rs b/vm/e2e-tests/src/gas_costs.rs index c491ca2973..99c919aee3 100644 --- a/vm/e2e-tests/src/gas_costs.rs +++ b/vm/e2e-tests/src/gas_costs.rs @@ -13,7 +13,7 @@ use starcoin_crypto::{ed25519::Ed25519PrivateKey, PrivateKey, Uniform}; use starcoin_vm_types::transaction::{authenticator::AuthenticationKey, SignedUserTransaction}; /// The gas each transaction is configured to reserve. If the gas available in the account, -/// converted to microaptos, falls below this threshold, transactions are expected to fail with +/// converted to micro STC, falls below this threshold, transactions are expected to fail with /// an insufficient balance. pub const TXN_RESERVED: u64 = 500_000; @@ -133,12 +133,17 @@ pub static CREATE_EXISTING_ACCOUNT_NEXT: Lazy = Lazy::new(|| { pub static PEER_TO_PEER: Lazy = Lazy::new(|| { // Compute gas used by running a placeholder transaction. let mut executor = FakeExecutor::from_genesis_file(); - let sender = AccountData::new(1_000_000, 10); - let receiver = AccountData::new(1_000_000, 10); + // XXX FIXME YSG + // let sender = AccountData::new(1_000_000, 10); + // let receiver = AccountData::new(1_000_000, 10); + let sender = AccountData::new(1_000_000_000, 10); + let receiver = AccountData::new(1_000_000_000, 10); executor.add_account_data(&sender); executor.add_account_data(&receiver); - let txn = peer_to_peer_txn(sender.account(), receiver.account(), 10, 20_000); + // XXX FIXME YSG + // let txn = peer_to_peer_txn(sender.account(), receiver.account(), 10, 20_000); + let txn = peer_to_peer_txn(sender.account(), receiver.account(), 10, 10); compute_gas_used(txn, &mut executor) }); diff --git a/vm/transaction-benchmarks/src/lib.rs b/vm/transaction-benchmarks/src/lib.rs index 723e0620bf..1191e8b4c8 100644 --- a/vm/transaction-benchmarks/src/lib.rs +++ b/vm/transaction-benchmarks/src/lib.rs @@ -8,3 +8,6 @@ pub mod measurement; #[cfg(any(test, feature = "fuzzing"))] pub mod transactions; + +#[cfg(test)] +mod test_peer_to_peer; diff --git a/vm/transaction-benchmarks/src/test_peer_to_peer.rs b/vm/transaction-benchmarks/src/test_peer_to_peer.rs new file mode 100644 index 0000000000..d73b09172c --- /dev/null +++ b/vm/transaction-benchmarks/src/test_peer_to_peer.rs @@ -0,0 +1,45 @@ +// Copyright (c) The Starcoin Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use crate::transactions::TransactionBencher; +use proptest::arbitrary::any_with; +use starcoin_language_e2e_tests::account::AccountData; +use starcoin_language_e2e_tests::account_universe::P2PTransferGen; +use starcoin_language_e2e_tests::common_transactions::peer_to_peer_txn; +use starcoin_language_e2e_tests::executor::FakeExecutor; + +#[test] +pub fn bencher_sequence() { + let default_num_account = 2; + let default_num_transactions = 1; + let maxium_transfer_balance = 100; + let minium_transfer_balance = 10; + + let bencher = TransactionBencher::new( + any_with::((minium_transfer_balance, maxium_transfer_balance)), + default_num_account, + default_num_transactions, + ); + bencher.manual_sequence(default_num_account, default_num_transactions, 1, 1); +} + +#[test] +pub fn fake_execute_with_account_data() { + // Compute gas used by running a placeholder transaction. + let mut executor = FakeExecutor::from_genesis_file(); + let sender = AccountData::new(1_000_000_000, 10); + let receiver = AccountData::new(1_000_000_000, 10); + executor.add_account_data(&sender); + executor.add_account_data(&receiver); + + let txn = peer_to_peer_txn(sender.account(), receiver.account(), 10, 10); + let result = executor.execute_block(vec![txn]); + match result { + Ok(outputs) => { + println!("Outputs: {:#?}", outputs); + } + Err(err) => { + println!("Error: {:#?}", err); + } + } +} diff --git a/vm/transaction-benchmarks/src/transactions.rs b/vm/transaction-benchmarks/src/transactions.rs index 10f46bb829..83e4ba158e 100644 --- a/vm/transaction-benchmarks/src/transactions.rs +++ b/vm/transaction-benchmarks/src/transactions.rs @@ -372,7 +372,9 @@ fn universe_strategy( num_transactions: usize, ) -> impl Strategy { // Multiply by 5 past the number of to provide - let max_balance = TXN_RESERVED * num_transactions as u64 * 5; + // XXX FIXME YSG + // let max_balance = TXN_RESERVED * num_transactions as u64 * 5; + let max_balance = 5_000_000_000; let balance_strategy = log_balance_strategy(max_balance); AccountUniverseGen::strategy(num_accounts, balance_strategy) }