Skip to content

Commit

Permalink
Fix types tests (#4325)
Browse files Browse the repository at this point in the history
* remove proptest_types from starcoin-types

* fix warnings, remove unused dependencies

* add back author_auth_key for legacy block header
  • Loading branch information
simonjiao authored Dec 5, 2024
1 parent 6a2c1b8 commit e9b8fe6
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 113 deletions.
87 changes: 2 additions & 85 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion chain/tests/block_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ use starcoin_storage::storage::StorageInstance;
use starcoin_storage::Storage;
use starcoin_transaction_builder::{empty_txn_payload, DEFAULT_EXPIRATION_TIME};
use starcoin_types::block::BlockHeaderExtra;
use starcoin_types::proptest_types::{AccountInfoUniverse, Index, SignatureCheckedTransactionGen};
use starcoin_types::transaction::{SignedUserTransaction, Transaction, TransactionPayload};
use starcoin_types::{
block::{Block, BlockBody, BlockHeader},
block_metadata::BlockMetadata,
U256,
};
use starcoin_vm_types::proptest_types::{
AccountInfoUniverse, Index, SignatureCheckedTransactionGen,
};
use std::convert::TryFrom;
use std::sync::Arc;

Expand Down
9 changes: 4 additions & 5 deletions executor/benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use starcoin_statedb::ChainStateDB;
use starcoin_storage::storage::StorageInstance;
use starcoin_storage::Storage;
use starcoin_transaction_builder::{
create_signed_txn_with_association_account, encode_create_account_script_function,
encode_transfer_script_by_token_code, encode_transfer_script_function,
create_signed_txn_with_association_account, encode_transfer_script_by_token_code,
encode_transfer_script_function,
};
use starcoin_types::{
account_address,
Expand All @@ -25,18 +25,17 @@ use starcoin_types::{
transaction::{Transaction, TransactionPayload},
};
use starcoin_vm_types::account_config::G_STC_TOKEN_CODE;
use starcoin_vm_types::genesis_config::StdlibVersion;
use starcoin_vm_types::token::stc;
use starcoin_vm_types::transaction::authenticator::AuthenticationKey;
use std::sync::mpsc;
use std::sync::Arc;

struct AccountData {
#[allow(dead_code)]
public_key: Ed25519PublicKey,
address: AccountAddress,
}

impl AccountData {
#[allow(dead_code)]
pub fn public_key(&self) -> &Ed25519PublicKey {
&self.public_key
}
Expand Down
7 changes: 3 additions & 4 deletions executor/tests/executor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use starcoin_config::{BuiltinNetworkID, ChainNetwork};
use starcoin_executor::validate_transaction;
use starcoin_logger::prelude::*;
use starcoin_transaction_builder::{
build_batch_payload_same_amount, build_transfer_txn, encode_create_account_script_function,
encode_transfer_script_by_token_code, raw_peer_to_peer_txn, DEFAULT_EXPIRATION_TIME,
DEFAULT_MAX_GAS_AMOUNT,
build_batch_payload_same_amount, build_transfer_txn, encode_transfer_script_by_token_code,
raw_peer_to_peer_txn, DEFAULT_EXPIRATION_TIME, DEFAULT_MAX_GAS_AMOUNT,
};
use starcoin_types::account::peer_to_peer_txn;
use starcoin_types::identifier::Identifier;
Expand Down Expand Up @@ -197,7 +196,7 @@ fn test_batch_transfer() -> Result<()> {

#[stest::test]
fn test_txn_verify_err_case() -> Result<()> {
let (chain_state, net) = prepare_genesis();
let (chain_state, _net) = prepare_genesis();
let mut vm = StarcoinVM::new(None, &chain_state);
let alice = Account::new();
let bob = Account::new();
Expand Down
2 changes: 2 additions & 0 deletions scripts/nextest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ cargo nextest run \
-p starcoin-chain \
-p starcoin-network \
-p starcoin-storage \
-p starcoin-types \
-p starcoin-sync \
--retries 2 --build-jobs 8 --test-threads 12 --no-fail-fast --failure-output immediate-final


Expand Down
6 changes: 3 additions & 3 deletions storage/src/transaction/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::storage::StorageInstance;
use crate::{Storage, TransactionStore};
use proptest::{collection::vec, prelude::*};
use starcoin_config::RocksdbConfig;
use starcoin_types::{
proptest_types::{AccountInfoUniverse, Index, SignatureCheckedTransactionGen},
transaction::Transaction,
use starcoin_types::transaction::Transaction;
use starcoin_vm_types::proptest_types::{
AccountInfoUniverse, Index, SignatureCheckedTransactionGen,
};

fn init_store(
Expand Down
9 changes: 1 addition & 8 deletions types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[dependencies]
anyhow = { workspace = true }
bcs-ext = { workspace = true }
byteorder = { features = ["std"], workspace = true }
bytes = { workspace = true }
forkable-jellyfish-merkle = { workspace = true }
hex = { features = ["serde"], workspace = true }
num_enum = { workspace = true }
proptest = { features = ["std"], optional = true, workspace = true }
proptest-derive = { optional = true, workspace = true }
rand = { workspace = true }
rand_core = { default-features = false, workspace = true }
schemars = { workspace = true }
serde = { features = ["derive"], workspace = true }
serde_json = { workspace = true }
Expand All @@ -22,18 +19,14 @@ lazy_static = { workspace = true }
move-binary-format = { workspace = true }
move-bytecode-verifier = { workspace = true }
move-core-types = { workspace = true }
move-table-extension = { workspace = true }
move-vm-runtime = { workspace = true }
move-vm-types = { workspace = true }
once_cell = { workspace = true }
serde_bytes = { workspace = true }
serde_with = { workspace = true }
serde_yaml = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }

[dev-dependencies]
claims = { workspace = true }
starcoin-vm-types = { workspace = true }

[features]
default = []
Expand Down
9 changes: 9 additions & 0 deletions types/src/block/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use starcoin_crypto::{
hash::{CryptoHash, CryptoHasher, PlainCryptoHash},
HashValue,
};
use starcoin_vm_types::transaction::authenticator::AuthenticationKey;

#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, CryptoHasher, CryptoHash, JsonSchema)]
#[serde(rename = "BlockHeader")]
Expand All @@ -19,6 +20,9 @@ pub struct BlockHeader {
number: BlockNumber,
/// Block author.
author: AccountAddress,
/// Block author auth key.
/// this field is deprecated
author_auth_key: Option<AuthenticationKey>,
/// The transaction accumulator root hash after executing this block.
txn_accumulator_root: HashValue,
/// The parent block info's block accumulator root hash.
Expand Down Expand Up @@ -47,6 +51,7 @@ impl BlockHeader {
timestamp: u64,
number: BlockNumber,
author: AccountAddress,
author_auth_key: Option<AuthenticationKey>,
txn_accumulator_root: HashValue,
block_accumulator_root: HashValue,
state_root: HashValue,
Expand All @@ -64,6 +69,7 @@ impl BlockHeader {
number,
timestamp,
author,
author_auth_key,
txn_accumulator_root,
state_root,
gas_used,
Expand Down Expand Up @@ -94,6 +100,7 @@ impl From<crate::block::BlockHeader> for BlockHeader {
timestamp: v.timestamp,
number: v.number,
author: v.author,
author_auth_key: None,
txn_accumulator_root: v.txn_accumulator_root,
block_accumulator_root: v.block_accumulator_root,
state_root: v.state_root,
Expand Down Expand Up @@ -141,6 +148,7 @@ impl<'de> Deserialize<'de> for BlockHeader {
timestamp: u64,
number: BlockNumber,
author: AccountAddress,
author_auth_key: Option<AuthenticationKey>,
txn_accumulator_root: HashValue,
block_accumulator_root: HashValue,
state_root: HashValue,
Expand All @@ -158,6 +166,7 @@ impl<'de> Deserialize<'de> for BlockHeader {
header_data.timestamp,
header_data.number,
header_data.author,
header_data.author_auth_key,
header_data.txn_accumulator_root,
header_data.block_accumulator_root,
header_data.state_root,
Expand Down
1 change: 1 addition & 0 deletions types/src/block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fn this_header() -> BlockHeader {
timestamp,
number,
author,
None,
txn_accumulator_root,
block_accumulator_root,
state_root,
Expand Down
3 changes: 0 additions & 3 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ pub mod event {

pub mod filter;

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

pub mod sign_message {
pub use starcoin_vm_types::sign_message::*;
}
Expand Down
Loading

0 comments on commit e9b8fe6

Please sign in to comment.