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

feat: spike out what unit testing puyapy contracts could look like #117

Closed
wants to merge 7 commits into from

Conversation

neilcampbell
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Mar 7, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/puya
   __main__.py30197%110
   arc4_util.py63494%28, 64, 78, 97
   arc32.py66297%87, 98
   compile.py155398%141, 155–158
   errors.py1222976%47–48, 52, 54–57, 82, 124, 144–145, 150–164, 175–178
   logging_config.py1292878%15, 36–39, 45, 47, 50–54, 69, 88, 141–143, 146–148, 150, 163–172, 194
   models.py80298%11–12
   options.py29293%12–13
   parse.py2041891%86, 98, 127, 166, 169, 223, 266, 276, 278, 282, 310–315, 319, 349, 363, 376–377
   utils.py1501987%49, 53, 87, 93, 108, 111–113, 120, 142, 155–156, 160, 164–167, 196, 198, 221
src/puya/awst
   function_traverser.py188398%113, 143–144
   nodes.py9696893%19–28, 44, 53, 87, 93, 97–100, 134, 140, 144–147, 275, 281, 495, 533, 738–739, 759, 771, 809, 815–816, 846, 872, 876–880, 892, 948, 990–991, 996, 1011, 1062, 1067, 1125, 1148, 1165, 1344, 1349–1350, 1357–1362, 1474, 1522, 1531, 1559, 1566, 1579, 1628, 1639, 1641, 1646, 1654, 1659, 1664, 1673, 1678, 1683, 1690
   to_code_visitor.py3201496%83–84, 87–90, 114–115, 196, 321–322, 332, 413–414, 485, 513
   visitors.py2177167%7, 15, 19, 23, 27, 31, 35, 39, 43, 47, 53, 59, 65, 69, 73, 77, 83, 87, 91, 95, 99, 105, 109, 113, 117, 121, 125, 129, 133, 139, 143, 147, 153, 159, 163, 169, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 231, 234, 237, 243, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313
   wtypes.py2873687%21, 64, 176–187, 202–205, 222, 224, 268, 271, 296, 298, 302–303, 306, 331, 350, 386, 389, 416–417, 426–427, 435–436, 447, 450, 509, 516, 532
src/puya/awst_build
   base_mypy_visitor.py1334467%39, 59, 71–77, 95, 106–121, 135, 139, 143, 154, 158, 166, 172, 178, 196, 202, 207, 210, 213, 222, 226, 231, 236, 242, 247, 253, 260, 264, 268, 272, 276, 280, 284, 288, 292, 296, 300, 304, 308
   context.py1402086%124–129, 137, 139–144, 147–148, 168, 173, 177, 190, 202–203
   contract.py3349372%133–134, 136–139, 147–148, 151, 163, 174, 196, 214, 220, 222, 233, 243, 252, 280, 284, 300–304, 312–313, 318, 321, 324, 327, 332–333, 336, 339, 342, 345, 348, 351, 354, 357, 360, 363, 366, 380, 394–401, 410–417, 424–425, 451, 461, 490, 492, 495, 507, 536–537, 552, 556, 559, 565, 568, 571, 574, 582, 590, 593, 596–608, 611, 620, 623, 640, 650–651, 658, 664, 686–692
   intrinsic_models.py32584%21, 26–29
   main.py47394%32, 44, 54
   module.py3708078%67, 115, 133–134, 141, 149, 155, 161–165, 174, 198–199, 210, 240, 266–267, 290, 297, 305–318, 331–332, 355–360, 414–415, 426, 450, 453, 459, 467, 470, 477, 483, 495, 498, 519, 538–539, 556–587, 615–616, 630–632, 634, 636–637, 669–676, 688, 690
   subroutine.py6117388%214, 225, 280, 348, 352, 366, 374, 407–408, 545–559, 567, 575, 578, 590, 619–620, 625, 630, 666, 686–687, 717–723, 776–777, 782, 798, 801, 804, 812–818, 873, 877–878, 882–883, 899, 901, 904–906, 933–934, 942, 977–985, 1020, 1048, 1052, 1083, 1180, 1187, 1197, 1208–1212, 1221, 1224, 1227, 1230, 1233, 1238, 1243, 1250, 1257
   utils.py1742287%47–48, 63, 100, 115–116, 118, 138–139, 159, 173, 184, 189, 196, 208, 234–241, 262, 315–316
