#![doc(html_root_url = "https://docs.rs/casper-engine-test-support/7.0.1")]
#![doc(
html_favicon_url = "https://raw.githubusercontent.com/casper-network/casper-node/blob/dev/images/Casper_Logo_Favicon_48.png",
html_logo_url = "https://raw.githubusercontent.com/casper-network/casper-node/blob/dev/images/Casper_Logo_Favicon.png",
test(attr(forbid(warnings)))
)]
#![warn(missing_docs)]
mod additive_map_diff;
pub mod auction;
mod chainspec_config;
mod deploy_item_builder;
mod execute_request_builder;
mod step_request_builder;
pub mod transfer;
mod upgrade_request_builder;
pub mod utils;
mod wasm_test_builder;
use num_rational::Ratio;
use once_cell::sync::Lazy;
#[doc(inline)]
#[allow(deprecated)]
pub use casper_execution_engine::core::engine_state::engine_config::{
DEFAULT_MAX_ASSOCIATED_KEYS, DEFAULT_MAX_RUNTIME_CALL_STACK_HEIGHT,
DEFAULT_MAX_STORED_VALUE_SIZE, DEFAULT_MINIMUM_DELEGATION_AMOUNT,
};
use casper_execution_engine::{
core::engine_state::{
engine_config::{DEFAULT_FEE_HANDLING, DEFAULT_REFUND_HANDLING},
genesis::ExecConfigBuilder,
ChainspecRegistry, ExecConfig, GenesisAccount, GenesisConfig, RunGenesisRequest,
},
shared::{system_config::SystemConfig, wasm_config::WasmConfig},
};
use casper_hashing::Digest;
use casper_types::{account::AccountHash, Motes, ProtocolVersion, PublicKey, SecretKey, U512};
pub use additive_map_diff::AdditiveMapDiff;
pub use chainspec_config::{ChainspecConfig, PRODUCTION_CHAINSPEC_PATH};
pub use deploy_item_builder::DeployItemBuilder;
pub use execute_request_builder::ExecuteRequestBuilder;
pub use step_request_builder::StepRequestBuilder;
pub use upgrade_request_builder::UpgradeRequestBuilder;
pub use wasm_test_builder::{InMemoryWasmTestBuilder, LmdbWasmTestBuilder, WasmTestBuilder};
pub const DEFAULT_VALIDATOR_SLOTS: u32 = 5;
pub const DEFAULT_AUCTION_DELAY: u64 = 1;
pub const DEFAULT_LOCKED_FUNDS_PERIOD_MILLIS: u64 = 0;
pub const DEFAULT_VESTING_SCHEDULE_PERIOD_MILLIS: u64 = 0;
pub const DEFAULT_UNBONDING_DELAY: u64 = 7;
pub const DEFAULT_ROUND_SEIGNIORAGE_RATE: Ratio<u64> = Ratio::new_raw(7, 175070816);
pub const DEFAULT_CHAIN_NAME: &str = "casper-execution-engine-testing";
pub const DEFAULT_GENESIS_TIMESTAMP_MILLIS: u64 = 0;
pub const DEFAULT_BLOCK_TIME: u64 = 0;
pub const DEFAULT_GAS_PRICE: u64 = 1;
pub const ARG_AMOUNT: &str = "amount";
pub const TIMESTAMP_MILLIS_INCREMENT: u64 = 30_000; pub static DEFAULT_GENESIS_CONFIG_HASH: Lazy<Digest> = Lazy::new(|| [42; 32].into());
pub static DEFAULT_ACCOUNT_PUBLIC_KEY: Lazy<PublicKey> = Lazy::new(|| {
let secret_key = SecretKey::ed25519_from_bytes([199; SecretKey::ED25519_LENGTH]).unwrap();
PublicKey::from(&secret_key)
});
pub static DEFAULT_ACCOUNT_ADDR: Lazy<AccountHash> =
Lazy::new(|| AccountHash::from(&*DEFAULT_ACCOUNT_PUBLIC_KEY));
pub static DEFAULT_ACCOUNT_KEY: Lazy<AccountHash> =
Lazy::new(|| AccountHash::from(&*DEFAULT_ACCOUNT_PUBLIC_KEY));
pub const DEFAULT_ACCOUNT_INITIAL_BALANCE: u64 = 100_000_000_000_000_000u64;
pub const MINIMUM_ACCOUNT_CREATION_BALANCE: u64 = 7_500_000_000_000_000u64;
pub static DEFAULT_PROPOSER_PUBLIC_KEY: Lazy<PublicKey> = Lazy::new(|| {
let secret_key = SecretKey::ed25519_from_bytes([198; SecretKey::ED25519_LENGTH]).unwrap();
PublicKey::from(&secret_key)
});
pub static DEFAULT_PROPOSER_ADDR: Lazy<AccountHash> =
Lazy::new(|| AccountHash::from(&*DEFAULT_PROPOSER_PUBLIC_KEY));
pub static DEFAULT_ACCOUNTS: Lazy<Vec<GenesisAccount>> = Lazy::new(|| {
let mut ret = Vec::new();
let genesis_account = GenesisAccount::account(
DEFAULT_ACCOUNT_PUBLIC_KEY.clone(),
Motes::new(DEFAULT_ACCOUNT_INITIAL_BALANCE.into()),
None,
);
ret.push(genesis_account);
let proposer_account = GenesisAccount::account(
DEFAULT_PROPOSER_PUBLIC_KEY.clone(),
Motes::new(DEFAULT_ACCOUNT_INITIAL_BALANCE.into()),
None,
);
ret.push(proposer_account);
ret
});
pub static DEFAULT_PROTOCOL_VERSION: Lazy<ProtocolVersion> = Lazy::new(|| ProtocolVersion::V1_0_0);
pub static DEFAULT_PAYMENT: Lazy<U512> = Lazy::new(|| U512::from(2_500_000_000_000u64));
pub static DEFAULT_WASM_CONFIG: Lazy<WasmConfig> = Lazy::new(WasmConfig::default);
pub static DEFAULT_SYSTEM_CONFIG: Lazy<SystemConfig> = Lazy::new(SystemConfig::default);
pub static DEFAULT_EXEC_CONFIG: Lazy<ExecConfig> = Lazy::new(|| {
ExecConfigBuilder::default()
.with_accounts(DEFAULT_ACCOUNTS.clone())
.with_wasm_config(*DEFAULT_WASM_CONFIG)
.with_system_config(*DEFAULT_SYSTEM_CONFIG)
.with_validator_slots(DEFAULT_VALIDATOR_SLOTS)
.with_auction_delay(DEFAULT_AUCTION_DELAY)
.with_locked_funds_period_millis(DEFAULT_LOCKED_FUNDS_PERIOD_MILLIS)
.with_round_seigniorage_rate(DEFAULT_ROUND_SEIGNIORAGE_RATE)
.with_unbonding_delay(DEFAULT_UNBONDING_DELAY)
.with_genesis_timestamp_millis(DEFAULT_GENESIS_TIMESTAMP_MILLIS)
.with_refund_handling(DEFAULT_REFUND_HANDLING)
.with_fee_handling(DEFAULT_FEE_HANDLING)
.build()
});
pub static DEFAULT_GENESIS_CONFIG: Lazy<GenesisConfig> = Lazy::new(|| {
GenesisConfig::new(
DEFAULT_CHAIN_NAME.to_string(),
DEFAULT_GENESIS_TIMESTAMP_MILLIS,
*DEFAULT_PROTOCOL_VERSION,
#[allow(deprecated)]
DEFAULT_EXEC_CONFIG.clone(),
)
});
pub static DEFAULT_CHAINSPEC_REGISTRY: Lazy<ChainspecRegistry> =
Lazy::new(|| ChainspecRegistry::new_with_genesis(&[1, 2, 3], &[4, 5, 6]));
#[deprecated(
since = "2.3.0",
note = "prefer `PRODUCTION_RUN_GENESIS_REQUEST` as it uses cost tables matching those used in \
Casper Mainnet"
)]
pub static DEFAULT_RUN_GENESIS_REQUEST: Lazy<RunGenesisRequest> = Lazy::new(|| {
RunGenesisRequest::new(
*DEFAULT_GENESIS_CONFIG_HASH,
*DEFAULT_PROTOCOL_VERSION,
#[allow(deprecated)]
DEFAULT_EXEC_CONFIG.clone(),
DEFAULT_CHAINSPEC_REGISTRY.clone(),
)
});
pub static PRODUCTION_RUN_GENESIS_REQUEST: Lazy<RunGenesisRequest> = Lazy::new(|| {
ChainspecConfig::create_genesis_request_from_production_chainspec(
DEFAULT_ACCOUNTS.clone(),
*DEFAULT_PROTOCOL_VERSION,
)
.expect("must create the request")
});
pub static PRODUCTION_ROUND_SEIGNIORAGE_RATE: Lazy<Ratio<u64>> = Lazy::new(|| {
let chainspec = ChainspecConfig::from_chainspec_path(&*PRODUCTION_CHAINSPEC_PATH)
.expect("must create chainspec_config");
chainspec.core_config.round_seigniorage_rate
});
pub static SYSTEM_ADDR: Lazy<AccountHash> = Lazy::new(|| PublicKey::System.to_account_hash());
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn defaults_should_match_production_chainspec_values() {
let production = ChainspecConfig::from_chainspec_path(&*PRODUCTION_CHAINSPEC_PATH).unwrap();
assert_eq!(production.core_config.auction_delay, DEFAULT_AUCTION_DELAY);
assert_eq!(
production.core_config.locked_funds_period.millis(),
DEFAULT_LOCKED_FUNDS_PERIOD_MILLIS
);
assert_eq!(
production.core_config.unbonding_delay,
DEFAULT_UNBONDING_DELAY
);
assert_eq!(
production.core_config.round_seigniorage_rate.reduced(),
DEFAULT_ROUND_SEIGNIORAGE_RATE.reduced()
);
assert_eq!(
production.core_config.max_associated_keys,
DEFAULT_MAX_ASSOCIATED_KEYS
);
assert_eq!(
production.core_config.max_runtime_call_stack_height,
DEFAULT_MAX_RUNTIME_CALL_STACK_HEIGHT
);
assert_eq!(
production.core_config.minimum_delegation_amount,
DEFAULT_MINIMUM_DELEGATION_AMOUNT
);
assert_eq!(production.wasm_config, WasmConfig::default());
assert_eq!(production.system_costs_config, SystemConfig::default());
}
}