From b43d8b318fa935a4051dc0e7162c02372e1ccf00 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu Date: Thu, 18 Aug 2022 11:16:03 -0700 Subject: [PATCH] Add and regen tests --- .../function/record_in_conditional_return.leo | 32 +++++++++++++++++++ .../expectations/compiler/circuits/inline.out | 2 +- .../compiler/circuits/member_variable.out | 2 +- .../expectations/compiler/console/assert.out | 2 +- .../function/record_in_conditional_return.out | 9 ++++++ .../compiler/records/init_expression.out | 2 +- .../records/init_expression_shorthand.out | 2 +- .../compiler/records/nested_record.out | 2 +- 8 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 tests/compiler/function/record_in_conditional_return.leo create mode 100644 tests/expectations/compiler/function/record_in_conditional_return.out diff --git a/tests/compiler/function/record_in_conditional_return.leo b/tests/compiler/function/record_in_conditional_return.leo new file mode 100644 index 0000000000..44c16a24a2 --- /dev/null +++ b/tests/compiler/function/record_in_conditional_return.leo @@ -0,0 +1,32 @@ +/* +namespace: Compile +expectation: Pass +*/ + +record Token { + owner: address, + gates: u64, + amount: u64 +} + +@program +function mint_token(owner: address, amount: u64, password: field) -> Token { + // check if the password is correct + let password_hash: field = 7202470996857839225873911078012225723419856133099120809866608931983814353616field; + let password_hash_from_input: field = Poseidon2::hash(password); + + if(password_hash == password_hash_from_input){ + return Token { + owner: owner, + gates: 0u64, + amount: amount + }; + } + else { + return Token { + owner: owner, + gates: 0u64, + amount: 0u64 + }; + } +} diff --git a/tests/expectations/compiler/circuits/inline.out b/tests/expectations/compiler/circuits/inline.out index 7dd10a332b..d76a5f8210 100644 --- a/tests/expectations/compiler/circuits/inline.out +++ b/tests/expectations/compiler/circuits/inline.out @@ -6,4 +6,4 @@ outputs: - initial_input_ast: no input initial_ast: 5c65976b4634ee0fbbad7377b00319b0c0e855c96bfbdd67239f374029116764 unrolled_ast: 5c65976b4634ee0fbbad7377b00319b0c0e855c96bfbdd67239f374029116764 - ssa_ast: cf9355f637b6ad329e033542d428271e0f8c588dba0c58b8784f6e05752afbe3 + ssa_ast: 29a6602a013e6421ebb35cff04af3d09fe4a80690e7519fda97e4520152c0a9d diff --git a/tests/expectations/compiler/circuits/member_variable.out b/tests/expectations/compiler/circuits/member_variable.out index 896a206eea..bd2f0405b4 100644 --- a/tests/expectations/compiler/circuits/member_variable.out +++ b/tests/expectations/compiler/circuits/member_variable.out @@ -6,4 +6,4 @@ outputs: - initial_input_ast: 3ad7f9e1a4aa5edb8ab4cc1eb0d4baa189f8d388eb90565a269098cee9b06d3c initial_ast: 104350e2f6dda8259ba0a4d7328471cba029bca9fa76fe0e4776900662fdce6f unrolled_ast: 104350e2f6dda8259ba0a4d7328471cba029bca9fa76fe0e4776900662fdce6f - ssa_ast: f09f67fe81c2e4626d324e34a1dcd4b4e661d4ed26b035c0f3e03b2e61a28d65 + ssa_ast: fcaa0f7cbdbeb27a1b915edddfbebd65bca2fc938c969e62a6cdea96ca7c4dfe diff --git a/tests/expectations/compiler/console/assert.out b/tests/expectations/compiler/console/assert.out index 2c80f9e5ec..9fa863bf87 100644 --- a/tests/expectations/compiler/console/assert.out +++ b/tests/expectations/compiler/console/assert.out @@ -6,4 +6,4 @@ outputs: - initial_input_ast: 00ae278f2e47685455a873498a580f06abfcb7bae93cc5844c2616a7da7d03db initial_ast: c9e573f04eefae7c4769e23ef75e1b330fc728126ddfa82458f96e4677ee50a1 unrolled_ast: c9e573f04eefae7c4769e23ef75e1b330fc728126ddfa82458f96e4677ee50a1 - ssa_ast: 48b0763cb65ae1c2740b346ba4ed326ed0b00a921fd5aaf1ab9f4e339834c1d1 + ssa_ast: cd41bc942fcb38a3065f8678e2a57beb0c9a445eda3abd55489c752a874ff3e6 diff --git a/tests/expectations/compiler/function/record_in_conditional_return.out b/tests/expectations/compiler/function/record_in_conditional_return.out new file mode 100644 index 0000000000..244c22fb35 --- /dev/null +++ b/tests/expectations/compiler/function/record_in_conditional_return.out @@ -0,0 +1,9 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - output: + - initial_input_ast: no input + initial_ast: 08e066d2f012e03b969dbbb64faea07edc08f419d9aa61e2e30d1c413e1c3614 + unrolled_ast: 08e066d2f012e03b969dbbb64faea07edc08f419d9aa61e2e30d1c413e1c3614 + ssa_ast: 26bff93f37a51d90a703b7e903c7ff6a4756c8afc768c02002e295f03993385f diff --git a/tests/expectations/compiler/records/init_expression.out b/tests/expectations/compiler/records/init_expression.out index e066a363df..116eecbabe 100644 --- a/tests/expectations/compiler/records/init_expression.out +++ b/tests/expectations/compiler/records/init_expression.out @@ -6,4 +6,4 @@ outputs: - initial_input_ast: no input initial_ast: 08f6c86c1678425452fb8cc9613a9307b132135400d14cf862a8f212bd328cf7 unrolled_ast: 08f6c86c1678425452fb8cc9613a9307b132135400d14cf862a8f212bd328cf7 - ssa_ast: 3afafefd1792ceb9c6986f18ba24a29bcd5c047f0e217863ed8ef017403421bc + ssa_ast: c341be1929e8d349a182445d049b9e714e75b33fbe85a33dd7b90408cbdb526f diff --git a/tests/expectations/compiler/records/init_expression_shorthand.out b/tests/expectations/compiler/records/init_expression_shorthand.out index 4024189ad5..0b543e428a 100644 --- a/tests/expectations/compiler/records/init_expression_shorthand.out +++ b/tests/expectations/compiler/records/init_expression_shorthand.out @@ -6,4 +6,4 @@ outputs: - initial_input_ast: no input initial_ast: 8ba65e37aa7cafbe07ca66b746eb1d9f663d0c2d083a6a9a168ca96d0b706ca1 unrolled_ast: 8ba65e37aa7cafbe07ca66b746eb1d9f663d0c2d083a6a9a168ca96d0b706ca1 - ssa_ast: 4acf70956276b2d7c7d8ea94e95d643e55376ce6ae280e4e2d501f68d1f17ae2 + ssa_ast: a6b0dae4b635d058f7047cf6238831f4323bfa787be37cbfdd4ee52d850b96b3 diff --git a/tests/expectations/compiler/records/nested_record.out b/tests/expectations/compiler/records/nested_record.out index 9f9484e34c..df4d9730f5 100644 --- a/tests/expectations/compiler/records/nested_record.out +++ b/tests/expectations/compiler/records/nested_record.out @@ -6,4 +6,4 @@ outputs: - initial_input_ast: no input initial_ast: 4c9190de88fefd0cd576a5567f42bc1ac4b4db466cbf26703d0226928ba3b593 unrolled_ast: 4c9190de88fefd0cd576a5567f42bc1ac4b4db466cbf26703d0226928ba3b593 - ssa_ast: 92d7be4500a613181004cbd85d3b55428fc68916130b4d9d6764b580f36c182d + ssa_ast: 813e653ac8122755b72c68207c874eb750e1b4f07cc0b408d5ed5a6688823ae4