Skip to content

Commit

Permalink
[spellcheck] Part 4: Spell check directories genesis-tools and integr…
Browse files Browse the repository at this point in the history
…ation-tests (#12789)
  • Loading branch information
shreyan-gupta authored Jan 24, 2025
1 parent e268099 commit 77f19f7
Show file tree
Hide file tree
Showing 39 changed files with 87 additions and 76 deletions.
1 change: 1 addition & 0 deletions chain/chain/src/test_utils/kv_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl MockEpochManager {
})
.collect();

// cspell:ignore coef
let validators_per_shard = block_producers.len() / vs.validator_groups as usize;
let coefficient = block_producers.len() / vs.num_shards as usize;

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"bitmask",
"bitvec",
"BLOCKLIST",
"bootnodes",
"borsh",
"bufbuild",
"bytesize",
Expand Down
3 changes: 3 additions & 0 deletions genesis-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ We also make sure the trie does not compress the subtrees due to similar account
benchmarking, loadtesting, and estimating system parameters.

To start node with 20k accounts first create configs:

```bash
cargo run --package neard --bin neard -- init --test-seed=alice.near --account-id=test.near --fast
```

Then create state dump with how many accounts you want:

```bash
cargo run --package genesis-populate --bin genesis-populate -- --additional-accounts-num=20000
```
Expand All @@ -26,6 +28,7 @@ This will produce `state_dump` and `genesis_roots` files in home directory of th
use `--home` on all commands here to specify an absolute path to a home directory to use.

Then start a single local node:

```bash
cargo run --package neard --bin neard -- run --boot-nodes=
```
2 changes: 1 addition & 1 deletion genesis-tools/genesis-csv-to-json/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
.get_matches();

