Skip to content

Commit

Permalink
Fix tests compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Eitu33 committed Apr 28, 2023
1 parent 947a3ed commit 4550f9d
Show file tree
Hide file tree
Showing 42 changed files with 362 additions and 207 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.

6 changes: 4 additions & 2 deletions massa-async-pool/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl Deserializer<BTreeMap<AsyncMessageId, AsyncMessage>> for AsyncPoolDeseriali
fn test_take_batch() {
use massa_hash::Hash;
use massa_models::{
address::{Address, UserAddress},
address::{Address, UserAddress, UserAddressV0},
amount::Amount,
slot::Slot,
};
Expand All @@ -382,7 +382,9 @@ fn test_take_batch() {
bootstrap_part_size: 100,
};
let mut pool = AsyncPool::new(config);
let address = Address::User(UserAddress(Hash::compute_from(b"abc")));
let address = Address::User(UserAddress::UserAddressV0(UserAddressV0(
Hash::compute_from(b"abc"),
)));
for i in 1..10 {
let message = AsyncMessage::new_with_hash(
Slot::new(0, 0),
Expand Down
2 changes: 1 addition & 1 deletion massa-async-pool/src/test_exports/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn create_async_pool(
}

fn get_random_address() -> Address {
let keypair = KeyPair::generate();
let keypair = KeyPair::generate(0).unwrap();
Address::from_public_key(&keypair.get_public_key())
}

Expand Down
2 changes: 1 addition & 1 deletion massa-bootstrap/src/tests/binders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::str::FromStr;

lazy_static::lazy_static! {
pub static ref BOOTSTRAP_CONFIG_KEYPAIR: (BootstrapConfig, KeyPair) = {
let keypair = KeyPair::generate();
let keypair = KeyPair::generate(0).unwrap();
(get_bootstrap_config(NodeId::new(keypair.get_public_key())), keypair)
};
}
Expand Down
4 changes: 2 additions & 2 deletions massa-bootstrap/src/tests/scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use tokio::{net::TcpStream, sync::mpsc};

lazy_static::lazy_static! {
pub static ref BOOTSTRAP_CONFIG_KEYPAIR: (BootstrapConfig, KeyPair) = {
let keypair = KeyPair::generate();
let keypair = KeyPair::generate(0).unwrap();
(get_bootstrap_config(NodeId::new(keypair.get_public_key())), keypair)
};
}
Expand All @@ -72,7 +72,7 @@ async fn test_bootstrap_server() {
let periods_per_cycle = 2;
let (bootstrap_config, keypair): &(BootstrapConfig, KeyPair) = &BOOTSTRAP_CONFIG_KEYPAIR;
let rolls_path = PathBuf::from_str("../massa-node/base_config/initial_rolls.json").unwrap();
let genesis_address = Address::from_public_key(&KeyPair::generate().get_public_key());
let genesis_address = Address::from_public_key(&KeyPair::generate(0).unwrap().get_public_key());

let (consensus_controller, mut consensus_event_receiver) =
MockConsensusController::new_with_receiver();
Expand Down
13 changes: 8 additions & 5 deletions massa-bootstrap/src/tests/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use massa_final_state::{FinalState, FinalStateConfig};
use massa_hash::Hash;
use massa_ledger_exports::{LedgerChanges, LedgerEntry, SetUpdateOrDelete};
use massa_ledger_worker::test_exports::create_final_ledger;
use massa_models::address::SCAddress;
use massa_models::block::BlockDeserializerArgs;
use massa_models::bytecode::Bytecode;
use massa_models::config::{
Expand Down Expand Up @@ -247,10 +248,10 @@ pub fn get_random_final_state_bootstrap(
// insert the last possible address to prevent the last cursor to move when testing the changes
// The magic number at idx 0 is to account for address variant leader. At time of writing,
// the highest value for encoding this variant in serialized form is `1`.
let mut bytes = [255; 33];
bytes[0] = 1;
let bytes = [255; 32];
// CURRENT TODO: check if this has an impact on the bootstrap test
sorted_ledger.insert(
Address::from_prefixed_bytes(&bytes).unwrap(),
Address::SC(SCAddress::from_bytes_without_version(0, &bytes).unwrap()),
get_random_ledger_entry(),
);

Expand All @@ -275,7 +276,7 @@ pub fn get_dummy_block_id(s: &str) -> BlockId {
}

pub fn get_random_address() -> Address {
let priv_key = KeyPair::generate();
let priv_key = KeyPair::generate(0).unwrap();
Address::from_public_key(&priv_key.get_public_key())
}

Expand Down Expand Up @@ -383,12 +384,14 @@ pub fn assert_eq_bootstrap_graph(v1: &BootstrapableGraph, v2: &BootstrapableGrap
}

pub fn get_boot_state() -> BootstrapableGraph {
let keypair = KeyPair::generate();
let keypair = KeyPair::generate(0).unwrap();

let block = Block::new_verifiable(
Block {
header: BlockHeader::new_verifiable(
BlockHeader {
current_version: 0,
announced_version: 0,
// associated slot
// all header endorsements are supposed to point towards this one
slot: Slot::new(1, 0),
Expand Down
2 changes: 1 addition & 1 deletion massa-consensus-exports/src/export_active_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl Deserializer<ExportActiveBlock> for ExportActiveBlockDeserializer {
/// use massa_signature::KeyPair;
/// use massa_serialization::{Serializer, Deserializer, DeserializeError};
///
/// let keypair = KeyPair::generate();
/// let keypair = KeyPair::generate(0).unwrap();
/// let parents = (0..THREAD_COUNT)
/// .map(|i| BlockId(Hash::compute_from(&[i])))
/// .collect();
Expand Down
13 changes: 13 additions & 0 deletions massa-execution-worker/src/interface_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ impl InterfaceImpl {
operation_datastore: Option<Datastore>,
) -> InterfaceImpl {
use massa_ledger_exports::{LedgerEntry, SetUpdateOrDelete};
use massa_models::config::{
MIP_STORE_STATS_BLOCK_CONSIDERED, MIP_STORE_STATS_COUNTERS_MAX,
};
use massa_module_cache::{config::ModuleCacheConfig, controller::ModuleCache};
use massa_versioning::versioning::{MipStatsConfig, MipStore};
use parking_lot::RwLock;

let vesting_file = super::tests::get_initials_vesting(false);
Expand All @@ -95,12 +99,21 @@ impl InterfaceImpl {
.unwrap(),
);

// create an empty default store
let mip_stats_config = MipStatsConfig {
block_count_considered: MIP_STORE_STATS_BLOCK_CONSIDERED,
counters_max: MIP_STORE_STATS_COUNTERS_MAX,
};
let mip_store =
MipStore::try_from(([], mip_stats_config)).expect("Cannot create an empty MIP store");

let mut execution_context = ExecutionContext::new(
config.clone(),
final_state,
Default::default(),
module_cache,
vesting_manager,
mip_store,
);
execution_context.stack = vec![ExecutionStackElement {
address: sender_addr,
Expand Down
4 changes: 3 additions & 1 deletion massa-execution-worker/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn get_initials() -> (NamedTempFile, HashMap<Address, LedgerEntry>) {
/// to the address.
#[allow(dead_code)] // to avoid warnings on gas_calibration feature
pub fn get_random_address_full() -> (Address, KeyPair) {
let keypair = KeyPair::generate();
let keypair = KeyPair::generate(0).unwrap();
(Address::from_public_key(&keypair.get_public_key()), keypair)
}

Expand Down Expand Up @@ -159,6 +159,8 @@ pub fn create_block(

let header = BlockHeader::new_verifiable(
BlockHeader {
current_version: 0,
announced_version: 0,
slot,
parents: vec![],
operation_merkle_root,
Expand Down
Loading

0 comments on commit 4550f9d

Please sign in to comment.