Skip to content

Commit

Permalink
no camel case in test contract
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 30, 2023
1 parent 603d33a commit b7bb7b9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ use dep::aztec::constants_gen::RETURN_VALUES_LENGTH;

struct AStructTestCodeGenStruct {
amount: Field,
secretHash: Field,
secret_hash: Field,
}

struct ADeepStructTestCodeGenStruct {
aField: Field,
aBool: bool,
aNote: ANoteADeepStructTestCodeGenStruct,
manyNotes: [ManyNotesADeepStructTestCodeGenStruct;3],
a_field: Field,
a_bool: bool,
a_note: ANoteADeepStructTestCodeGenStruct,
many_notes: [ManyNotesADeepStructTestCodeGenStruct;3],
}

struct ANoteADeepStructTestCodeGenStruct {
amount: Field,
secretHash: Field,
secret_hash: Field,
}

struct ManyNotesADeepStructTestCodeGenStruct {
amount: Field,
secretHash: Field,
secret_hash: Field,
}


Expand Down Expand Up @@ -83,11 +83,11 @@ impl TestPrivateContextInterface {
self,
context: &mut PrivateContext,
amount: Field,
secretHash: Field
secret_hash: Field
) {
let mut serialized_args = [0; 2];
serialized_args[0] = amount;
serialized_args[1] = secretHash;
serialized_args[1] = secret_hash;

context.call_public_function(self.address, 0x9749ca06, serialized_args)
}
Expand All @@ -97,11 +97,11 @@ impl TestPrivateContextInterface {
self,
context: &mut PrivateContext,
amount: Field,
secretHash: Field
secret_hash: Field
) {
let mut serialized_args = [0; 2];
serialized_args[0] = amount;
serialized_args[1] = secretHash;
serialized_args[1] = secret_hash;

context.call_public_function(self.address, 0xdf02db8d, serialized_args)
}
Expand Down Expand Up @@ -200,31 +200,31 @@ impl TestPrivateContextInterface {
pub fn test_code_gen(
self,
context: &mut PrivateContext,
aField: Field,
aBool: bool,
aNumber: u32,
anArray: [Field;2],
aStruct: AStructTestCodeGenStruct,
aDeepStruct: ADeepStructTestCodeGenStruct
a_field: Field,
a_bool: bool,
a_number: u32,
an_array: [Field;2],
a_struct: AStructTestCodeGenStruct,
a_deep_struct: ADeepStructTestCodeGenStruct
) -> [Field; RETURN_VALUES_LENGTH] {
let mut serialized_args = [0; 17];
serialized_args[0] = aField;
serialized_args[1] = aBool as Field;
serialized_args[2] = aNumber as Field;
serialized_args[3] = anArray[0];
serialized_args[4] = anArray[1];
serialized_args[5] = aStruct.amount;
serialized_args[6] = aStruct.secretHash;
serialized_args[7] = aDeepStruct.aField;
serialized_args[8] = aDeepStruct.aBool as Field;
serialized_args[9] = aDeepStruct.aNote.amount;
serialized_args[10] = aDeepStruct.aNote.secretHash;
serialized_args[11] = aDeepStruct.manyNotes[0].amount;
serialized_args[12] = aDeepStruct.manyNotes[0].secretHash;
serialized_args[13] = aDeepStruct.manyNotes[1].amount;
serialized_args[14] = aDeepStruct.manyNotes[1].secretHash;
serialized_args[15] = aDeepStruct.manyNotes[2].amount;
serialized_args[16] = aDeepStruct.manyNotes[2].secretHash;
serialized_args[0] = a_field;
serialized_args[1] = a_bool as Field;
serialized_args[2] = a_number as Field;
serialized_args[3] = an_array[0];
serialized_args[4] = an_array[1];
serialized_args[5] = a_struct.amount;
serialized_args[6] = a_struct.secret_hash;
serialized_args[7] = a_deep_struct.a_field;
serialized_args[8] = a_deep_struct.a_bool as Field;
serialized_args[9] = a_deep_struct.a_note.amount;
serialized_args[10] = a_deep_struct.a_note.secret_hash;
serialized_args[11] = a_deep_struct.many_notes[0].amount;
serialized_args[12] = a_deep_struct.many_notes[0].secret_hash;
serialized_args[13] = a_deep_struct.many_notes[1].amount;
serialized_args[14] = a_deep_struct.many_notes[1].secret_hash;
serialized_args[15] = a_deep_struct.many_notes[2].amount;
serialized_args[16] = a_deep_struct.many_notes[2].secret_hash;

context.call_private_function(self.address, 0x0f054f9b, serialized_args)
}
Expand Down Expand Up @@ -270,11 +270,11 @@ impl TestPublicContextInterface {
self,
context: PublicContext,
amount: Field,
secretHash: Field
secret_hash: Field
) -> [Field; RETURN_VALUES_LENGTH] {
let mut serialized_args = [0; 2];
serialized_args[0] = amount;
serialized_args[1] = secretHash;
serialized_args[1] = secret_hash;

context.call_public_function(self.address, 0x9749ca06, serialized_args)
}
Expand All @@ -284,11 +284,11 @@ impl TestPublicContextInterface {
self,
context: PublicContext,
amount: Field,
secretHash: Field
secret_hash: Field
) -> [Field; RETURN_VALUES_LENGTH] {
let mut serialized_args = [0; 2];
serialized_args[0] = amount;
serialized_args[1] = secretHash;
serialized_args[1] = secret_hash;

context.call_public_function(self.address, 0xdf02db8d, serialized_args)
}
Expand Down
60 changes: 30 additions & 30 deletions yarn-project/noir-contracts/src/contracts/test_contract/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,27 @@ contract Test {
// Note; this function is deliberately NOT annotated with #[aztec(private)] due to its use in tests
fn test_code_gen(
inputs: PrivateContextInputs,
aField: Field,
aBool: bool,
aNumber: u32,
anArray: [Field; 2],
aStruct: DummyNote,
aDeepStruct: DeepStruct,
a_field: Field,
a_bool: bool,
a_number: u32,
an_array: [Field; 2],
a_struct: DummyNote,
a_deep_struct: DeepStruct,
) -> distinct pub abi::PrivateCircuitPublicInputs {
let mut args: BoundedVec<Field, 17> = BoundedVec::new(0);
args.push(aField);
args.push(aBool as Field);
args.push(aNumber as Field);
args.push_array(anArray);
args.push(aStruct.amount);
args.push(aStruct.secretHash);
args.push(aDeepStruct.aField);
args.push(aDeepStruct.aBool as Field);
args.push(aDeepStruct.aNote.amount);
args.push(aDeepStruct.aNote.secretHash);
for note in aDeepStruct.manyNotes {
args.push(a_field);
args.push(a_bool as Field);
args.push(a_number as Field);
args.push_array(an_array);
args.push(a_struct.amount);
args.push(a_struct.secret_hash);
args.push(a_deep_struct.a_field);
args.push(a_deep_struct.a_bool as Field);
args.push(a_deep_struct.a_note.amount);
args.push(a_deep_struct.a_note.secret_hash);
for note in a_deep_struct.many_notes {
args.push(note.amount);
args.push(note.secretHash);
args.push(note.secret_hash);
}
let args_hash = abi::hash_args(args.storage);
let mut context = PrivateContext::new(inputs, args_hash);
Expand All @@ -96,10 +96,10 @@ contract Test {
#[aztec(public)]
fn create_l2_to_l1_message_public(
amount: Field,
secretHash: Field,
secret_hash: Field,
) {
// Create a commitment to the amount
let note = DummyNote::new(amount, secretHash);
let note = DummyNote::new(amount, secret_hash);

// Public oracle call to emit new commitment.
context.message_portal(note.get_commitment());
Expand All @@ -110,10 +110,10 @@ contract Test {
#[aztec(public)]
fn create_nullifier_public(
amount: Field,
secretHash: Field,
secret_hash: Field,
) {
// Create a commitment to the amount
let note = DummyNote::new(amount, secretHash);
let note = DummyNote::new(amount, secret_hash);

// Public oracle call to emit new commitment.
context.push_new_nullifier(note.get_commitment(), EMPTY_NULLIFIED_COMMITMENT);
Expand Down Expand Up @@ -186,26 +186,26 @@ contract Test {

struct DummyNote {
amount: Field,
secretHash: Field
secret_hash: Field
}

impl DummyNote {
fn new(amount: Field, secretHash: Field) -> pub Self {
fn new(amount: Field, secret_hash: Field) -> pub Self {
Self {
amount: amount,
secretHash: secretHash
secret_hash: secret_hash
}
}

fn get_commitment(self) -> pub Field {
pedersen_hash([self.amount, self.secretHash],0)
pedersen_hash([self.amount, self.secret_hash],0)
}
}

struct DeepStruct {
aField: Field,
aBool: bool,
aNote: DummyNote,
manyNotes: [DummyNote; 3],
a_field: Field,
a_bool: bool,
a_note: DummyNote,
many_notes: [DummyNote; 3],
}
}

0 comments on commit b7bb7b9

Please sign in to comment.