Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core, sequencer): add names to all snapshot tests #1690

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/astria-core/src/primitive/v1/asset/denom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,10 @@ mod serde_impl {
}
#[test]
fn snapshots() {
insta::assert_json_snapshot!(ibc_prefixed());
insta::assert_json_snapshot!(trace_prefixed());
insta::assert_json_snapshot!(Denom::from(ibc_prefixed()));
insta::assert_json_snapshot!(Denom::from(trace_prefixed()));
insta::assert_json_snapshot!("ibc_prefixed", ibc_prefixed());
insta::assert_json_snapshot!("trace_prefixed", trace_prefixed());
insta::assert_json_snapshot!("ibc_prefixed_denom", Denom::from(ibc_prefixed()));
insta::assert_json_snapshot!("trace_prefixed_denom", Denom::from(trace_prefixed()));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-core/src/primitive/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,15 +845,15 @@ mod tests {
.prefix(ASTRIA_ADDRESS_PREFIX)
.try_build()
.unwrap();
insta::assert_json_snapshot!(&main_address.to_raw());
insta::assert_json_snapshot!("main_address", &main_address.to_raw());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's never name this main_bech32m_address

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you meant to name it main_bech32m_address?


let compat_address = main_address
.to_prefix(ASTRIA_COMPAT_ADDRESS_PREFIX)
.unwrap()
.to_format::<Bech32>();
// We don't allow serializing non bech32m addresses due to
// its impl via the protobuf type.
insta::assert_snapshot!(&compat_address);
insta::assert_snapshot!("compat_address", &compat_address);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/astria-core/src/primitive/v1/mod.rs
expression: "&bech32_address"
expression: "&compat_address"
ethanoroshiba marked this conversation as resolved.
Show resolved Hide resolved
---
astriacompat19g4z52329g4z52329g4z52329g4z52322jspvr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/astria-core/src/primitive/v1/mod.rs
expression: address
expression: "&main_address.to_raw()"
---
{
"bech32m": "astria19g4z52329g4z52329g4z52329g4z5232ayenag"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: crates/astria-core/src/protocol/genesis/v1alpha1.rs
source: crates/astria-core/src/protocol/genesis/v1.rs
expression: genesis_state()
---
{
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-core/src/protocol/genesis/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,6 @@ mod tests {
#[cfg(feature = "serde")]
#[test]
fn genesis_state_is_unchanged() {
insta::assert_json_snapshot!(genesis_state());
insta::assert_json_snapshot!("genesis_state", genesis_state());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-core/src/protocol/memos/v1alpha1.rs
assertion_line: 28
source: crates/astria-core/src/protocol/memos/v1.rs
expression: memo
---
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-core/src/protocol/memos/v1alpha1.rs
assertion_line: 19
source: crates/astria-core/src/protocol/memos/v1.rs
expression: memo
---
{
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-core/src/protocol/memos/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod tests {
memo: "hello".to_string(),
};

insta::assert_json_snapshot!(memo);
insta::assert_json_snapshot!("ics20_withdrawal_from_rollup_memo", memo);
}

#[test]
Expand All @@ -25,6 +25,6 @@ mod tests {
rollup_deposit_address: "an-address-on-the-rollup".to_string(),
};

insta::assert_json_snapshot!(memo);
insta::assert_json_snapshot!("ics20_transfer_deposit_memo", memo);
}
}
2 changes: 1 addition & 1 deletion crates/astria-core/src/protocol/transaction/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ mod tests {
body_bytes: body.to_raw().encode_to_vec().into(),
};

insta::assert_json_snapshot!(tx.id().to_raw());
insta::assert_json_snapshot!("transaction_id", tx.id().to_raw());
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-sequencer/src/accounts/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(balance(&address(), &asset()));
insta::assert_snapshot!(nonce(&address()));
insta::assert_snapshot!("balance_key", balance(&address(), &asset()));
insta::assert_snapshot!("nonce_key", nonce(&address()));
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/astria-sequencer/src/address/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(BASE_PREFIX);
insta::assert_snapshot!(IBC_COMPAT_PREFIX);
insta::assert_snapshot!("base_prefix", BASE_PREFIX);
insta::assert_snapshot!("ibc_compat_prefix", IBC_COMPAT_PREFIX);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/address/storage/keys.rs
assertion_line: 10
expression: BASE_PREFIX_KEY
expression: BASE_PREFIX
---
address/prefixes/base
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/address/storage/keys.rs
assertion_line: 11
expression: IBC_COMPAT_PREFIX_KEY
expression: IBC_COMPAT_PREFIX
---
address/prefixes/ibc_compat
10 changes: 5 additions & 5 deletions crates/astria-sequencer/src/app/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(CHAIN_ID);
insta::assert_snapshot!(REVISION_NUMBER);
insta::assert_snapshot!(BLOCK_HEIGHT);
insta::assert_snapshot!(BLOCK_TIMESTAMP);
insta::assert_snapshot!(storage_version_by_height(42));
insta::assert_snapshot!("chain_id_key", CHAIN_ID);
insta::assert_snapshot!("revision_number_key", REVISION_NUMBER);
insta::assert_snapshot!("block_height_key", BLOCK_HEIGHT);
insta::assert_snapshot!("block_timestamp_key", BLOCK_TIMESTAMP);
insta::assert_snapshot!("storage_version_key", storage_version_by_height(42));
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/app/storage/keys.rs
assertion_line: 22
expression: BLOCK_HEIGHT_KEY
expression: BLOCK_HEIGHT
---
app/block_height
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/app/storage/keys.rs
assertion_line: 23
expression: BLOCK_TIMESTAMP_KEY
expression: BLOCK_TIMESTAMP
---
app/block_timestamp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/app/storage/keys.rs
assertion_line: 18
expression: CHAIN_ID_KEY
expression: CHAIN_ID
---
app/chain_id
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/app/storage/keys.rs
assertion_line: 21
expression: REVISION_NUMBER_KEY
expression: REVISION_NUMBER
---
app/revision_number
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/app/storage/keys.rs
assertion_line: 22
expression: storage_version_by_height(42)
---
app/storage_version/42
6 changes: 3 additions & 3 deletions crates/astria-sequencer/src/app/tests_breaking_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ use crate::{
#[tokio::test]
async fn app_genesis_snapshot() {
let app = initialize_app(None, vec![]).await;
insta::assert_json_snapshot!(app.app_hash.as_bytes());
insta::assert_json_snapshot!("app_hash_at_genesis", app.app_hash.as_bytes());
}

#[tokio::test]
Expand Down Expand Up @@ -154,7 +154,7 @@ async fn app_finalize_block_snapshot() {
.await
.unwrap();
app.commit(storage.clone()).await;
insta::assert_json_snapshot!(app.app_hash.as_bytes());
insta::assert_json_snapshot!("app_hash_finalize_block", app.app_hash.as_bytes());
}

// Note: this tests every action except for `Ics20Withdrawal` and `IbcRelay`.
Expand Down Expand Up @@ -347,5 +347,5 @@ async fn app_execute_transaction_with_every_action_snapshot() {
app.prepare_commit(storage.clone()).await.unwrap();
app.commit(storage.clone()).await;

insta::assert_json_snapshot!(app.app_hash.as_bytes());
insta::assert_json_snapshot!("app_hash_execute_every_action", app.app_hash.as_bytes());
}
4 changes: 2 additions & 2 deletions crates/astria-sequencer/src/assets/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(NATIVE_ASSET);
insta::assert_snapshot!(asset(&test_asset()));
insta::assert_snapshot!("native_asset_key", NATIVE_ASSET);
insta::assert_snapshot!("asset_key_test_asset", asset(&test_asset()));
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/assets/storage/keys.rs
assertion_line: 87
expression: asset(&test_asset())
---
assets/ibc/be429a02d00837245167a2616674a979a2ac6f9806468b48a975b156ad711320
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/assets/storage/keys.rs
assertion_line: 84
expression: NATIVE_ASSET_KEY
expression: NATIVE_ASSET
---
assets/native_asset
6 changes: 3 additions & 3 deletions crates/astria-sequencer/src/authority/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(SUDO);
insta::assert_snapshot!(VALIDATOR_SET);
insta::assert_snapshot!(VALIDATOR_UPDATES);
insta::assert_snapshot!("sudo_address_key", SUDO);
insta::assert_snapshot!("validator_set_key", VALIDATOR_SET);
insta::assert_snapshot!("validator_updates_key", VALIDATOR_UPDATES);
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/authority/storage/keys.rs
assertion_line: 15
expression: SUDO_STORAGE_KEY
expression: SUDO
---
authority/sudo
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/authority/storage/keys.rs
assertion_line: 16
expression: VALIDATOR_SET_STORAGE_KEY
expression: VALIDATOR_SET
---
authority/validator_set
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/authority/storage/keys.rs
assertion_line: 15
expression: VALIDATOR_UPDATES
---
authority/validator_updates
28 changes: 20 additions & 8 deletions crates/astria-sequencer/src/bridge/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,26 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(DEPOSITS_EPHEMERAL);
insta::assert_snapshot!(rollup_id(&address()));
insta::assert_snapshot!(asset_id(&address()));
insta::assert_snapshot!(bridge_account_sudo_address(&address()));
insta::assert_snapshot!(bridge_account_withdrawer_address(&address()));
insta::assert_snapshot!(bridge_account_withdrawal_event(&address(), "the-event"));
insta::assert_snapshot!(deposit(&[1; 32], &RollupId::new([2; 32])));
insta::assert_snapshot!(last_transaction_id_for_bridge_account(&address()));
insta::assert_snapshot!("ephemeral_deposits_key", DEPOSITS_EPHEMERAL);
insta::assert_snapshot!("rollup_id_key", rollup_id(&address()));
insta::assert_snapshot!("asset_id_key", asset_id(&address()));
insta::assert_snapshot!(
"bridge_sudo_address_key",
bridge_account_sudo_address(&address())
);
insta::assert_snapshot!(
"bridge_withdrawer_address_key",
bridge_account_withdrawer_address(&address())
);
insta::assert_snapshot!(
"bridge_withdrawal_event_key",
bridge_account_withdrawal_event(&address(), "the-event")
);
insta::assert_snapshot!("deposit_key", deposit(&[1; 32], &RollupId::new([2; 32])));
insta::assert_snapshot!(
"last_tx_id_for_bridge_acct_key",
last_transaction_id_for_bridge_account(&address())
);
}

#[test]
Expand Down
21 changes: 15 additions & 6 deletions crates/astria-sequencer/src/grpc/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,21 @@ mod tests {

#[test]
fn keys_should_not_change() {
insta::assert_snapshot!(block_hash_by_height(42));
insta::assert_snapshot!(sequencer_block_header_by_hash(&HASH));
insta::assert_snapshot!(rollup_data_by_hash_and_rollup_id(&HASH, &ROLLUP_ID));
insta::assert_snapshot!(rollup_ids_by_hash(&HASH));
insta::assert_snapshot!(rollup_transactions_proof_by_hash(&HASH));
insta::assert_snapshot!(rollup_ids_proof_by_hash(&HASH));
insta::assert_snapshot!("block_hash_by_height_key", block_hash_by_height(42));
insta::assert_snapshot!(
"sequencer_block_header_by_hash_key",
sequencer_block_header_by_hash(&HASH)
);
insta::assert_snapshot!(
"rollup_data_by_has_and_id_key",
rollup_data_by_hash_and_rollup_id(&HASH, &ROLLUP_ID)
);
insta::assert_snapshot!("rollup_ids_by_hash_key", rollup_ids_by_hash(&HASH));
insta::assert_snapshot!(
"rollup_transactions_proof_by_hash_key",
rollup_transactions_proof_by_hash(&HASH)
);
insta::assert_snapshot!("rollup_ids_proof_by_hash", rollup_ids_proof_by_hash(&HASH));
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/grpc/storage/keys.rs
assertion_line: 44
expression: block_hash_by_height(42)
---
grpc/block_hash/42
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/grpc/storage/keys.rs
assertion_line: 46
expression: "rollup_data_by_hash_and_rollup_id(&HASH, &ROLLUP_ID)"
---
grpc/rollup_data/AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=/AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI=
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/grpc/storage/keys.rs
assertion_line: 49
expression: rollup_ids_by_hash(&HASH)
---
grpc/rollup_ids/AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/grpc/storage/keys.rs
assertion_line: 51
expression: rollup_ids_proof_by_hash(&HASH)
---
grpc/rollup_ids_proof/AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/grpc/storage/keys.rs
assertion_line: 50
expression: rollup_transactions_proof_by_hash(&HASH)
---
grpc/rollup_txs_proof/AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/astria-sequencer/src/grpc/storage/keys.rs
assertion_line: 45
expression: sequencer_block_header_by_hash(&HASH)
---
grpc/block_header/AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=
Loading
Loading