Skip to content

Commit

Permalink
fix mpm and executor test (#4276)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Nov 12, 2024
1 parent 03acd54 commit 014122c
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 173 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ futures-timer = { workspace = true }
starcoin-logger = { workspace = true }
parking_lot = { workspace = true }
proptest = { workspace = true }
rand_0_7_3 = { workspace = true }
rand = { workspace = true }
rand_core = { default-features = false, workspace = true }
starcoin-account-api = { workspace = true }
Expand Down Expand Up @@ -62,4 +63,4 @@ harness = false
name = "bench_vm"

[target."cfg(target_os=\"linux\")".dependencies]
pprof = { version = "0.10", features = ["flamegraph", "criterion"] }
pprof = { version = "0.10", features = ["flamegraph", "criterion"] }
2 changes: 1 addition & 1 deletion benchmarks/benches/bench_state_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use forkable_jellyfish_merkle::blob::Blob;
use forkable_jellyfish_merkle::HashValueKey;
#[cfg(target_os = "linux")]
use pprof::criterion::{Output, PProfProfiler};
use rand::{rngs::StdRng, SeedableRng};
use rand_0_7_3::{prelude::StdRng, SeedableRng};
use starcoin_config::RocksdbConfig;
use starcoin_crypto::hash::*;
use starcoin_state_store_api::StateNodeStore;
Expand Down
2 changes: 1 addition & 1 deletion commons/forkable-jellyfish-merkle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bcs = { workspace = true }
criterion = { workspace = true }
proptest = { workspace = true }
proptest-derive = { workspace = true }
rand_0_7_3= { workspace = true }
rand_0_7_3 = { workspace = true }
rand_core = { default-features = false, workspace = true }
starcoin-crypto = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,15 @@ fn many_versions_get_proof_and_verify_tree_root(seed: &[u8], num_versions: usize
}

for (i, (k, v, _)) in kvs.iter().enumerate() {
let random_version = rng.gen_range(i..i + num_versions);
let random_version = rng.gen_range(i, i + num_versions);
let history_root = roots[random_version];
let (value, proof) = tree.get_with_proof(history_root, *k).unwrap();
assert_eq!(value.unwrap(), *v);
assert!(proof.verify(history_root, *k, Some(v)).is_ok());
}

for (i, (k, _, v)) in kvs.iter().enumerate() {
let random_version = rng.gen_range(i + num_versions..2 * num_versions);
let random_version = rng.gen_range(i + num_versions, 2 * num_versions);
let history_root = roots[random_version];
let (value, proof) = tree.get_with_proof(history_root, *k).unwrap();
assert_eq!(value.unwrap(), *v);
Expand Down
3 changes: 0 additions & 3 deletions executor/tests/block_reward_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn test_block_reward() -> Result<()> {
HashValue::zero(),
block_timestamp,
*alice.address(),
Some(alice.auth_key()),
0,
block_number,
net.chain_id(),
Expand All @@ -48,7 +47,6 @@ fn test_block_reward() -> Result<()> {
HashValue::zero(),
block_timestamp,
*bob.address(),
Some(bob.auth_key()),
0,
block_number,
net.chain_id(),
Expand All @@ -74,7 +72,6 @@ fn test_block_reward() -> Result<()> {
HashValue::zero(),
block_timestamp,
*alice.address(),
Some(alice.auth_key()),
0,
block_number,
net.chain_id(),
Expand Down
7 changes: 2 additions & 5 deletions executor/tests/error_code_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ fn test_block_metadata_error_code() -> Result<()> {
starcoin_crypto::HashValue::random(),
net.time_service().now_millis(),
*account1.address(),
Some(account1.auth_key()),
0,
1,
net.chain_id(),
Expand All @@ -66,7 +65,6 @@ fn test_block_metadata_error_code() -> Result<()> {
starcoin_crypto::HashValue::random(),
net.time_service().now_millis(),
*account1.address(),
Some(account1.auth_key()),
0,
3, //EBLOCK_NUMBER_MISMATCH
net.chain_id(),
Expand All @@ -83,7 +81,6 @@ fn test_block_metadata_error_code() -> Result<()> {
starcoin_crypto::HashValue::random(),
0, //EINVALID_TIMESTAMP
*account1.address(),
Some(account1.auth_key()),
0,
2,
net.chain_id(),
Expand Down Expand Up @@ -144,7 +141,7 @@ fn test_execute_transfer_txn_with_wrong_token_code() -> Result<()> {
net.chain_id(),
);

let txn2 = Transaction::UserTransaction(account1.sign_txn(raw_txn));
let txn2 = Transaction::UserTransaction(account1.sign_txn(raw_txn)?);
let output = starcoin_executor::execute_transactions(&chain_state, vec![txn2], None).unwrap();
assert_eq!(
KeptVMStatus::MiscellaneousError,
Expand Down Expand Up @@ -179,7 +176,7 @@ fn test_execute_transfer_txn_with_dummy_gas_token_code() -> Result<()> {
net.chain_id(),
);

let txn2 = Transaction::UserTransaction(account1.sign_txn(raw_txn));
let txn2 = Transaction::UserTransaction(account1.sign_txn(raw_txn)?);
let output = execute_and_apply(&chain_state, txn2);
assert_eq!(
TransactionStatus::Discard(StatusCode::BAD_TRANSACTION_FEE_CURRENCY),
Expand Down
Loading

0 comments on commit 014122c

Please sign in to comment.