src/puya/awst_build/eb
   utils.py21290%13–14
   app_account_state.py1282878%51–54, 62, 79, 81, 114–115, 136–143, 165–166, 171, 178–179, 181, 198–199, 206–207, 236, 241–242
   app_state.py1202282%47–54, 76–77, 82, 92–93, 98, 115–116, 123–124, 165–166, 190, 209
   array.py684534%26–27, 30–32, 37–44, 57–73, 78–80, 83, 86–89, 94–96, 101–103, 113–125
   base.py2076171%24–31, 103, 107, 111, 117, 121, 127–132, 143–149, 154–160, 166, 172, 182, 193, 197, 201, 211, 214, 217, 220, 223, 226, 231, 234, 256, 277, 280, 285, 288, 291, 294, 297, 302, 305, 316, 329, 340, 343, 356, 377, 382, 392, 395, 399, 406, 409, 412, 417, 422, 427, 433
   biguint.py902276%34–38, 63–64, 78, 93, 103–106, 128–131, 148–153, 170–178, 181–182
   bool.py40880%27–31, 50–51, 54–55, 73
   bytes.py1401986%55–59, 82–83, 94–95, 116–117, 121, 125, 130, 132–133, 153, 175, 296–297, 330
   bytes_backed.py29486%38–39, 48–49
   ensure_budget.py481569%25–29, 50–51, 71–72, 80, 92, 98–103
   intrinsics.py1564372%32–34, 56–57, 65–66, 72–73, 90–91, 98, 128, 137, 139–163, 170–171, 215, 223, 235–236, 238, 255–256, 268, 273, 280, 283
   log.py591181%26–30, 85–95, 105, 107
   named_int_constants.py20290%23–24
   struct.py321553%21–22, 25, 36–42, 47–49, 52–57
   subroutine.py35294%52, 72
   template_variables.py471079%25–26, 60–61, 65, 70, 73–74, 83–84
   tuple.py982080%39–40, 47, 58, 60–61, 83–84, 93–94, 107, 113, 131–132, 137–138, 150, 158, 166, 198
   type_registry.py27293%142–143
   uint64.py791581%37–41, 63–64, 85, 103, 126, 145–148, 162–170, 173–174
   unsigned_builtins.py701184%30–34, 52, 59, 94, 97–98, 129, 132–133
   value_proxy.py391269%24, 27, 30, 33, 36, 41, 56, 66, 75, 85, 88, 91
src/puya/awst_build/eb/arc4
   arrays.py2252987%61–65, 78–79, 107, 138, 158–159, 195, 197, 231, 263, 279–280, 293, 336–337, 390–391, 413, 423–424, 440, 470, 490–491, 499, 546
   base.py1191885%34–38, 68–69, 90–91, 159, 180, 197–198, 212–213, 230–231, 241, 251, 256
   bool.py28679%22–29, 55–56
   numeric.py1052378%32–36, 48, 63, 94–95, 97, 100–101, 118, 125–126, 144, 158–159, 164, 169, 203–206, 227
   string.py671282%32–36, 66–67, 102, 121–122, 147–148, 166–167
   struct.py57886%25–32, 68, 71, 106–107
   tuple.py862176%31–35, 50, 54–55, 80, 85–87, 96, 107, 116, 129, 133–134, 146, 162–163, 172–173
src/puya/awst_build/eb/reference_types
   account.py46883%24–26, 44, 53–57
   application.py31681%17–19, 36–37, 41–42
   asset.py52885%27–29, 46–47, 51–52, 89–90
   base.py44491%25–27, 61, 87
src/puya/awst_build/eb/transaction
   base.py33779%16, 24, 28, 33–34, 41, 50
   group.py57984%33–37, 88–89, 98, 145, 148–149
   inner.py56984%28–31, 64–65, 101–102, 116, 144
   inner_params.py981189%29–33, 46–47, 69, 105, 141, 166, 183, 215
src/puya/awst_build/validation
   arc4_copy.py42198%37
   inner_transactions.py931188%92, 100, 111, 121, 125, 128, 133, 141, 151, 164, 169
   scratch_slots.py37489%17, 30, 46, 48
src/puya/ir
   arc4_router.py2722192%180, 281, 299, 307, 463, 543, 589, 656–657, 671, 711–712, 724, 729, 734, 739, 744, 749, 769–774
   avm_ops.py316299%44–45
   avm_ops_models.py36294%20, 28
   context.py881286%18, 59–60, 62, 80–86, 91, 102, 109, 119
   main.py175697%113, 116, 245, 247, 303, 314
   models.py4552694%29, 45, 63, 79, 186, 196, 200, 370, 444, 486, 566, 582, 623, 626, 633, 636, 692, 701, 709, 715, 726–728, 738, 750, 787
   ssa.py136993%43, 51–52, 99, 105, 141, 145, 166, 170
   to_text_visitor.py134795%85, 90, 172–177
   types.py50786%27–28, 52–56, 67
   visitor.py1713778%10–12, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 174, 186, 201, 204, 207, 213, 216, 222, 225, 228, 231, 234, 237, 240, 243
   visitor_mutator.py93298%138–139
   vla.py73297%50, 87
