Skip to content

Commit

Permalink
[e2e-test] fix error EPROLOGUE_CANT_PAY_GAS_DEPOSIT
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Sep 28, 2023
1 parent 64d34a4 commit 13a646a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
13 changes: 9 additions & 4 deletions vm/e2e-tests/src/gas_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -133,12 +133,17 @@ pub static CREATE_EXISTING_ACCOUNT_NEXT: Lazy<u64> = Lazy::new(|| {
pub static PEER_TO_PEER: Lazy<u64> = 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)
});

Expand Down
3 changes: 3 additions & 0 deletions vm/transaction-benchmarks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ pub mod measurement;

#[cfg(any(test, feature = "fuzzing"))]
pub mod transactions;

#[cfg(test)]
mod test_peer_to_peer;
45 changes: 45 additions & 0 deletions vm/transaction-benchmarks/src/test_peer_to_peer.rs
Original file line number Diff line number Diff line change
@@ -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::<P2PTransferGen>((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);
}
}
}
4 changes: 3 additions & 1 deletion vm/transaction-benchmarks/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ fn universe_strategy(
num_transactions: usize,
) -> impl Strategy<Value = AccountUniverseGen> {
// 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)
}
Expand Down

0 comments on commit 13a646a

Please sign in to comment.