let home_dir = matches.get_one::<PathBuf>("home").unwrap();
let chain_id = matches.get_one::<String>("chain-id").expect("Chain id is requried");
let chain_id = matches.get_one::<String>("chain-id").expect("Chain id is required");
let tracked_shards: HashSet<ShardId> = match matches.get_one::<String>("tracked-shards") {
Some(s) => {
if s.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion genesis-tools/genesis-csv-to-json/src/serde_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod tests {
}

#[test]
fn test_deserialize_pubkeys_with_whitespace() {
fn test_deserialize_pub_keys_with_whitespace() {
let test_str = r#"{"keys": "ed25519:EsjyvmBb2ESGiyjPHMBUnTGCe1P6hPjmxxY2b2hrTBAv, ed25519:2djz3u3CjV4dpDZryudwA4JNDcGnVwNtphjZQbUzrhLE, ed25519:2f9Zv5kuyuPM5DCyEP5pSqg58NQ8Ct9uSRerZXnCS9fK,ed25519:3xCFas58RKvD5UpF9GqvEb6q9rvgfbEJPhLf85zc4HpC, ed25519:4588iQsoG9mWjDPLbipQvaGNqo9UCphGsgon8u2yXArE,ed25519:5Me9NjXh3br1Rp2zvqaTUo8qvXcDPZ3YxafewzUKW7zc,\ned25519:93A8upKEMoZG9bBFyXJjQhzcMJBvSHHtPjZP3173FARk"}"#;
serde_json::from_str::<Test>(test_str).unwrap();
}
Expand Down
1 change: 1 addition & 0 deletions genesis-tools/genesis-populate/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use nearcore::{get_default_home, load_config};
use std::path::PathBuf;

fn main() {
// cspell:ignore populator
let matches = Command::new("Genesis populator")
.arg(
Arg::new("home")
Expand Down
35 changes: 18 additions & 17 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Integration tests

## TestLoopEnv

`TestLoopEnv` is a framework that enables writing multi-node tests for NEAR protocol
`TestLoopEnv` is a framework that enables writing multi-node tests for NEAR protocol
components. It simulates an entire blockchain environment within a single test,
allowing for synchronous testing of complex scenarios.

We recommend to use `TestLoopEnv` for writing multi-node tests and put new
tests into `src/test_loop/tests` folder. This framework is an attempt to
achieve the best of all our previous frameworks, to make tests powerful,
deterministic and easy to write and understand. The doc how it works is on
We recommend to use `TestLoopEnv` for writing multi-node tests and put new
tests into `src/test_loop/tests` folder. This framework is an attempt to
achieve the best of all our previous frameworks, to make tests powerful,
deterministic and easy to write and understand. The doc how it works is on
`core/async/src/test_loop.rs`.

Here's a step-by-step guide on how to create a test.

## 1. Build the environment
Expand Down Expand Up @@ -113,22 +113,23 @@ TestLoopEnv { test_loop, datas: node_datas }

For historical context, there are multiple existing ways for writing such
tests. The following list presents these methods in order of their development:

* `run_actix(... setup_mock_all_validators(...))` - very powerful, spawns all
actors required for multi-node chain to operate and supports network
communication among them. However, very hard to understand, uses a lot of
actors required for multi-node chain to operate and supports network
communication among them. However, very hard to understand, uses a lot of
resources and almost not maintained.
* pytest - quite powerful as well, spawns actual nodes in Python and uses
exposed RPC handlers to test different behaviour. Quite obsolete as well,
* pytest - quite powerful as well, spawns actual nodes in Python and uses
exposed RPC handlers to test different behavior. Quite obsolete as well,
exposed to flakiness.
* different environments spawning clients: `TestEnv`, `TestReshardingEnv`, ...
Good middle ground for testing specific features, but doesn't test actual
network behaviour. Modifications like forcing skipping chunks require a lot
Good middle ground for testing specific features, but doesn't test actual
network behavior. Modifications like forcing skipping chunks require a lot
of manual intervention.

If test became problematic, it is encouraged to migrate it to `TestLoopEnv`.
However, it would be _extremely_ hard to migrate the logic precisely. Instead,
If test became problematic, it is encouraged to migrate it to `TestLoopEnv`.
However, it would be _extremely_ hard to migrate the logic precisely. Instead,
migrate tests only if they make sense to you and their current implementation
became a huge burden. We hope that reproducing such logic in `TestLoopEnv` is
much easier.
became a huge burden. We hope that reproducing such logic in `TestLoopEnv` is
much easier.

Enjoy!
2 changes: 1 addition & 1 deletion integration-tests/src/node/process_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl ProcessNode {
result
}

/// Clear storage directory and run keygen
/// Clear storage directory and run key gen
pub fn reset_storage(&self) {
Command::new("rm").arg("-r").arg(&self.work_dir).spawn().unwrap().wait().unwrap();
self.config.save_to_dir(&self.work_dir);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/test_loop/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ impl TestLoopBuilder {
.unwrap();

// If this is an archival node and split storage is initialized, then create view-specific
// versions of EpochManager, ShardTracker and RuntimeAdapter and use them to initiaze the
// versions of EpochManager, ShardTracker and RuntimeAdapter and use them to initialize the
// ViewClientActorInner. Otherwise, we use the regular versions created above.
let (view_epoch_manager, view_shard_tracker, view_runtime_adapter) =
if let Some(split_store) = &split_store {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn test_contract_distribution_call_after_clear_different_accounts() {

/// Executes a test that deploys and calls different contracts to the same account.
#[test]
fn test_contract_distribution_deply_and_call_multiple_contracts() {
fn test_contract_distribution_deploy_and_call_multiple_contracts() {
init_test_logger();
// We need 1 more non-validator account to create, deploy-contract, and delete.
let accounts = make_accounts(NUM_VALIDATORS + 1);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/test_loop/tests/epoch_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ fn slow_test_initial_epoch_sync_proof_sanity() {
let final_head_height = setup.chain_final_head_height(0);
sanity_check_epoch_sync_proof(&proof, final_head_height, &setup.genesis.config, 2);
// Requesting the proof should not have persisted the proof on disk. This is intentional;
// it is to reduce the statefulness of the system so that we may modify the way the proof
// it is to reduce the stateful-ness of the system so that we may modify the way the proof
// is presented in the future (for e.g. bug fixes) without a DB migration.
setup.assert_epoch_sync_proof_existence_on_disk(0, false);
}
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/src/test_loop/tests/state_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static TEST_CASES: &[StateSyncTest] = &[
extra_node_shard_schedule: None,
},
// In this test we have 2 validators and 4 shards, and we don't generate any extra accounts.
// That makes 3 accounts ncluding the "near" account. This means at least one shard will have no
// That makes 3 accounts including the "near" account. This means at least one shard will have no
// accounts in it, so we check that corner case here.
StateSyncTest {
num_validators: 2,
Expand Down Expand Up @@ -690,6 +690,7 @@ fn await_sync_hash(env: &mut TestLoopEnv) -> CryptoHash {
client.chain.get_sync_hash(&tip.last_block_hash).unwrap().unwrap()
}

// cspell:ignore reqs
fn spam_state_sync_header_reqs(env: &mut TestLoopEnv) {
let sync_hash = await_sync_hash(env);

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/test_loop/utils/loop_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) struct LoopAction {

impl LoopAction {
/// Returns a pair of pointers to the same flag, initially set to false.
/// To be used for a succees flag that is shared between `LoopAction` and its `LoopActionFn`.
/// To be used for a success flag that is shared between `LoopAction` and its `LoopActionFn`.
pub fn shared_success_flag() -> (Rc<Cell<bool>>, Rc<Cell<bool>>) {
let flag = Rc::new(Cell::new(false));
(flag.clone(), flag)
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/test_loop/utils/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub fn chunk_endorsement_dropper(
/// producers so that this will not come up.
/// - Using this when there are too few validators will lead to the chain stalling rather than the intended behavior
/// of a skip being generated.
/// - Only the producer of the skipped block will receive it, so we only ovserve the behavior when we see two different
/// - Only the producer of the skipped block will receive it, so we only observe the behavior when we see two different
/// descendants of the same block on one node. This could be improved, though.
pub fn block_dropper_by_height(
heights: HashSet<BlockHeight>,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/test_loop/utils/resharding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ fn check_deleted_account_availability(

/// Loop action testing a scenario where a temporary account is deleted after resharding.
/// After `gc_num_epochs_to_keep epochs` we assert that the account
/// is not accesible through RPC node but it is still accesible through archival node.
/// is not accessible through RPC node but it is still accessible through archival node.
///
/// The `temporary_account_id` must be a subaccount of the `originator_id`.
pub(crate) fn temporary_account_during_resharding(
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/tests/client/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use near_crypto::InMemorySigner;
use near_primitives::transaction::{Action, DeployContractAction, SignedTransaction};
use nearcore::test_utils::TestEnvNightshadeSetupExt;

/// cspell:ignore txes
/// How long does it take to produce a large chunk?
///
/// Chunk production work does **not** include any transaction execution: it is
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/tests/client/chunks_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl Test {
vs,
key_pairs,
true,
self.block_timeout.whole_milliseconds() as u64, // TODO: use Duration for callees
self.block_timeout.whole_milliseconds() as u64,
false,
false,
5,
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/tests/client/cold_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn create_tx_function_call(

/// Deploying test contract and calling write_random_value 5 times every block for 4 epochs.
/// Also doing 5 send transactions every block.
/// 4 epochs, because this test does not cover gc behaviour.
/// 4 epochs, because this test does not cover gc behavior.
/// After every block updating a separate database with data from client's storage.
/// After 4 epochs we check that everything, that exists in cold columns
/// of the storage of the client also exists in the database to which we were writing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl AdversarialBehaviorTestData {

fn process_all_actor_messages(&mut self) {
loop {
// cspell:ignore hpmv
// Force trigger any chunk request retries.
// NOTE(hpmv): Additionally dial time forward to trigger a full fetch. Why? Probably
// because during epoch transitions we don't exactly get this correct. But honestly,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn check_meta_tx_execution(
.get_access_key(&relayer, &PublicKey::from_seed(KeyType::ED25519, relayer.as_ref()))
.unwrap()
.nonce;
let user_pubk = match sender.get_account_type() {
let user_pub_key = match sender.get_account_type() {
AccountType::NearImplicitAccount => PublicKey::from_near_implicit_account(&sender).unwrap(),
AccountType::EthImplicitAccount => {
if checked_feature!("stable", EthImplicitAccounts, protocol_version) {
Expand All @@ -144,7 +144,7 @@ fn check_meta_tx_execution(
}
AccountType::NamedAccount => PublicKey::from_seed(KeyType::ED25519, sender.as_ref()),
};
let user_nonce_before = node_user.get_access_key(&sender, &user_pubk).unwrap().nonce;
let user_nonce_before = node_user.get_access_key(&sender, &user_pub_key).unwrap().nonce;

let tx_result =
node_user.meta_tx(sender.clone(), receiver.clone(), relayer.clone(), actions).unwrap();
Expand Down Expand Up @@ -692,7 +692,7 @@ fn ft_transfer_event(sender: &str, receiver: &str, amount: u128) -> String {
// the string comparison.
// (Note: parsing the logs as JSON and comparing serde_json::Value instead
// of string is not possible because the logs are only partially valid
// JOSN...)
// JSON...)
let data_json = format!(
r#"[{{"old_owner_id":"{sender}","new_owner_id":"{receiver}","amount":"{amount}"}}]"#
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct TransferConfig {
transfers: Transfers,
/// True if the receipt should create account.
account_creation: bool,
/// Differentaties between named and implicit account creation, if `account_creation` is true.
/// Differentiates between named and implicit account creation, if `account_creation` is true.
implicit_account_creation: bool,
/// Whether the last action in the receipt should deploy a contract.
deploy_contract: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fn test_create_top_level_accounts() {
"0a5e97870f263700f46aa00d967821199b9bc5a120",
"0x000000000000000000000000000000000000000",
"alice",
// cspell:disable-next-line
"thisisaveryverylongtoplevelaccount",
];
for (index, id) in top_level_accounts.iter().enumerate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn run_chunk_validation_test(
protocol_treasury_account: accounts[num_validators].clone(),
// Simply make all validators block producers.
num_block_producer_seats: num_validators as NumSeats,
// Each shard has 2 chunk prducers, so 4 shards, 8 chunk producers total.
// Each shard has 2 chunk producers, so 4 shards, 8 chunk producers total.
minimum_validators_per_shard: 2,
// Even though not used for the most recent protocol version,
// this must still have the same length as the number of shards,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ fn test_storage_proof_size_limit() {
assert_eq!(chunk.transactions().len(), 3);
assert_eq!(chunk.prev_outgoing_receipts().len(), 0);

// Chunk B - 3 FuntionCall receipts (converted from transactions)
// Chunk B - 3 FunctionCall receipts (converted from transactions)
let chunk = next_chunk();
assert_eq!(chunk.transactions().len(), 0);
assert_eq!(count_function_call_receipts(chunk.prev_outgoing_receipts()), 3);
assert_eq!(count_transfer_receipts(chunk.prev_outgoing_receipts()), 0);

// Chunk C - 2 transfer receipts from two executed FunctionCals, third FunctionCall moved to delayed receipt queue
// Chunk C - 2 transfer receipts from two executed FunctionCalls, third FunctionCall moved to delayed receipt queue
let chunk = next_chunk();
assert_eq!(chunk.transactions().len(), 0);
assert_eq!(count_function_call_receipts(chunk.prev_outgoing_receipts()), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ fn abi_encode(target: String, action: Action) -> Vec<u8> {
permission.method_names,
),
};
// cspell:ignore ethabi
let tokens = &[
ethabi::Token::Uint(public_key_kind.into()),
ethabi::Token::Bytes(public_key),
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/tests/client/flat_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn test_not_supported_block() {
}

// The first result should be FlatStorageError, because we can't read from first chunk view anymore.
// But the node must not panic as this is normal behaviour.
// But the node must not panic as this is normal behavior.
// Ideally it should be tested on chain level, but there is no easy way to
// postpone applying chunks reliably.
assert_matches!(get_ref_results[0], Err(StorageError::FlatStorageBlockNotSupported(_)));
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/tests/client/resharding_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl TestReshardingEnv {

// Don't do catchup in the very first block of the epoch. This is
// primarily for the error handling test where we want to corrupt the
// databse before catchup happens.
// database before catchup happens.
if next_height % epoch_length == 1 {
return false;
}
Expand All @@ -308,7 +308,7 @@ impl TestReshardingEnv {

// Submit the tx to all clients for processing and checks:
// Clients that track the relevant shard should return ValidTx
// Clients that do not track the relevenat shard should return RequestRouted
// Clients that do not track the relevant shard should return RequestRouted
// At least one client should process it and return ValidTx.
fn process_tx(env: &mut TestEnv, tx: &SignedTransaction) {
let mut response_valid_count = 0;
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/src/tests/client/state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ use near_store::{NodeStorage, Store};
use nearcore::test_utils::TestEnvNightshadeSetupExt;
use std::path::PathBuf;

struct StateSnaptshotTestEnv {
struct StateSnapshotTestEnv {
home_dir: PathBuf,
hot_store_path: PathBuf,
state_snapshot_subdir: PathBuf,
shard_tries: ShardTries,
}

impl StateSnaptshotTestEnv {
impl StateSnapshotTestEnv {
fn new(
home_dir: PathBuf,
hot_store_path: PathBuf,
Expand Down Expand Up @@ -62,12 +62,12 @@ impl StateSnaptshotTestEnv {
}
}

fn set_up_test_env_for_state_snapshots(store: &Store) -> StateSnaptshotTestEnv {
fn set_up_test_env_for_state_snapshots(store: &Store) -> StateSnapshotTestEnv {
let home_dir =
tempfile::Builder::new().prefix("storage").tempdir().unwrap().path().to_path_buf();
let hot_store_path = PathBuf::from("data");
let state_snapshot_subdir = PathBuf::from("state_snapshot");
StateSnaptshotTestEnv::new(home_dir, hot_store_path, state_snapshot_subdir, store)
StateSnapshotTestEnv::new(home_dir, hot_store_path, state_snapshot_subdir, store)
}

#[test]
Expand Down Expand Up @@ -129,7 +129,7 @@ fn test_maybe_open_state_snapshot_garbage_snapshot() {
}

fn verify_make_snapshot(
state_snapshot_test_env: &StateSnaptshotTestEnv,
state_snapshot_test_env: &StateSnapshotTestEnv,
block_hash: CryptoHash,
block: &Block,
) -> Result<(), anyhow::Error> {
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/src/tests/client/sync_state_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ fn slow_test_state_sync_headers() {
Ok(Ok(b)) => Some(b.header.epoch_id),
_ => None,
};
// async is hard, will use this construct to reduce nestedness.
// async is hard, will use this construct to reduce nested code.
let epoch_id = match epoch_id {
Some(x) => x,
None => return ControlFlow::Continue(()),
Expand Down Expand Up @@ -884,7 +884,7 @@ fn slow_test_state_sync_headers_no_tracked_shards() {
Ok(Ok(b)) => Some(b.header.epoch_id),
_ => None,
};
// async is hard, will use this construct to reduce nestedness.
// async is hard, will use this construct to reduce nested code.
let epoch_id = match epoch_id {
Some(x) => x,
None => return ControlFlow::Continue(()),
Expand Down
Loading

0 comments on commit 77f19f7

Please sign in to comment.