src/puya/ir/builder
   _utils.py71889%33, 44, 57, 79–80, 157, 203–204
   arc4.py4184889%75–76, 125, 149–155, 219, 227, 450, 462, 465, 621–635, 964–978, 1004–1028, 1037–1053, 1076, 1177–1178, 1223–1240, 1279–1280, 1333, 1366–1367, 1517–1518, 1581
   assignment.py43588%59, 75, 102, 133–134
   blocks.py931089%62, 72, 76, 112, 120, 124, 157–159, 165–167
   callsub.py57198%93
   flow_control.py98496%63, 117, 141, 155
   iteration.py190597%46, 66, 95, 176–177
   itxn.py2231593%109–110, 119–120, 130–131, 139, 164, 443–444, 449–450, 456, 472–473
   main.py4745289%94, 119, 148, 152, 197–198, 213–214, 241, 249, 256–257, 328, 356–357, 372, 384, 401, 422, 429, 463, 476, 514, 527–528, 592–593, 615, 663, 691, 709, 744–745, 820, 823, 829, 836–837, 867–868, 883, 929–930, 946–947, 981, 996–998, 1007, 1010–1011
src/puya/ir/destructure
   coalesce_locals.py941584%33, 36, 118, 127–128, 131–134, 137–139, 153–156
   parcopy.py84298%47, 83
src/puya/ir/optimize
   _utils.py28196%21
   collapse_blocks.py92595%65–69
   control_op_simplification.py96694%156–162, 232
   dead_code_elimination.py119298%288, 324
   intrinsic_simplification.py3704189%64, 128, 140, 202, 268, 326, 332, 383, 405, 426, 428, 434, 478, 480, 482, 489, 505, 519, 525, 527, 529, 534, 536, 538, 540, 542, 545–548, 553, 555, 557, 559, 561, 563, 565, 569, 592–593, 600
   main.py85396%106–107, 123
src/puya/mir
   annotaters.py173796%57, 63, 99, 103, 136, 140, 217
   builder.py122695%90, 138, 144, 151, 258–259
   context.py39197%35
   models.py3352493%14–18, 30, 41, 53, 69–70, 78, 89, 100, 111, 141, 251, 282, 319, 331, 348, 356–362, 368
   output.py61297%29, 31
   stack.py2532291%68, 72, 115, 119, 125, 135, 146, 157, 167, 182, 199, 209, 228, 246, 252, 254, 293, 304, 328, 360, 365, 403
   visitor.py762468%7, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103
src/puya/mir/stack_allocation
   baileys.py208697%31, 103, 123, 330–334, 359
   frame_allocation.py80396%21, 64–65
   koopmans.py61198%55
   peephole.py100694%75, 89, 99, 101, 103, 145
src/puya/teal
   models.py229299%292, 298
src/puya/teal/optimize
   peephole.py112596%64, 154–164, 172
   repeated_rotations.py30197%13
   repeated_rotations_search.py88693%34, 40–41, 57, 67–68
TOTAL15213167689% 

Tests Skipped Failures Errors Time
249 2 💤 0 ❌ 0 🔥 2m 29s ⏱️

@neilcampbell neilcampbell changed the title feat: spike out what unit testing puyapy contracts may look like feat: spike out what unit testing puyapy contracts could look like Mar 10, 2024
src/puyapy_mocks/__init__.py Outdated Show resolved Hide resolved
src/puyapy_mocks/_primatives.py Outdated Show resolved Hide resolved
src/puyapy_mocks/op.py Show resolved Hide resolved
src/puyapy_mocks/_reference.py Outdated Show resolved Hide resolved
src/puyapy_mocks/_ctx_state.py Outdated Show resolved Hide resolved
elif isinstance(a, (int, UInt64)):
address = str(a)

return UInt64(active_ctx().get_balance(address, int(b))), False
Copy link
Contributor

Choose a reason for hiding this comment

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

@neilcampbell what happens when a is of type UInt64? Wouldn't address be None in this case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this code is very wrong, so we'll need to handle int/UInt64 address values properly.

@neilcampbell
Copy link
Contributor Author

Closing this, as it has served it's purpose.

@aorumbayev aorumbayev deleted the feat/unit-testing-spike branch April 26, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants