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: format noir stuff #9202

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/authwit/src/auth_witness.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ unconstrained fn get_auth_witness_oracle<let N: u32>(_message_hash: Field) -> [F

/**
* Oracle wrapper to fetch an `auth_witness` for a given `message_hash` from the PXE.
*
*
* @param message_hash The hash of the message for which the `auth_witness` is to be fetched.
* @return The `auth_witness` for the given `message_hash` as Field array.
*/
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/keys/getters/test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ unconstrained fn setup() -> TestAccount {
account
}

#[test(should_fail_with="Invalid public keys hint for address")]
#[test(should_fail_with = "Invalid public keys hint for address")]
unconstrained fn test_get_public_keys_unknown() {
let account = setup();

Expand Down
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/aztec/src/note/note_getter/test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ unconstrained fn can_return_zero_notes() {
assert_eq(returned.len(), 0);
}

#[test(should_fail_with="Got more notes than limit.")]
#[test(should_fail_with = "Got more notes than limit.")]
unconstrained fn rejects_mote_notes_than_limit() {
let mut env = setup();
let mut context = env.private();
Expand Down Expand Up @@ -155,7 +155,7 @@ unconstrained fn applies_filter_before_constraining() {
assert_eq(context.note_hash_read_requests.len(), 1);
}

#[test(should_fail_with="Mismatch note header contract address.")]
#[test(should_fail_with = "Mismatch note header contract address.")]
unconstrained fn rejects_mismatched_address() {
let mut env = setup();
let mut context = env.private();
Expand All @@ -169,7 +169,7 @@ unconstrained fn rejects_mismatched_address() {
let _ = constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options);
}

#[test(should_fail_with="Mismatch note header storage slot.")]
#[test(should_fail_with = "Mismatch note header storage slot.")]
unconstrained fn rejects_mismatched_storage_slot() {
let mut env = setup();
let mut context = env.private();
Expand All @@ -183,7 +183,7 @@ unconstrained fn rejects_mismatched_storage_slot() {
let _ = constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options);
}

#[test(should_fail_with="Mismatch return note field.")]
#[test(should_fail_with = "Mismatch return note field.")]
unconstrained fn rejects_mismatched_selector() {
let mut env = setup();
let mut context = env.private();
Expand All @@ -204,7 +204,7 @@ unconstrained fn rejects_mismatched_selector() {
let _ = constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options);
}

#[test(should_fail_with="Return notes not sorted in descending order.")]
#[test(should_fail_with = "Return notes not sorted in descending order.")]
unconstrained fn rejects_mismatched_desc_sort_order() {
let mut env = setup();
let mut context = env.private();
Expand All @@ -222,7 +222,7 @@ unconstrained fn rejects_mismatched_desc_sort_order() {
let _ = constrain_get_notes_internal(&mut context, storage_slot, opt_notes, options);
}

#[test(should_fail_with="Return notes not sorted in ascending order.")]
#[test(should_fail_with = "Return notes not sorted in ascending order.")]
unconstrained fn rejects_mismatched_asc_sort_order() {
let mut env = setup();
let mut context = env.private();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_initialize_uninitialized() {
assert(state_var.read() == value);
}

#[test(should_fail_with="PublicImmutable already initialized")]
#[test(should_fail_with = "PublicImmutable already initialized")]
fn test_initialize_already_initialized() {
let env = setup();
let state_var = in_public(env);
Expand All @@ -44,7 +44,7 @@ fn test_initialize_already_initialized() {
state_var.initialize(value);
}

#[test(should_fail_with="PublicImmutable not initialized")]
#[test(should_fail_with = "PublicImmutable not initialized")]
fn test_read_uninitialized() {
let env = setup();
let state_var = in_public(env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ unconstrained fn test_get_current_value_in_private_with_non_initial_delay() {
assert_eq(private_state_var.context.max_block_number.unwrap(), historical_block_number + new_delay);
}

#[test(should_fail_with="Hint values do not match hash")]
#[test(should_fail_with = "Hint values do not match hash")]
unconstrained fn test_get_current_value_in_private_bad_value_hints() {
let mut env = setup();

Expand All @@ -287,7 +287,7 @@ unconstrained fn test_get_current_value_in_private_bad_value_hints() {
let _ = private_state_var.get_current_value_in_private();
}

#[test(should_fail_with="Hint values do not match hash")]
#[test(should_fail_with = "Hint values do not match hash")]
unconstrained fn test_get_current_value_in_private_bad_delay_hints() {
let mut env = setup();

Expand All @@ -307,7 +307,7 @@ unconstrained fn test_get_current_value_in_private_bad_delay_hints() {
let _ = private_state_var.get_current_value_in_private();
}

#[test(should_fail_with="Non-zero value change for zero hash")]
#[test(should_fail_with = "Non-zero value change for zero hash")]
unconstrained fn test_get_current_value_in_private_bad_zero_hash_value_hints() {
let mut env = setup();

Expand All @@ -324,7 +324,7 @@ unconstrained fn test_get_current_value_in_private_bad_zero_hash_value_hints() {
let _ = state_var.get_current_value_in_private();
}

#[test(should_fail_with="Non-zero delay change for zero hash")]
#[test(should_fail_with = "Non-zero delay change for zero hash")]
unconstrained fn test_get_current_value_in_private_bad_zero_hash_delay_hints() {
let mut env = setup();

Expand Down
12 changes: 6 additions & 6 deletions noir-projects/aztec-nr/aztec/src/utils/test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ unconstrained fn verify_collapse_hints_good_hints() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Wrong collapsed vec length")]
#[test(should_fail_with = "Wrong collapsed vec length")]
unconstrained fn verify_collapse_hints_wrong_length() {
let original = [Option::some(7), Option::none(), Option::some(3)];
let collapsed = BoundedVec::from_array([7]);
Expand All @@ -66,7 +66,7 @@ unconstrained fn verify_collapse_hints_wrong_length() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Collapse hint vec length mismatch")]
#[test(should_fail_with = "Collapse hint vec length mismatch")]
unconstrained fn verify_collapse_hints_hint_length_mismatch() {
let original = [Option::some(7), Option::none(), Option::some(3)];
let collapsed = BoundedVec::from_array([7, 3]);
Expand All @@ -75,7 +75,7 @@ unconstrained fn verify_collapse_hints_hint_length_mismatch() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Out of bounds index hint")]
#[test(should_fail_with = "Out of bounds index hint")]
unconstrained fn verify_collapse_hints_out_of_bounds_index_hint() {
let original = [Option::some(7), Option::none(), Option::some(3)];
let collapsed = BoundedVec::from_array([7, 3]);
Expand All @@ -93,7 +93,7 @@ unconstrained fn verify_collapse_hints_hint_to_none() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Wrong collapsed vec content")]
#[test(should_fail_with = "Wrong collapsed vec content")]
unconstrained fn verify_collapse_hints_wrong_vec_content() {
let original = [Option::some(7), Option::none(), Option::some(3)];
let collapsed = BoundedVec::from_array([7, 42]);
Expand All @@ -102,7 +102,7 @@ unconstrained fn verify_collapse_hints_wrong_vec_content() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Wrong collapsed vec order")]
#[test(should_fail_with = "Wrong collapsed vec order")]
unconstrained fn verify_collapse_hints_wrong_vec_order() {
let original = [Option::some(7), Option::none(), Option::some(3)];
let collapsed = BoundedVec::from_array([3, 7]);
Expand All @@ -111,7 +111,7 @@ unconstrained fn verify_collapse_hints_wrong_vec_order() {
verify_collapse_hints(original, collapsed, collapsed_to_input_index_mapping);
}

#[test(should_fail_with="Dirty collapsed vec storage")]
#[test(should_fail_with = "Dirty collapsed vec storage")]
unconstrained fn verify_collapse_hints_dirty_storage() {
let original = [Option::some(7), Option::none(), Option::some(3)];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ contract EasyPrivateVoting {

// docs:start:constructor
#[public]
#[initializer] // annotation to mark function as a constructor
#[initializer]
// annotation to mark function as a constructor
fn constructor(admin: AztecAddress) {
storage.admin.write(admin);
storage.vote_ended.write(false);
Expand All @@ -30,7 +31,8 @@ contract EasyPrivateVoting {
// docs:end:constructor

// docs:start:cast_vote
#[private] // annotation to mark function as private and expose private context
#[private]
// annotation to mark function as private and expose private context
fn cast_vote(candidate: Field) {
let msg_sender_npk_m_hash = get_public_keys(context.msg_sender()).npk_m.hash();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ unconstrained fn transfer_in_private_on_behalf_of_other() {
utils::assert_owns_private_nft(nft_contract_address, recipient, token_id);
}

#[test(should_fail_with="NFT not found when transferring")]
#[test(should_fail_with = "NFT not found when transferring")]
unconstrained fn transfer_in_private_failure_not_an_owner() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, owner, not_owner, token_id) = utils::setup_mint_and_transfer_to_private(/* with_account_contracts */ false);
Expand All @@ -68,7 +68,7 @@ unconstrained fn transfer_in_private_failure_not_an_owner() {
env.call_private_void(NFT::at(nft_contract_address).transfer_in_private(not_owner, owner, token_id, 0));
}

#[test(should_fail_with="invalid nonce")]
#[test(should_fail_with = "invalid nonce")]
unconstrained fn transfer_in_private_failure_on_behalf_of_self_non_zero_nonce() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough.
// The nonce check is in the beginning so we don't need to waste time on minting the NFT and transferring
Expand All @@ -82,7 +82,7 @@ unconstrained fn transfer_in_private_failure_on_behalf_of_self_non_zero_nonce()
env.call_private_void(NFT::at(nft_contract_address).transfer_in_private(sender, recipient, token_id, 1));
}

#[test(should_fail_with="Authorization not found for message hash")]
#[test(should_fail_with = "Authorization not found for message hash")]
unconstrained fn transfer_in_private_failure_on_behalf_of_other_without_approval() {
// Setup with account contracts. Slower since we actually deploy them, but needed for authwits.
// The authwit check is in the beginning so we don't need to waste time on minting the NFT and transferring
Expand All @@ -98,7 +98,7 @@ unconstrained fn transfer_in_private_failure_on_behalf_of_other_without_approval
env.call_private_void(NFT::at(nft_contract_address).transfer_in_private(sender, recipient, token_id, 1));
}

#[test(should_fail_with="Authorization not found for message hash")]
#[test(should_fail_with = "Authorization not found for message hash")]
unconstrained fn transfer_in_private_failure_on_behalf_of_other_wrong_caller() {
// Setup with account contracts. Slower since we actually deploy them, but needed for authwits.
// The authwit check is in the beginning so we don't need to waste time on minting the NFT and transferring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ unconstrained fn transfer_in_public_on_behalf_of_other() {
utils::assert_owns_public_nft(env, nft_contract_address, recipient, token_id);
}

#[test(should_fail_with="invalid nonce")]
#[test(should_fail_with = "invalid nonce")]
unconstrained fn transfer_in_public_failure_on_behalf_of_self_non_zero_nonce() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough.
// The authwit check is in the beginning so we don't need to waste time on minting the NFT and transferring
Expand All @@ -56,7 +56,7 @@ unconstrained fn transfer_in_public_failure_on_behalf_of_self_non_zero_nonce() {
env.call_public(NFT::at(nft_contract_address).transfer_in_public(sender, recipient, token_id, random()));
}

#[test(should_fail_with="invalid owner")]
#[test(should_fail_with = "invalid owner")]
unconstrained fn transfer_in_public_non_existent_nft() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, sender, recipient) = utils::setup(/* with_account_contracts */ false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ unconstrained fn transfer_to_private_to_a_different_account() {
utils::assert_owns_public_nft(env, nft_contract_address, AztecAddress::zero(), token_id);
}

#[test(should_fail_with="transfer not prepared")]
#[test(should_fail_with = "transfer not prepared")]
unconstrained fn transfer_to_private_to_self_transfer_not_prepared() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, _, _, token_id) = utils::setup_and_mint(/* with_account_contracts */ false);
Expand All @@ -78,7 +78,7 @@ unconstrained fn transfer_to_private_to_self_transfer_not_prepared() {
);
}

#[test(should_fail_with="transfer not prepared")]
#[test(should_fail_with = "transfer not prepared")]
unconstrained fn transfer_to_private_finalizing_from_incorrect_sender() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, incorrect_sender, recipient, token_id) = utils::setup_and_mint(/* with_account_contracts */ false);
Expand Down Expand Up @@ -106,7 +106,7 @@ unconstrained fn transfer_to_private_finalizing_from_incorrect_sender() {
);
}

#[test(should_fail_with="invalid NFT owner")]
#[test(should_fail_with = "invalid NFT owner")]
unconstrained fn transfer_to_private_failure_not_an_owner() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, _, not_owner, token_id) = utils::setup_and_mint(/* with_account_contracts */ false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ unconstrained fn transfer_to_public_on_behalf_of_other() {
utils::assert_owns_public_nft(env, nft_contract_address, recipient, token_id);
}

#[test(should_fail_with="NFT not found when transferring to public")]
#[test(should_fail_with = "NFT not found when transferring to public")]
unconstrained fn transfer_to_public_failure_not_an_owner() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, _, not_owner, token_id) = utils::setup_mint_and_transfer_to_private(/* with_account_contracts */ false);
Expand All @@ -49,15 +49,15 @@ unconstrained fn transfer_to_public_failure_not_an_owner() {
env.call_private_void(NFT::at(nft_contract_address).transfer_to_public(not_owner, not_owner, token_id, 0));
}

#[test(should_fail_with="invalid nonce")]
#[test(should_fail_with = "invalid nonce")]
unconstrained fn transfer_to_public_failure_on_behalf_of_self_non_zero_nonce() {
// Setup without account contracts. We are not using authwits here, so dummy accounts are enough
let (env, nft_contract_address, user, _, token_id) = utils::setup_mint_and_transfer_to_private(/* with_account_contracts */ false);

env.call_private_void(NFT::at(nft_contract_address).transfer_to_public(user, user, token_id, random()));
}

#[test(should_fail_with="Authorization not found for message hash")]
#[test(should_fail_with = "Authorization not found for message hash")]
unconstrained fn transfer_to_public_failure_on_behalf_of_other_invalid_designated_caller() {
let (env, nft_contract_address, sender, recipient, token_id) = utils::setup_mint_and_transfer_to_private(/* with_account_contracts */ true);

Expand All @@ -69,7 +69,7 @@ unconstrained fn transfer_to_public_failure_on_behalf_of_other_invalid_designate
env.call_private_void(transfer_to_public_call_interface);
}

#[test(should_fail_with="Authorization not found for message hash")]
#[test(should_fail_with = "Authorization not found for message hash")]
unconstrained fn transfer_to_public_failure_on_behalf_of_other_no_approval() {
let (env, nft_contract_address, sender, recipient, token_id) = utils::setup_mint_and_transfer_to_private(/* with_account_contracts */ true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ contract TokenBlacklist {
}

/// Internal ///

#[public]
#[internal]
fn _increase_public_balance(to: AztecAddress, amount: Field) {
Expand All @@ -266,7 +265,6 @@ contract TokenBlacklist {
}

/// Unconstrained ///

unconstrained fn balance_of_private(owner: AztecAddress) -> pub Field {
storage.balances.balance_of(owner).to_field()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ contract TokenBridge {
Token::at(token).burn(context.msg_sender(), amount, nonce).call(&mut context);
}
/// docs:end:exit_to_l1_private

// docs:start:get_token
#[public]
#[view]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ unconstrained fn burn_private_on_behalf_of_other() {
utils::check_private_balance(token_contract_address, owner, mint_amount - burn_amount);
}

#[test(should_fail_with="Balance too low")]
#[test(should_fail_with = "Balance too low")]
unconstrained fn burn_private_failure_more_than_balance() {
let (env, token_contract_address, owner, _, mint_amount) = utils::setup_and_mint(/* with_account_contracts */ false);

Expand All @@ -123,7 +123,7 @@ unconstrained fn burn_private_failure_more_than_balance() {
// Private doesnt revert, so we cannot check balances here since notes have already been nullified. Test is done.
}

#[test(should_fail_with="invalid nonce")]
#[test(should_fail_with = "invalid nonce")]
unconstrained fn burn_private_failure_on_behalf_of_self_non_zero_nonce() {
let (env, token_contract_address, owner, _, mint_amount) = utils::setup_and_mint(/* with_account_contracts */ false);

Expand Down
Loading
Loading