Skip to content

Commit e9b8fe6

Browse files
authored
Fix types tests (#4325)
* remove proptest_types from starcoin-types * fix warnings, remove unused dependencies * add back author_auth_key for legacy block header
1 parent 6a2c1b8 commit e9b8fe6

File tree

11 files changed

+28
-113
lines changed

11 files changed

+28
-113
lines changed

Cargo.lock

Lines changed: 2 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chain/tests/block_test_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ use starcoin_storage::storage::StorageInstance;
1515
use starcoin_storage::Storage;
1616
use starcoin_transaction_builder::{empty_txn_payload, DEFAULT_EXPIRATION_TIME};
1717
use starcoin_types::block::BlockHeaderExtra;
18-
use starcoin_types::proptest_types::{AccountInfoUniverse, Index, SignatureCheckedTransactionGen};
1918
use starcoin_types::transaction::{SignedUserTransaction, Transaction, TransactionPayload};
2019
use starcoin_types::{
2120
block::{Block, BlockBody, BlockHeader},
2221
block_metadata::BlockMetadata,
2322
U256,
2423
};
24+
use starcoin_vm_types::proptest_types::{
25+
AccountInfoUniverse, Index, SignatureCheckedTransactionGen,
26+
};
2527
use std::convert::TryFrom;
2628
use std::sync::Arc;
2729

executor/benchmark/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use starcoin_statedb::ChainStateDB;
1515
use starcoin_storage::storage::StorageInstance;
1616
use starcoin_storage::Storage;
1717
use starcoin_transaction_builder::{
18-
create_signed_txn_with_association_account, encode_create_account_script_function,
19-
encode_transfer_script_by_token_code, encode_transfer_script_function,
18+
create_signed_txn_with_association_account, encode_transfer_script_by_token_code,
19+
encode_transfer_script_function,
2020
};
2121
use starcoin_types::{
2222
account_address,
@@ -25,18 +25,17 @@ use starcoin_types::{
2525
transaction::{Transaction, TransactionPayload},
2626
};
2727
use starcoin_vm_types::account_config::G_STC_TOKEN_CODE;
28-
use starcoin_vm_types::genesis_config::StdlibVersion;
29-
use starcoin_vm_types::token::stc;
30-
use starcoin_vm_types::transaction::authenticator::AuthenticationKey;
3128
use std::sync::mpsc;
3229
use std::sync::Arc;
3330

3431
struct AccountData {
32+
#[allow(dead_code)]
3533
public_key: Ed25519PublicKey,
3634
address: AccountAddress,
3735
}
3836

3937
impl AccountData {
38+
#[allow(dead_code)]
4039
pub fn public_key(&self) -> &Ed25519PublicKey {
4140
&self.public_key
4241
}

executor/tests/executor_test.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use starcoin_config::{BuiltinNetworkID, ChainNetwork};
77
use starcoin_executor::validate_transaction;
88
use starcoin_logger::prelude::*;
99
use starcoin_transaction_builder::{
10-
build_batch_payload_same_amount, build_transfer_txn, encode_create_account_script_function,
11-
encode_transfer_script_by_token_code, raw_peer_to_peer_txn, DEFAULT_EXPIRATION_TIME,
12-
DEFAULT_MAX_GAS_AMOUNT,
10+
build_batch_payload_same_amount, build_transfer_txn, encode_transfer_script_by_token_code,
11+
raw_peer_to_peer_txn, DEFAULT_EXPIRATION_TIME, DEFAULT_MAX_GAS_AMOUNT,
1312
};
1413
use starcoin_types::account::peer_to_peer_txn;
1514
use starcoin_types::identifier::Identifier;
@@ -197,7 +196,7 @@ fn test_batch_transfer() -> Result<()> {
197196

198197
#[stest::test]
199198
fn test_txn_verify_err_case() -> Result<()> {
200-
let (chain_state, net) = prepare_genesis();
199+
let (chain_state, _net) = prepare_genesis();
201200
let mut vm = StarcoinVM::new(None, &chain_state);
202201
let alice = Account::new();
203202
let bob = Account::new();

scripts/nextest.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ cargo nextest run \
3232
-p starcoin-chain \
3333
-p starcoin-network \
3434
-p starcoin-storage \
35+
-p starcoin-types \
36+
-p starcoin-sync \
3537
--retries 2 --build-jobs 8 --test-threads 12 --no-fail-fast --failure-output immediate-final
3638

3739

storage/src/transaction/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use crate::storage::StorageInstance;
88
use crate::{Storage, TransactionStore};
99
use proptest::{collection::vec, prelude::*};
1010
use starcoin_config::RocksdbConfig;
11-
use starcoin_types::{
12-
proptest_types::{AccountInfoUniverse, Index, SignatureCheckedTransactionGen},
13-
transaction::Transaction,
11+
use starcoin_types::transaction::Transaction;
12+
use starcoin_vm_types::proptest_types::{
13+
AccountInfoUniverse, Index, SignatureCheckedTransactionGen,
1414
};
1515

1616
fn init_store(

types/Cargo.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
[dependencies]
22
anyhow = { workspace = true }
33
bcs-ext = { workspace = true }
4-
byteorder = { features = ["std"], workspace = true }
54
bytes = { workspace = true }
65
forkable-jellyfish-merkle = { workspace = true }
76
hex = { features = ["serde"], workspace = true }
8-
num_enum = { workspace = true }
97
proptest = { features = ["std"], optional = true, workspace = true }
108
proptest-derive = { optional = true, workspace = true }
119
rand = { workspace = true }
12-
rand_core = { default-features = false, workspace = true }
1310
schemars = { workspace = true }
1411
serde = { features = ["derive"], workspace = true }
1512
serde_json = { workspace = true }
@@ -22,18 +19,14 @@ lazy_static = { workspace = true }
2219
move-binary-format = { workspace = true }
2320
move-bytecode-verifier = { workspace = true }
2421
move-core-types = { workspace = true }
25-
move-table-extension = { workspace = true }
2622
move-vm-runtime = { workspace = true }
2723
move-vm-types = { workspace = true }
2824
once_cell = { workspace = true }
2925
serde_bytes = { workspace = true }
30-
serde_with = { workspace = true }
31-
serde_yaml = { workspace = true }
32-
strum = { workspace = true }
33-
strum_macros = { workspace = true }
3426

3527
[dev-dependencies]
3628
claims = { workspace = true }
29+
starcoin-vm-types = { workspace = true }
3730

3831
[features]
3932
default = []

types/src/block/legacy.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use starcoin_crypto::{
55
hash::{CryptoHash, CryptoHasher, PlainCryptoHash},
66
HashValue,
77
};
8+
use starcoin_vm_types::transaction::authenticator::AuthenticationKey;
89

910
#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, CryptoHasher, CryptoHash, JsonSchema)]
1011
#[serde(rename = "BlockHeader")]
@@ -19,6 +20,9 @@ pub struct BlockHeader {
1920
number: BlockNumber,
2021
/// Block author.
2122
author: AccountAddress,
23+
/// Block author auth key.
24+
/// this field is deprecated
25+
author_auth_key: Option<AuthenticationKey>,
2226
/// The transaction accumulator root hash after executing this block.
2327
txn_accumulator_root: HashValue,
2428
/// The parent block info's block accumulator root hash.
@@ -47,6 +51,7 @@ impl BlockHeader {
4751
timestamp: u64,
4852
number: BlockNumber,
4953
author: AccountAddress,
54+
author_auth_key: Option<AuthenticationKey>,
5055
txn_accumulator_root: HashValue,
5156
block_accumulator_root: HashValue,
5257
state_root: HashValue,
@@ -64,6 +69,7 @@ impl BlockHeader {
6469
number,
6570
timestamp,
6671
author,
72+
author_auth_key,
6773
txn_accumulator_root,
6874
state_root,
6975
gas_used,
@@ -94,6 +100,7 @@ impl From<crate::block::BlockHeader> for BlockHeader {
94100
timestamp: v.timestamp,
95101
number: v.number,
96102
author: v.author,
103+
author_auth_key: None,
97104
txn_accumulator_root: v.txn_accumulator_root,
98105
block_accumulator_root: v.block_accumulator_root,
99106
state_root: v.state_root,
@@ -141,6 +148,7 @@ impl<'de> Deserialize<'de> for BlockHeader {
141148
timestamp: u64,
142149
number: BlockNumber,
143150
author: AccountAddress,
151+
author_auth_key: Option<AuthenticationKey>,
144152
txn_accumulator_root: HashValue,
145153
block_accumulator_root: HashValue,
146154
state_root: HashValue,
@@ -158,6 +166,7 @@ impl<'de> Deserialize<'de> for BlockHeader {
158166
header_data.timestamp,
159167
header_data.number,
160168
header_data.author,
169+
header_data.author_auth_key,
161170
header_data.txn_accumulator_root,
162171
header_data.block_accumulator_root,
163172
header_data.state_root,

types/src/block/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fn this_header() -> BlockHeader {
4848
timestamp,
4949
number,
5050
author,
51+
None,
5152
txn_accumulator_root,
5253
block_accumulator_root,
5354
state_root,

types/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ pub mod event {
4646

4747
pub mod filter;
4848

49-
#[cfg(any(test, feature = "fuzzing"))]
50-
pub mod proptest_types;
51-
5249
pub mod sign_message {
5350
pub use starcoin_vm_types::sign_message::*;
5451
}

0 commit comments

Comments
 (0)