From 68df98611d8ad7486cbccf009f156e6a9b3cbb88 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Thu, 10 Oct 2024 11:46:19 -0700 Subject: [PATCH] feat: add 2 auction examples - 1 handles tie edge case --- nillion_client_script.py | 1 + src/auction.py | 7 +++-- src/auction_can_tie.py | 8 +++--- streamlit_app.py | 15 ++++++---- streamlit_demo_apps/app_auction.py | 26 ++++++++++++++++++ streamlit_demo_apps/app_auction_can_tie.py | 26 ++++++++++++++++++ .../compiled_nada_programs/auction.nada.bin | Bin 0 -> 3279 bytes .../compiled_nada_programs/auction.nada.json | 1 + .../auction_can_tie.nada.bin | Bin 0 -> 4668 bytes .../auction_can_tie.nada.json | 1 + tests/auction_can_tie_test_1.yaml | 10 +++---- tests/auction_can_tie_test_2.yaml | 15 ++++++++++ tests/auction_test_2.yaml | 11 ++++++++ 13 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 streamlit_demo_apps/app_auction.py create mode 100644 streamlit_demo_apps/app_auction_can_tie.py create mode 100644 streamlit_demo_apps/compiled_nada_programs/auction.nada.bin create mode 100644 streamlit_demo_apps/compiled_nada_programs/auction.nada.json create mode 100644 streamlit_demo_apps/compiled_nada_programs/auction_can_tie.nada.bin create mode 100644 streamlit_demo_apps/compiled_nada_programs/auction_can_tie.nada.json create mode 100644 tests/auction_can_tie_test_2.yaml create mode 100644 tests/auction_test_2.yaml diff --git a/nillion_client_script.py b/nillion_client_script.py index 9b308d5..3c48476 100644 --- a/nillion_client_script.py +++ b/nillion_client_script.py @@ -182,6 +182,7 @@ async def store_inputs_and_run_blind_computation( blind_computation_results = compute_event.result.value return { 'user_id': user_id, + 'user_key': userkey, 'program_id': program_id, 'store_ids': store_ids, 'output': blind_computation_results, diff --git a/src/auction.py b/src/auction.py index e9356b2..4295fc4 100644 --- a/src/auction.py +++ b/src/auction.py @@ -3,17 +3,18 @@ def nada_main(): # Define parties auctioneer = Party(name="auctioneer") - parties = [Party(name=f"Party{i}") for i in range(5)] + num_bidders = 5 + bidders = [Party(name=f"bidder_{i}") for i in range(num_bidders)] # Collect bids from each party - bids = [SecretInteger(Input(name=f"bid_{i}", party=parties[i])) for i in range(5)] + bids = [SecretInteger(Input(name=f"bid_{i}", party=bidders[i])) for i in range(num_bidders)] # Initialize variables to track the highest bid and the winning party index highest_bid = bids[0] winning_index = Integer(0) # Compare bids to find the highest - for i in range(1, 5): + for i in range(1, num_bidders): is_higher = bids[i] > highest_bid highest_bid = is_higher.if_else(bids[i], highest_bid) winning_index = is_higher.if_else(Integer(i), winning_index) diff --git a/src/auction_can_tie.py b/src/auction_can_tie.py index b7d104c..ee9811e 100644 --- a/src/auction_can_tie.py +++ b/src/auction_can_tie.py @@ -21,10 +21,10 @@ def nada_main(): # Create a list of outputs for each bidder, indicating if their bid matches the highest bid # Each output is a flag (1 if the bid matches the highest bid, 0 otherwise), visible to the auctioneer - placed_highest_bid = [ - Output((bids[i] == highest_bid).if_else(Integer(1), Integer(0)), f"bidder_{i}_placed_highest_bid", auctioneer) + flag_highest_bid = [ + Output((bids[i] == highest_bid).if_else(Integer(1), Integer(0)), f"bidder_{i}_flag_highest_bid", auctioneer) for i in range(num_bidders) ] - # Return the highest bid and a list of flags indicating which bidders placed the highest bid - return [Output(highest_bid, "highest_bid", auctioneer)] + placed_highest_bid \ No newline at end of file + # Return the highest bid and a list of flags indicating which bidders flag the highest bid + return [Output(highest_bid, "highest_bid", auctioneer)] + flag_highest_bid \ No newline at end of file diff --git a/streamlit_app.py b/streamlit_app.py index d13ddb1..e543bae 100644 --- a/streamlit_app.py +++ b/streamlit_app.py @@ -120,7 +120,7 @@ def create_party_inputs(input_info, input_values): # Distribute parties between the columns for i, party_name in enumerate(party_names): with columns[i % len(columns)]: - st.subheader(f"{party_name}'s Inputs") + st.subheader(f"{party_name}'s inputs") for input_name, value in input_values.items(): if input_info[input_name]['party'] == party_name: input_type = input_info[input_name]['type'] @@ -222,9 +222,10 @@ def main(nada_test_file_name=None, path_nada_bin=None, path_nada_json=None): st.subheader("Nada Program Result") - st.text('Output(s)') + # st.text('Output(s)') + st.success('Output(s)', icon="🖥️") st.caption(f"The Nada program returned one or more outputs to designated output parties - {output_parties}") - st.success(result_message['output'], icon="🖥️") + st.json(result_message['output']) st.text('Nilchain Nillion Address') st.caption(f"Blind computation ran on the Nillion PetNet and operations were paid for on the Nilchain Testnet. Check out the Nilchain transactions that paid for each PetNet operation (store program, store secrets, compute) on the [Nillion Testnet Explorer](https://testnet.nillion.explorers.guru/account/{result_message['nillion_address']})") @@ -234,8 +235,12 @@ def main(nada_test_file_name=None, path_nada_bin=None, path_nada_json=None): st.caption('The Store IDs are the unique identifiers used to reference input values you stored in the Nillion Network on the PetNet.') st.code(result_message['store_ids'], language='json') - st.text('PetNet User ID') - st.caption(f"The User ID is derived from your PetNet user public/private key pair and serves as your public user identifier on the Nillion Network. The user key is randomized every time you run this demo, so the User ID is also randomized.") + st.text('User Key') + st.caption(f"The user key is a private key derived from a PetNet user public/private key pair. It is randomized every time you run this page for the sake of the demo, ensuring that the key is different for each session.") + st.code(result_message['user_key'], language='json') + + st.text('User ID') + st.caption(f"The user id is derived from your PetNet user key and serves as your public user identifier on the Nillion Network. Since the user key is randomized with each run of the demo, the user id is also randomized accordingly.") st.code(result_message['user_id'], language='json') st.text('Program ID') diff --git a/streamlit_demo_apps/app_auction.py b/streamlit_demo_apps/app_auction.py new file mode 100644 index 0000000..53f5efb --- /dev/null +++ b/streamlit_demo_apps/app_auction.py @@ -0,0 +1,26 @@ +# This file was automatically generated by the generate-streamlit-app script. +# To run this file: from the root directory run `streamlit run streamlit_demo_apps/app_auction.py` + +import sys +import os + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +import streamlit_app + +program_name = "auction" +program_test_name = "auction_test_1" + +def main(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + path_nada_bin = os.path.join(current_dir, "compiled_nada_programs", f"{program_name}.nada.bin") + path_nada_json = os.path.join(current_dir, "compiled_nada_programs", f"{program_name}.nada.json") + + if not os.path.exists(path_nada_bin): + raise FileNotFoundError(f"Add `{program_name}.nada.bin` to the compiled_nada_programs folder.") + if not os.path.exists(path_nada_json): + raise FileNotFoundError(f"Run nada build --mir-json and add `{program_name}.nada.json` to the compiled_nada_programs folder.") + + streamlit_app.main(program_test_name, path_nada_bin, path_nada_json) + +if __name__ == "__main__": + main() diff --git a/streamlit_demo_apps/app_auction_can_tie.py b/streamlit_demo_apps/app_auction_can_tie.py new file mode 100644 index 0000000..6672704 --- /dev/null +++ b/streamlit_demo_apps/app_auction_can_tie.py @@ -0,0 +1,26 @@ +# This file was automatically generated by the generate-streamlit-app script. +# To run this file: from the root directory run `streamlit run streamlit_demo_apps/app_auction_can_tie.py` + +import sys +import os + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +import streamlit_app + +program_name = "auction_can_tie" +program_test_name = "auction_can_tie_test_1" + +def main(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + path_nada_bin = os.path.join(current_dir, "compiled_nada_programs", f"{program_name}.nada.bin") + path_nada_json = os.path.join(current_dir, "compiled_nada_programs", f"{program_name}.nada.json") + + if not os.path.exists(path_nada_bin): + raise FileNotFoundError(f"Add `{program_name}.nada.bin` to the compiled_nada_programs folder.") + if not os.path.exists(path_nada_json): + raise FileNotFoundError(f"Run nada build --mir-json and add `{program_name}.nada.json` to the compiled_nada_programs folder.") + + streamlit_app.main(program_test_name, path_nada_bin, path_nada_json) + +if __name__ == "__main__": + main() diff --git a/streamlit_demo_apps/compiled_nada_programs/auction.nada.bin b/streamlit_demo_apps/compiled_nada_programs/auction.nada.bin new file mode 100644 index 0000000000000000000000000000000000000000..b4b30f49640b5df3e7f1cbd51e30dda7d3e9019b GIT binary patch literal 3279 zcmb7G+m0hO5Y2KY2v`9^@PbVCB|*{39d|Ch(kw{32n`5!VPIi3iZb1?d&VN^M4b*W zT>b%Gd74kiGoQrMd;;amnK+q1220&8SJkPT%kHk#+<3vybw8)eaiwR4Qss-D^OB!4 zEu|_)9Ba&;A7PEz^E+5$_I!agX3vkYe%||imS*t04u_1^BkuKTxBeXvg@EV=fKCYL z+yEd#fVcr54gv8t07B*kJnrxwPx3U9qAQX(k0Tx@GUr0&B93z8Zi@j>#HAqJSc<;v zW>Gc}B2&Fw_JtH&h%rF6AOK}5kz)}ji4uc;H%@wkoGTfrjvNf+AnF2Sivp0!x`M|& znZzB%MW1)#c)&YZn$a?$umQ4#0jNL7M3Qhh=!kLDmt1v4)E^7c?e&tpn??ZH;yhDx z;}t)j>C-c{s7BNQzkmDTEu(wAg-z?2$Bb9qRQpjEg)UA~`a9UNBl!fV6>4Vk^EO!3jxmwsbx(LBvaZpOYdXmn6~ zG@fw^I&>O^PEk$MDWK7j03&jP!?-wFS0D6=54yIaBXJ~+AJFJzbTB$P^aGy3frdZ$ zf!`2!+joa40_d;^ov;WnWRyXN$|6)ov_=_ps2qpNxK2#?ppiBjboGrZrNLnj!816} zNE?T1fiV=9hY-TDQ zpV?^7;mx={K2qaSRfk2TPF2}FEauC~1#KN$uWbiA@Btp{Ve96B92UCL=|umm*bix` z(`=#^teUZ^Ovm4|>P#{JSu>%sw2+qPzgW&OrAyx}8+Gsrq~J|*$K2(;@r@%HGUBe_ zS7n*fhACGTih{P#IrN6D+E$IDHVez__TTh?UW_cPL@0X5?js$uz1Eu1+zk5)cUR{l zHCd>pO+*jdp`wf1ptn=Ijz_Y()!x+JNdD2XqTT)9HK+DimIXV$%EsAg21&J9BUm-s zY~Ap!_BL)K9YSubH?bBvtiS9J@%6L&CP|LypWuMz>r%t{o1T-M(l?0PB5Z4?^c~{9 zPd7tJEi90{EIG}_jXFn&GnQl-`goQ7wvs|c1LA?6Mm)VV|xApY+_4! literal 0 HcmV?d00001 diff --git a/streamlit_demo_apps/compiled_nada_programs/auction.nada.json b/streamlit_demo_apps/compiled_nada_programs/auction.nada.json new file mode 100644 index 0000000..d49cbfb --- /dev/null +++ b/streamlit_demo_apps/compiled_nada_programs/auction.nada.json @@ -0,0 +1 @@ +{"functions":[],"parties":[{"name":"auctioneer","source_ref_index":7},{"name":"bidder_0","source_ref_index":8},{"name":"bidder_1","source_ref_index":8},{"name":"bidder_2","source_ref_index":8},{"name":"bidder_3","source_ref_index":8},{"name":"bidder_4","source_ref_index":8}],"inputs":[{"type":"SecretInteger","party":"bidder_0","name":"bid_0","doc":"","source_ref_index":1},{"type":"SecretInteger","party":"bidder_1","name":"bid_1","doc":"","source_ref_index":1},{"type":"SecretInteger","party":"bidder_2","name":"bid_2","doc":"","source_ref_index":1},{"type":"SecretInteger","party":"bidder_3","name":"bid_3","doc":"","source_ref_index":1},{"type":"SecretInteger","party":"bidder_4","name":"bid_4","doc":"","source_ref_index":1}],"literals":[{"name":"0420609fa1d35394f41049df03ef341f","value":"0","type":"Integer"},{"name":"10d33944d37d5b1b833be6fd73d3033c","value":"1","type":"Integer"},{"name":"be9dc3499e38754968f0ed1e2d88d815","value":"2","type":"Integer"},{"name":"eb53046d942e0370244802bab2e0909f","value":"3","type":"Integer"},{"name":"78b3990d823c17d0e5317c335669f5a1","value":"4","type":"Integer"}],"outputs":[{"name":"highest_bid","operation_id":4315895696,"party":"auctioneer","type":"SecretInteger","source_ref_index":3},{"name":"winning_index","operation_id":4315896128,"party":"auctioneer","type":"SecretInteger","source_ref_index":6}],"operations":{"4315893248":{"LessThan":{"id":4315893248,"left":4315890608,"right":4315891616,"type":"SecretBoolean","source_ref_index":2}},"4315893680":{"IfElse":{"id":4315893680,"this":4315893248,"arg_0":4315893488,"arg_1":4315893008,"type":"SecretInteger","source_ref_index":4}},"4315895408":{"LessThan":{"id":4315895408,"left":4315894880,"right":4315892720,"type":"SecretBoolean","source_ref_index":2}},"4315894448":{"IfElse":{"id":4315894448,"this":4315893920,"arg_0":4315894256,"arg_1":4315893680,"type":"SecretInteger","source_ref_index":4}},"4315893488":{"LiteralReference":{"id":4315893488,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":4}},"4315895024":{"LiteralReference":{"id":4315895024,"refers_to":"eb53046d942e0370244802bab2e0909f","type":"Integer","source_ref_index":4}},"4315893920":{"LessThan":{"id":4315893920,"left":4315893296,"right":4315892240,"type":"SecretBoolean","source_ref_index":2}},"4315895984":{"LiteralReference":{"id":4315895984,"refers_to":"78b3990d823c17d0e5317c335669f5a1","type":"Integer","source_ref_index":4}},"4315893008":{"LiteralReference":{"id":4315893008,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":5}},"4315890608":{"InputReference":{"id":4315890608,"refers_to":"bid_0","type":"SecretInteger","source_ref_index":1}},"4315894256":{"LiteralReference":{"id":4315894256,"refers_to":"be9dc3499e38754968f0ed1e2d88d815","type":"Integer","source_ref_index":4}},"4315891616":{"InputReference":{"id":4315891616,"refers_to":"bid_1","type":"SecretInteger","source_ref_index":1}},"4315893296":{"IfElse":{"id":4315893296,"this":4315893248,"arg_0":4315891616,"arg_1":4315890608,"type":"SecretInteger","source_ref_index":0}},"4315894688":{"LessThan":{"id":4315894688,"left":4315894112,"right":4315892480,"type":"SecretBoolean","source_ref_index":2}},"4315895696":{"IfElse":{"id":4315895696,"this":4315895408,"arg_0":4315892720,"arg_1":4315894880,"type":"SecretInteger","source_ref_index":0}},"4315894880":{"IfElse":{"id":4315894880,"this":4315894688,"arg_0":4315892480,"arg_1":4315894112,"type":"SecretInteger","source_ref_index":0}},"4315892240":{"InputReference":{"id":4315892240,"refers_to":"bid_2","type":"SecretInteger","source_ref_index":1}},"4315892480":{"InputReference":{"id":4315892480,"refers_to":"bid_3","type":"SecretInteger","source_ref_index":1}},"4315892720":{"InputReference":{"id":4315892720,"refers_to":"bid_4","type":"SecretInteger","source_ref_index":1}},"4315896128":{"IfElse":{"id":4315896128,"this":4315895408,"arg_0":4315895984,"arg_1":4315895216,"type":"SecretInteger","source_ref_index":4}},"4315895216":{"IfElse":{"id":4315895216,"this":4315894688,"arg_0":4315895024,"arg_1":4315894448,"type":"SecretInteger","source_ref_index":4}},"4315894112":{"IfElse":{"id":4315894112,"this":4315893920,"arg_0":4315892240,"arg_1":4315893296,"type":"SecretInteger","source_ref_index":0}}},"source_files":{"auction.py":"from nada_dsl import *\n\ndef nada_main():\n # Define parties\n auctioneer = Party(name=\"auctioneer\")\n num_bidders = 5\n bidders = [Party(name=f\"bidder_{i}\") for i in range(num_bidders)]\n \n # Collect bids from each party\n bids = [SecretInteger(Input(name=f\"bid_{i}\", party=bidders[i])) for i in range(num_bidders)]\n \n # Initialize variables to track the highest bid and the winning party index\n highest_bid = bids[0]\n winning_index = Integer(0)\n \n # Compare bids to find the highest\n for i in range(1, num_bidders):\n is_higher = bids[i] > highest_bid\n highest_bid = is_higher.if_else(bids[i], highest_bid)\n winning_index = is_higher.if_else(Integer(i), winning_index)\n \n # Output the highest bid and the winning party index\n return [\n Output(highest_bid, \"highest_bid\", auctioneer),\n Output(winning_index, \"winning_index\", auctioneer)\n ]\n"},"source_refs":[{"file":"auction.py","lineno":19,"offset":595,"length":61},{"file":"auction.py","lineno":10,"offset":234,"length":96},{"file":"auction.py","lineno":18,"offset":553,"length":41},{"file":"auction.py","lineno":24,"offset":801,"length":55},{"file":"auction.py","lineno":20,"offset":657,"length":68},{"file":"auction.py","lineno":14,"offset":442,"length":30},{"file":"auction.py","lineno":25,"offset":857,"length":58},{"file":"auction.py","lineno":5,"offset":62,"length":41},{"file":"auction.py","lineno":7,"offset":124,"length":69}]} \ No newline at end of file diff --git a/streamlit_demo_apps/compiled_nada_programs/auction_can_tie.nada.bin b/streamlit_demo_apps/compiled_nada_programs/auction_can_tie.nada.bin new file mode 100644 index 0000000000000000000000000000000000000000..2e52950d4661bb15323ad3b2f772c17a73498d8b GIT binary patch literal 4668 zcmbVP-EJF26gIS!Hk3A$ir-RB6Hsihs$H+s5+rj&dyy+5dKpD#0ZFfL!58AEZNwAT|VG^xJ8|}0m2JMX`4I-6B?Jz~`1`G&= zK@u@$~CZcTu#fo}|gsD2ak7>Osf=0@&Yk7W;ayuga>+5T7i+x-Pu)H6l>U zPu8b)tD#Q1=^)%=PW+6Ta8AwXCvTvpHK!){;tkY9b83zry@8tcoSKub zucGFW!|3<}%YB>wgFf2+!z2mGdYA8j>DFz_FK3{^zjb4JhpK}P$pz?TR|F?ZmVfK6 z-I0D~t&QHF>H>Z0Y#-m8-oeiCo#`3q6Q|?!*7Oei$eH*B`uH=;cl5d4M-S{Sej)z9 z?%A`udAlN8hJX;&Z!q4 zXcEVHy>4;{58^{Hi@%^xA6j2dzO?(_WOpB5+zGy*iD_Aj;ES5P!*ZbgF&T(aOs!?t zGGY`oF)eG6py?|ckmvzTqJ-BX&SNeKc%YHI;A3lp-0bqf!=2a%O-##L#6B88^nfN& z!fO#dC`c2BYhDZu6d{r`Q?zbCNCRM4U`U`z# zW<0v_01M}~k1KKEN4aDCoX3wWnu>85C6<-7NaX=d2@13yROknVxh6(I6VtL5F^Z?K zq!%=vA()MrAz~l10jU%@(3sg1u-uFjIV{Wz@f$R`%SHT#4FLsDGl9v%McY^Fs%q%2P2Zc+|N4@Y@X(Kky=iAwG9FxFYU z@%<9t>XMsZOcQlZLGo|SrcpeW4?%J)@KDy6eMUrgA>gQ_%o zJyjjr5-s&C9;(jD^kSu9IGr0m7AmgT1sdqGqCBN_vaf3;i4(e~M{y+Yhb2k0I?KzgNI6c4V-&YzYOf9yGINMWoPfufK#_fDC zP`yfgEy*CS;$Gjm-lT)RDiq;}bjbm}P`yG`n^~pyRKX@jqUpsM~s{arKa%sY(??)P#FW7Dp%^=A3|dFfd*^ z<;J&FdQowfX!no<(v^+}`X$Q4*Wdz7b-_ut3f4*?j27>WoCD?4ayzhSuhJ$vB?VIT zi+sG-cQ{EYiyh$=^v0vaGAZ)S>XdOe2VA^d?3{-*A7|F8RJ51sut|QlZJS7|=+b^N z6!1;&&<`*pRc2xk&e=F7a*uV|RfAI1O=Nnf=`%K#9FTL3kdG@)v3OieDv1la$w()< z=b9oFKy)EM&@irg{DEX3@=$R4pG$pOowgq3V~FY@F-S55F454WfO6(34s@v+P1@IX zCb+ClTicjA`;jHJJAvpY6I2~gP^U8k#sn(YCiRfbfesq{$M4sfe}zU?6Jils>_ z-oM!(cIaE9(*JCgcNSR}KNIfr?aOPmTIW(OdAs highest_bid\n highest_bid = is_higher.if_else(bids[i], highest_bid)\n\n # Create a list of outputs for each bidder, indicating if their bid matches the highest bid\n # Each output is a flag (1 if the bid matches the highest bid, 0 otherwise), visible to the auctioneer\n flag_highest_bid = [\n Output((bids[i] == highest_bid).if_else(Integer(1), Integer(0)), f\"bidder_{i}_flag_highest_bid\", auctioneer)\n for i in range(num_bidders)\n ]\n\n # Return the highest bid and a list of flags indicating which bidders flag the highest bid\n return [Output(highest_bid, \"highest_bid\", auctioneer)] + flag_highest_bid"},"source_refs":[{"file":"auction_can_tie.py","lineno":20,"offset":890,"length":61},{"file":"auction_can_tie.py","lineno":12,"offset":468,"length":96},{"file":"auction_can_tie.py","lineno":19,"offset":848,"length":41},{"file":"auction_can_tie.py","lineno":30,"offset":0,"length":0},{"file":"auction_can_tie.py","lineno":25,"offset":1181,"length":116},{"file":"auction_can_tie.py","lineno":5,"offset":129,"length":41},{"file":"auction_can_tie.py","lineno":9,"offset":284,"length":69}]} \ No newline at end of file diff --git a/tests/auction_can_tie_test_1.yaml b/tests/auction_can_tie_test_1.yaml index 7a44e9c..5c0b129 100644 --- a/tests/auction_can_tie_test_1.yaml +++ b/tests/auction_can_tie_test_1.yaml @@ -7,9 +7,9 @@ inputs: bid_3: 3 bid_4: 4 expected_outputs: - bidder_0_placed_highest_bid: 0 - bidder_1_placed_highest_bid: 0 - bidder_2_placed_highest_bid: 1 - bidder_3_placed_highest_bid: 0 - bidder_4_placed_highest_bid: 1 + bidder_0_flag_highest_bid: 0 + bidder_1_flag_highest_bid: 0 + bidder_2_flag_highest_bid: 1 + bidder_3_flag_highest_bid: 0 + bidder_4_flag_highest_bid: 1 highest_bid: 4 diff --git a/tests/auction_can_tie_test_2.yaml b/tests/auction_can_tie_test_2.yaml new file mode 100644 index 0000000..53e2223 --- /dev/null +++ b/tests/auction_can_tie_test_2.yaml @@ -0,0 +1,15 @@ +--- +program: auction_can_tie +inputs: + bid_0: 10 + bid_1: 9 + bid_2: 80 + bid_3: 7 + bid_4: 6 +expected_outputs: + bidder_0_flag_highest_bid: 0 + bidder_1_flag_highest_bid: 0 + bidder_2_flag_highest_bid: 1 + bidder_3_flag_highest_bid: 0 + bidder_4_flag_highest_bid: 0 + highest_bid: 80 diff --git a/tests/auction_test_2.yaml b/tests/auction_test_2.yaml new file mode 100644 index 0000000..bfcd4aa --- /dev/null +++ b/tests/auction_test_2.yaml @@ -0,0 +1,11 @@ +--- +program: auction +inputs: + bid_0: 5 + bid_1: 10 # note that this program does not handle ties properly + bid_2: 10 # in the case of a tie, the first party to place the tie bid wins + bid_3: 4 + bid_4: 9 +expected_outputs: + highest_bid: 10 + winning_index: 1