Skip to content

Commit

Permalink
fix some warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg committed Sep 20, 2023
1 parent e982b25 commit 51d893e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
75 changes: 75 additions & 0 deletions executor/tests/executor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,3 +1090,78 @@ fn test_chunk_block_transactions() -> Result<()> {

Ok(())
}

#[stest::test]
fn test_stm_dependency() -> Result<()> {
let (chain_state, net) = prepare_genesis();

let account1 = Account::new();
let txn1 = Transaction::UserTransaction(create_account_txn_sent_as_association(
&account1, 0, 50_000_000, 1, &net,
));
let output1 = execute_and_apply(&chain_state, txn1);
assert_eq!(KeptVMStatus::Executed, output1.status().status().unwrap());

let account2 = Account::new();

let txn2 = Transaction::UserTransaction(account1.sign_txn(
starcoin_transaction_builder::build_transfer_txn(
*account1.address(),
*account2.address(),
0,
1000,
1,
DEFAULT_MAX_GAS_AMOUNT,
net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME,
net.chain_id(),
),
));

let output2 = execute_and_apply(&chain_state, txn2);
assert_eq!(KeptVMStatus::Executed, output2.status().status().unwrap());

let txn3 = Transaction::UserTransaction(account1.sign_txn(
starcoin_transaction_builder::build_transfer_txn(
*account1.address(),
*account2.address(),
1,
1000,
1,
DEFAULT_MAX_GAS_AMOUNT,
net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME,
net.chain_id(),
),
));
let txn4 = Transaction::UserTransaction(account1.sign_txn(
starcoin_transaction_builder::build_transfer_txn(
*account1.address(),
*account2.address(),
1,
1000,
1,
DEFAULT_MAX_GAS_AMOUNT,
net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME,
net.chain_id(),
),
));

let txn5 = Transaction::UserTransaction(account1.sign_txn(
starcoin_transaction_builder::build_transfer_txn(
*account1.address(),
*account2.address(),
1,
1000,
1,
DEFAULT_MAX_GAS_AMOUNT,
net.time_service().now_secs() + DEFAULT_EXPIRATION_TIME,
net.chain_id(),
),
));

StarcoinVM::set_concurrency_level_once(4);

let _output =
starcoin_executor::execute_transactions(&chain_state, vec![txn3, txn4, txn5], None).unwrap();

Ok(())
}
2 changes: 1 addition & 1 deletion vm/vm-runtime/src/block_executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl BlockStarcoinVM {
println!("Sequential execution starts...");
let seq_timer = Instant::now();
let mut vm = StarcoinVM::new(None);
let ret = vm.execute_block_transactions(state_view, transactions, None);
let _ret = vm.execute_block_transactions(state_view, transactions, None);
let seq_exec_t = seq_timer.elapsed();
println!(
"Sequential execution finishes, TPS = {}",
Expand Down

0 comments on commit 51d893e

Please sign in to comment.