mirror of https://github.com/nucypher/nucypher.git
Reworked logic to determine good serials for mocks.
parent
21ed54097c
commit
046c8e3989
|
@ -99,7 +99,7 @@ from tests.mock.performance_mocks import (
|
|||
mock_remember_node,
|
||||
mock_rest_app_creation,
|
||||
mock_secret_source,
|
||||
mock_verify_node
|
||||
mock_verify_node, _determine_good_serials
|
||||
)
|
||||
from tests.utils.blockchain import TesterBlockchain, token_airdrop
|
||||
from tests.utils.config import (
|
||||
|
@ -924,6 +924,7 @@ def mock_transacting_power_activation(testerchain):
|
|||
|
||||
@pytest.fixture(scope="module")
|
||||
def fleet_of_highperf_mocked_ursulas(ursula_federated_test_config, request):
|
||||
# good_serials = _determine_good_serials(10000, 50000)
|
||||
try:
|
||||
quantity = request.param
|
||||
except AttributeError:
|
||||
|
|
|
@ -17,13 +17,14 @@
|
|||
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
|
||||
from umbral.config import default_params
|
||||
from umbral.keys import UmbralPublicKey
|
||||
from umbral.signing import Signature
|
||||
from unittest.mock import patch
|
||||
|
||||
from nucypher.network.server import make_rest_app
|
||||
from tests.mock.serials import good_serials
|
||||
from tests.utils.ursula import MOCK_KNOWN_URSULAS_CACHE
|
||||
from umbral.config import default_params
|
||||
from umbral.keys import UmbralPublicKey
|
||||
from umbral.signing import Signature
|
||||
|
||||
mock_cert_storage = patch("nucypher.config.storages.ForgetfulNodeStorage.store_node_certificate",
|
||||
new=lambda *args, **kwargs: "this_might_normally_be_a_filepath")
|
||||
|
@ -49,335 +50,22 @@ The problem is that, for any mock key string, there are going to be some bytes t
|
|||
The only other obvious way to have a test this fast is to hardcode 20k keypairs into the codebase (and even then, it will be far, far less performant than this).
|
||||
"""
|
||||
|
||||
serials_which_produce_bytes_which_are_not_viable_as_a_pubkey = (10001, 10003, 10004, 10005, 10007, 10013, 10014, 10018,
|
||||
10020, 10022, 10029, 10031, 10033, 10034, 10035, 10036,
|
||||
10037, 10038, 10040, 10041, 10043, 10045, 10049, 10051,
|
||||
10052, 10053, 10054, 10055, 10056, 10057, 10058, 10060,
|
||||
10064, 10065, 10068, 10069, 10070, 10071, 10074, 10077,
|
||||
10078, 10082, 10083, 10086, 10089, 10090, 10091, 10092,
|
||||
10093, 10095, 10096, 10099, 10100, 10101, 10102, 10103,
|
||||
10107, 10108, 10110, 10112, 10113, 10116, 10119, 10120,
|
||||
10122, 10124, 10125, 10128, 10130, 10131, 10134, 10140,
|
||||
10141, 10142, 10143, 10145, 10146, 10149, 10150, 10151,
|
||||
10152, 10153, 10154, 10155, 10158, 10159, 10160, 10161,
|
||||
10164, 10166, 10167, 10169, 10171, 10173, 10174, 10175,
|
||||
10180, 10184, 10187, 10190, 10191, 10193, 10197, 10198,
|
||||
10199, 10201, 10202, 10205, 10207, 10209, 10212, 10215,
|
||||
10218, 10219, 10225, 10226, 10229, 10230, 10233, 10234,
|
||||
10237, 10239, 10240, 10241, 10243, 10244, 10245, 10251,
|
||||
10252, 10253, 10260, 10262, 10263, 10264, 10266, 10267,
|
||||
10269, 10277, 10283, 10284, 10291, 10292, 10293, 10294,
|
||||
10296, 10297, 10302, 10303, 10305, 10306, 10312, 10315,
|
||||
10317, 10318, 10319, 10321, 10322, 10326, 10329, 10332,
|
||||
10340, 10344, 10345, 10348, 10349, 10351, 10352, 10353,
|
||||
10354, 10355, 10357, 10359, 10360, 10361, 10362, 10363,
|
||||
10364, 10365, 10367, 10369, 10371, 10373, 10374, 10376,
|
||||
10377, 10380, 10383, 10385, 10386, 10387, 10388, 10389,
|
||||
10392, 10393, 10394, 10395, 10396, 10399, 10400, 10403,
|
||||
10404, 10405, 10406, 10407, 10409, 10410, 10415, 10416,
|
||||
10418, 10419, 10420, 10424, 10425, 10429, 10430, 10431,
|
||||
10432, 10433, 10436, 10439, 10440, 10444, 10452, 10454,
|
||||
10456, 10458, 10463, 10467, 10468, 10470, 10471, 10472,
|
||||
10473, 10476, 10477, 10478, 10480, 10483, 10488, 10489,
|
||||
10490, 10493, 10494, 10496, 10497, 10498, 10499, 10501,
|
||||
10503, 10504, 10507, 10512, 10514, 10515, 10516, 10518,
|
||||
10522, 10523, 10524, 10526, 10527, 10529, 10531, 10533,
|
||||
10537, 10538, 10539, 10546, 10547, 10551, 10553, 10554,
|
||||
10555, 10556, 10557, 10559, 10561, 10563, 10565, 10567,
|
||||
10568, 10570, 10574, 10575, 10577, 10578, 10580, 10588,
|
||||
10590, 10592, 10593, 10596, 10598, 10599, 10601, 10602,
|
||||
10604, 10607, 10609, 10610, 10613, 10616, 10618, 10623,
|
||||
10624, 10628, 10630, 10631, 10637, 10639, 10640, 10641,
|
||||
10642, 10643, 10647, 10651, 10652, 10653, 10655, 10656,
|
||||
10657, 10660, 10661, 10662, 10664, 10666, 10668, 10671,
|
||||
10674, 10676, 10677, 10679, 10680, 10686, 10692, 10695,
|
||||
10696, 10697, 10699, 10701, 10703, 10704, 10705, 10707,
|
||||
10708, 10711, 10713, 10715, 10717, 10722, 10724, 10731,
|
||||
10732, 10733, 10734, 10736, 10739, 10740, 10741, 10742,
|
||||
10746, 10747, 10753, 10754, 10755, 10758, 10759, 10761,
|
||||
10763, 10764, 10765, 10767, 10768, 10771, 10772, 10773,
|
||||
10774, 10775, 10777, 10779, 10780, 10785, 10786, 10789,
|
||||
10792, 10793, 10798, 10802, 10803, 10806, 10807, 10808,
|
||||
10809, 10810, 10812, 10813, 10815, 10816, 10817, 10818,
|
||||
10821, 10822, 10827, 10828, 10832, 10834, 10836, 10837,
|
||||
10839, 10844, 10846, 10848, 10849, 10851, 10853, 10855,
|
||||
10858, 10859, 10860, 10861, 10862, 10863, 10864, 10865,
|
||||
10866, 10867, 10870, 10872, 10873, 10877, 10878, 10880,
|
||||
10881, 10883, 10884, 10887, 10889, 10892, 10893, 10895,
|
||||
10896, 10898, 10899, 10900, 10901, 10902, 10908, 10910,
|
||||
10915, 10916, 10920, 10921, 10922, 10923, 10924, 10926,
|
||||
10931, 10932, 10934, 10935, 10936, 10937, 10939, 10940,
|
||||
10948, 10952, 10953, 10954, 10958, 10959, 10961, 10963,
|
||||
10964, 10965, 10966, 10968, 10969, 10970, 10972, 10974,
|
||||
10975, 10976, 10977, 10978, 10979, 10981, 10982, 10983,
|
||||
10984, 10985, 10986, 10987, 10988, 10992, 10993, 10996,
|
||||
10997, 10998, 10999, 11001, 11002, 11005, 11010, 11011,
|
||||
11015, 11016, 11019, 11025, 11026, 11027, 11029, 11030,
|
||||
11034, 11035, 11039, 11041, 11043, 11046, 11050, 11054,
|
||||
11055, 11057, 11058, 11064, 11066, 11067, 11068, 11070,
|
||||
11071, 11073, 11074, 11076, 11078, 11082, 11084, 11086,
|
||||
11087, 11089, 11092, 11093, 11094, 11095, 11097, 11098,
|
||||
11100, 11103, 11104, 11105, 11108, 11111, 11114, 11115,
|
||||
11116, 11118, 11119, 11120, 11122, 11124, 11125, 11127,
|
||||
11128, 11131, 11132, 11135, 11137, 11139, 11142, 11143,
|
||||
11145, 11148, 11150, 11151, 11153, 11155, 11156, 11158,
|
||||
11160, 11164, 11165, 11167, 11169, 11171, 11176, 11179,
|
||||
11181, 11182, 11183, 11184, 11186, 11187, 11188, 11189,
|
||||
11194, 11197, 11198, 11200, 11205, 11206, 11208, 11209,
|
||||
11212, 11213, 11214, 11217, 11221, 11224, 11228, 11230,
|
||||
11238, 11239, 11241, 11242, 11243, 11245, 11249, 11250,
|
||||
11251, 11252, 11253, 11259, 11261, 11263, 11264, 11266,
|
||||
11267, 11272, 11273, 11278, 11279, 11280, 11282, 11283,
|
||||
11286, 11287, 11289, 11291, 11295, 11296, 11298, 11299,
|
||||
11304, 11307, 11308, 11309, 11310, 11312, 11319, 11321,
|
||||
11323, 11327, 11328, 11330, 11331, 11332, 11337, 11340,
|
||||
11345, 11347, 11349, 11350, 11351, 11352, 11353, 11354,
|
||||
11355, 11359, 11360, 11361, 11362, 11363, 11364, 11366,
|
||||
11368, 11369, 11371, 11374, 11377, 11380, 11382, 11383,
|
||||
11384, 11386, 11387, 11388, 11390, 11393, 11394, 11396,
|
||||
11398, 11401, 11403, 11406, 11411, 11412, 11417, 11422,
|
||||
11423, 11428, 11429, 11430, 11431, 11433, 11434, 11435,
|
||||
11442, 11444, 11449, 11451, 11453, 11456, 11457, 11458,
|
||||
11461, 11463, 11464, 11465, 11466, 11469, 11470, 11471,
|
||||
11472, 11476, 11477, 11478, 11479, 11481, 11485, 11488,
|
||||
11490, 11492, 11494, 11495, 11496, 11498, 11500, 11501,
|
||||
11502, 11503, 11505, 11509, 11510, 11513, 11514, 11515,
|
||||
11516, 11518, 11521, 11523, 11524, 11525, 11527, 11530,
|
||||
11531, 11532, 11533, 11535, 11537, 11538, 11539, 11540,
|
||||
11544, 11546, 11548, 11551, 11552, 11553, 11559, 11560,
|
||||
11562, 11564, 11568, 11569, 11575, 11576, 11577, 11579,
|
||||
11581, 11584, 11585, 11586, 11587, 11591, 11592, 11593,
|
||||
11596, 11597, 11598, 11600, 11601, 11604, 11605, 11608,
|
||||
11609, 11610, 11611, 11612, 11616, 11618, 11621, 11622,
|
||||
11623, 11624, 11628, 11633, 11634, 11637, 11638, 11641,
|
||||
11642, 11644, 11645, 11646, 11650, 11655, 11658, 11661,
|
||||
11664, 11665, 11666, 11668, 11670, 11671, 11672, 11673,
|
||||
11674, 11675, 11679, 11681, 11684, 11685, 11687, 11688,
|
||||
11689, 11690, 11691, 11692, 11695, 11696, 11697, 11698,
|
||||
11699, 11700, 11701, 11702, 11706, 11709, 11710, 11712,
|
||||
11716, 11718, 11719, 11724, 11726, 11732, 11733, 11736,
|
||||
11737, 11738, 11742, 11744, 11745, 11746, 11747, 11748,
|
||||
11749, 11750, 11751, 11756, 11757, 11759, 11763, 11764,
|
||||
11768, 11771, 11772, 11773, 11775, 11778, 11779, 11780,
|
||||
11782, 11784, 11785, 11786, 11787, 11788, 11789, 11790,
|
||||
11791, 11794, 11798, 11800, 11802, 11804, 11811, 11815,
|
||||
11818, 11821, 11824, 11829, 11831, 11833, 11834, 11837,
|
||||
11839, 11840, 11846, 11847, 11848, 11849, 11851, 11852,
|
||||
11853, 11860, 11863, 11865, 11866, 11867, 11868, 11869,
|
||||
11870, 11873, 11877, 11878, 11881, 11883, 11885, 11886,
|
||||
11888, 11889, 11893, 11894, 11895, 11896, 11899, 11902,
|
||||
11905, 11906, 11909, 11910, 11912, 11913, 11916, 11919,
|
||||
11920, 11924, 11925, 11927, 11931, 11933, 11934, 11936,
|
||||
11937, 11938, 11943, 11947, 11948, 11953, 11954, 11955,
|
||||
11956, 11959, 11960, 11963, 11969, 11970, 11972, 11973,
|
||||
11975, 11980, 11981, 11983, 11985, 11991, 11992, 11996,
|
||||
11999, 12002, 12003, 12004, 12007, 12008, 12009, 12010,
|
||||
12011, 12012, 12013, 12014, 12016, 12017, 12018, 12020,
|
||||
12022, 12026, 12028, 12029, 12030, 12031, 12034, 12036,
|
||||
12043, 12045, 12047, 12050, 12051, 12053, 12054, 12056,
|
||||
12057, 12058, 12060, 12061, 12063, 12065, 12067, 12069,
|
||||
12070, 12071, 12074, 12075, 12076, 12077, 12079, 12080,
|
||||
12082, 12083, 12084, 12086, 12087, 12089, 12090, 12091,
|
||||
12092, 12093, 12094, 12095, 12096, 12097, 12098, 12099,
|
||||
12102, 12103, 12104, 12111, 12113, 12114, 12116, 12122,
|
||||
12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130,
|
||||
12132, 12135, 12136, 12137, 12138, 12139, 12140, 12141,
|
||||
12145, 12147, 12148, 12151, 12152, 12153, 12155, 12156,
|
||||
12157, 12159, 12164, 12167, 12170, 12171, 12173, 12174,
|
||||
12176, 12178, 12179, 12181, 12182, 12183, 12185, 12190,
|
||||
12193, 12194, 12195, 12198, 12200, 12201, 12202, 12204,
|
||||
12205, 12208, 12211, 12212, 12214, 12215, 12218, 12219,
|
||||
12221, 12222, 12223, 12226, 12227, 12229, 12230, 12232,
|
||||
12233, 12238, 12244, 12245, 12246, 12249, 12254, 12255,
|
||||
12257, 12258, 12262, 12263, 12264, 12265, 12266, 12272,
|
||||
12273, 12274, 12276, 12277, 12278, 12280, 12281, 12283,
|
||||
12284, 12286, 12288, 12293, 12294, 12297, 12299, 12300,
|
||||
12301, 12302, 12303, 12304, 12308, 12309, 12310, 12313,
|
||||
12314, 12315, 12316, 12317, 12320, 12321, 12323, 12324,
|
||||
12328, 12330, 12331, 12333, 12334, 12335, 12338, 12339,
|
||||
12340, 12346, 12350, 12354, 12357, 12360, 12361, 12362,
|
||||
12363, 12365, 12368, 12369, 12375, 12376, 12378, 12382,
|
||||
12385, 12386, 12388, 12389, 12396, 12398, 12403, 12404,
|
||||
12408, 12409, 12411, 12413, 12420, 12421, 12422, 12424,
|
||||
12426, 12427, 12429, 12431, 12432, 12435, 12436, 12437,
|
||||
12438, 12442, 12443, 12445, 12446, 12447, 12448, 12455,
|
||||
12457, 12458, 12460, 12463, 12464, 12466, 12467, 12468,
|
||||
12469, 12470, 12472, 12473, 12474, 12475, 12476, 12480,
|
||||
12481, 12484, 12485, 12486, 12487, 12489, 12490, 12491,
|
||||
12492, 12496, 12497, 12499, 12502, 12504, 12505, 12507,
|
||||
12508, 12509, 12514, 12515, 12516, 12518, 12520, 12521,
|
||||
12523, 12540, 12544, 12546, 12548, 12549, 12553, 12555,
|
||||
12556, 12558, 12559, 12560, 12563, 12564, 12566, 12568,
|
||||
12569, 12572, 12574, 12575, 12576, 12577, 12579, 12580,
|
||||
12581, 12582, 12585, 12586, 12587, 12589, 12590, 12591,
|
||||
12593, 12597, 12599, 12601, 12602, 12604, 12605, 12607,
|
||||
12608, 12609, 12610, 12613, 12615, 12616, 12617, 12620,
|
||||
12623, 12624, 12631, 12632, 12633, 12634, 12635, 12636,
|
||||
12637, 12638, 12639, 12640, 12644, 12648, 12650, 12651,
|
||||
12652, 12657, 12658, 12659, 12663, 12665, 12666, 12667,
|
||||
12668, 12669, 12672, 12676, 12679, 12680, 12681, 12682,
|
||||
12683, 12684, 12685, 12687, 12688, 12690, 12691, 12693,
|
||||
12694, 12697, 12699, 12702, 12703, 12705, 12708, 12709,
|
||||
12710, 12712, 12714, 12715, 12716, 12721, 12728, 12730,
|
||||
12731, 12732, 12735, 12738, 12739, 12742, 12746, 12748,
|
||||
12750, 12753, 12755, 12757, 12758, 12764, 12765, 12774,
|
||||
12776, 12778, 12779, 12781, 12785, 12786, 12787, 12788,
|
||||
12791, 12799, 12800, 12802, 12804, 12805, 12808, 12813,
|
||||
12816, 12817, 12818, 12819, 12820, 12824, 12825, 12827,
|
||||
12828, 12830, 12831, 12832, 12833, 12836, 12838, 12839,
|
||||
12840, 12841, 12843, 12844, 12847, 12848, 12850, 12851,
|
||||
12853, 12855, 12857, 12858, 12860, 12862, 12864, 12865,
|
||||
12866, 12867, 12868, 12870, 12875, 12876, 12877, 12878,
|
||||
12879, 12881, 12882, 12883, 12889, 12890, 12891, 12892,
|
||||
12893, 12898, 12902, 12904, 12905, 12908, 12909, 12910,
|
||||
12911, 12916, 12917, 12918, 12919, 12920, 12922, 12923,
|
||||
12925, 12926, 12927, 12928, 12931, 12934, 12935, 12938,
|
||||
12942, 12943, 12944, 12945, 12951, 12952, 12953, 12954,
|
||||
12955, 12956, 12957, 12958, 12960, 12961, 12962, 12963,
|
||||
12965, 12966, 12969, 12970, 12971, 12976, 12977, 12980,
|
||||
12982, 12983, 12984, 12985, 12991, 12992, 12994, 12996,
|
||||
13003, 13004, 13005, 13006, 13007, 13010, 13011, 13013,
|
||||
13015, 13016, 13018, 13021, 13022, 13025, 13028, 13030,
|
||||
13031, 13033, 13034, 13036, 13038, 13039, 13041, 13045,
|
||||
13046, 13049, 13051, 13052, 13054, 13055, 13057, 13058,
|
||||
13059, 13061, 13062, 13063, 13067, 13071, 13072, 13078,
|
||||
13081, 13082, 13084, 13087, 13090, 13091, 13093, 13095,
|
||||
13096, 13098, 13099, 13100, 13101, 13102, 13103, 13105,
|
||||
13106, 13108, 13109, 13112, 13114, 13115, 13116, 13118,
|
||||
13120, 13121, 13123, 13124, 13125, 13126, 13129, 13130,
|
||||
13131, 13132, 13133, 13134, 13136, 13137, 13138, 13139,
|
||||
13141, 13144, 13145, 13146, 13148, 13149, 13151, 13152,
|
||||
13153, 13154, 13155, 13156, 13157, 13158, 13160, 13161,
|
||||
13164, 13165, 13166, 13167, 13168, 13172, 13173, 13177,
|
||||
13178, 13179, 13180, 13182, 13184, 13185, 13190, 13194,
|
||||
13195, 13199, 13200, 13201, 13203, 13205, 13206, 13212,
|
||||
13214, 13216, 13217, 13218, 13219, 13220, 13221, 13225,
|
||||
13226, 13227, 13241, 13242, 13243, 13244, 13245, 13247,
|
||||
13253, 13256, 13257, 13258, 13259, 13261, 13262, 13263,
|
||||
13265, 13267, 13269, 13271, 13272, 13274, 13276, 13277,
|
||||
13279, 13280, 13282, 13284, 13285, 13286, 13287, 13290,
|
||||
13293, 13294, 13296, 13298, 13302, 13305, 13308, 13309,
|
||||
13310, 13311, 13317, 13318, 13320, 13322, 13323, 13325,
|
||||
13327, 13329, 13330, 13333, 13338, 13339, 13340, 13342,
|
||||
13345, 13346, 13347, 13350, 13353, 13355, 13357, 13358,
|
||||
13359, 13364, 13365, 13366, 13368, 13372, 13374, 13376,
|
||||
13379, 13380, 13383, 13384, 13386, 13388, 13389, 13390,
|
||||
13392, 13393, 13394, 13395, 13396, 13398, 13399, 13402,
|
||||
13403, 13405, 13406, 13408, 13410, 13412, 13414, 13416,
|
||||
13417, 13419, 13421, 13422, 13423, 13425, 13428, 13432,
|
||||
13434, 13435, 13437, 13438, 13439, 13440, 13442, 13443,
|
||||
13444, 13445, 13452, 13453, 13454, 13455, 13457, 13458,
|
||||
13459, 13462, 13464, 13465, 13470, 13474, 13477, 13479,
|
||||
13482, 13484, 13486, 13488, 13489, 13491, 13492, 13497,
|
||||
13499, 13501, 13502, 13503, 13505, 13506, 13507, 13510,
|
||||
13511, 13514, 13517, 13521, 13522, 13524, 13525, 13527,
|
||||
13529, 13531, 13533, 13534, 13535, 13539, 13540, 13544,
|
||||
13546, 13547, 13552, 13553, 13554, 13562, 13565, 13570,
|
||||
13575, 13576, 13577, 13578, 13581, 13582, 13583, 13585,
|
||||
13587, 13589, 13591, 13592, 13593, 13597, 13598, 13600,
|
||||
13601, 13602, 13603, 13605, 13607, 13609, 13610, 13617,
|
||||
13619, 13620, 13624, 13625, 13631, 13634, 13637, 13640,
|
||||
13641, 13643, 13644, 13645, 13648, 13653, 13656, 13658,
|
||||
13659, 13661, 13662, 13669, 13670, 13671, 13672, 13674,
|
||||
13676, 13681, 13684, 13686, 13687, 13690, 13691, 13697,
|
||||
13698, 13700, 13702, 13704, 13708, 13710, 13711, 13713,
|
||||
13715, 13719, 13722, 13723, 13724, 13725, 13732, 13733,
|
||||
13734, 13735, 13741, 13742, 13744, 13746, 13747, 13748,
|
||||
13754, 13755, 13757, 13759, 13762, 13766, 13770, 13771,
|
||||
13772, 13774, 13778, 13780, 13781, 13783, 13784, 13785,
|
||||
13789, 13790, 13792, 13793, 13794, 13795, 13796, 13799,
|
||||
13801, 13803, 13804, 13806, 13808, 13810, 13811, 13817,
|
||||
13819, 13820, 13826, 13828, 13834, 13835, 13837, 13838,
|
||||
13839, 13841, 13842, 13844, 13845, 13846, 13854, 13855,
|
||||
13860, 13861, 13863, 13864, 13867, 13868, 13869, 13870,
|
||||
13872, 13876, 13879, 13881, 13884, 13888, 13890, 13895,
|
||||
13896, 13897, 13899, 13901, 13903, 13905, 13906, 13907,
|
||||
13913, 13915, 13918, 13920, 13921, 13923, 13924, 13929,
|
||||
13930, 13931, 13935, 13937, 13938, 13939, 13942, 13946,
|
||||
13948, 13949, 13950, 13951, 13953, 13959, 13961, 13962,
|
||||
13963, 13965, 13968, 13969, 13978, 13980, 13982, 13990,
|
||||
13991, 13992, 13994, 13995, 13996, 13998, 13999, 14000,
|
||||
14005, 14008, 14010, 14012, 14015, 14016, 14018, 14019,
|
||||
14025, 14027, 14028, 14031, 14032, 14034, 14035, 14036,
|
||||
14038, 14039, 14040, 14041, 14044, 14045, 14047, 14048,
|
||||
14049, 14050, 14051, 14052, 14055, 14056, 14058, 14063,
|
||||
14064, 14066, 14068, 14070, 14071, 14072, 14073, 14074,
|
||||
14078, 14083, 14084, 14085, 14089, 14090, 14091, 14093,
|
||||
14094, 14096, 14097, 14098, 14099, 14100, 14101, 14102,
|
||||
14106, 14109, 14110, 14111, 14119, 14120, 14121, 14122,
|
||||
14123, 14124, 14125, 14126, 14128, 14130, 14132, 14133,
|
||||
14134, 14136, 14137, 14138, 14140, 14143, 14144, 14146,
|
||||
14147, 14148, 14151, 14152, 14157, 14167, 14168, 14169,
|
||||
14171, 14173, 14177, 14179, 14181, 14184, 14185, 14188,
|
||||
14189, 14190, 14191, 14197, 14200, 14201, 14203, 14206,
|
||||
14208, 14211, 14212, 14213, 14216, 14218, 14220, 14222,
|
||||
14227, 14228, 14229, 14230, 14231, 14232, 14233, 14234,
|
||||
14235, 14237, 14239, 14243, 14245, 14247, 14248, 14252,
|
||||
14258, 14261, 14264, 14265, 14266, 14267, 14268, 14269,
|
||||
14271, 14275, 14277, 14278, 14280, 14281, 14282, 14283,
|
||||
14284, 14285, 14286, 14289, 14290, 14292, 14293, 14294,
|
||||
14296, 14297, 14302, 14307, 14309, 14310, 14311, 14314,
|
||||
14316, 14317, 14318, 14326, 14331, 14332, 14334, 14338,
|
||||
14341, 14343, 14346, 14348, 14349, 14350, 14352, 14353,
|
||||
14354, 14356, 14359, 14361, 14362, 14365, 14367, 14369,
|
||||
14370, 14371, 14373, 14376, 14377, 14382, 14384, 14386,
|
||||
14387, 14388, 14391, 14392, 14393, 14394, 14396, 14399,
|
||||
14400, 14401, 14403, 14404, 14405, 14407, 14409, 14410,
|
||||
14411, 14412, 14414, 14415, 14416, 14419, 14420, 14423,
|
||||
14424, 14426, 14427, 14429, 14431, 14433, 14434, 14436,
|
||||
14437, 14439, 14440, 14441, 14442, 14443, 14444, 14446,
|
||||
14449, 14455, 14457, 14458, 14460, 14461, 14464, 14468,
|
||||
14469, 14470, 14471, 14475, 14476, 14480, 14482, 14483,
|
||||
14485, 14486, 14488, 14492, 14495, 14496, 14497, 14498,
|
||||
14499, 14501, 14502, 14504, 14505, 14506, 14509, 14510,
|
||||
14511, 14514, 14516, 14517, 14518, 14519, 14521, 14526,
|
||||
14529, 14530, 14534, 14535, 14537, 14538, 14539, 14541,
|
||||
14543, 14544, 14545, 14546, 14551, 14552, 14555, 14558,
|
||||
14562, 14563, 14564, 14568, 14569, 14571, 14572, 14573,
|
||||
14575, 14578, 14579, 14580, 14581, 14584, 14586, 14590,
|
||||
14591, 14593, 14594, 14595, 14596, 14597, 14598, 14599,
|
||||
14600, 14603, 14606, 14609, 14611, 14613, 14617, 14619,
|
||||
14620, 14622, 14624, 14627, 14629, 14631, 14633, 14634,
|
||||
14635, 14637, 14640, 14644, 14645, 14647, 14648, 14652,
|
||||
14654, 14656, 14658, 14659, 14661, 14666, 14668, 14669,
|
||||
14671, 14673, 14677, 14680, 14681, 14682, 14686, 14688,
|
||||
14689, 14693, 14695, 14698, 14700, 14701, 14703, 14709,
|
||||
14711, 14714, 14715, 14716, 14717, 14718, 14719, 14722,
|
||||
14723, 14725, 14727, 14730, 14731, 14732, 14733, 14734,
|
||||
14735, 14736, 14739, 14741, 14743, 14750, 14753, 14754,
|
||||
14755, 14759, 14760, 14761, 14767, 14770, 14771, 14772,
|
||||
14773, 14777, 14781, 14782, 14783, 14788, 14789, 14790,
|
||||
14791, 14792, 14795, 14799, 14800, 14807, 14809, 14810,
|
||||
14813, 14814, 14817, 14819, 14820, 14822, 14823, 14824,
|
||||
14825, 14827, 14828, 14829, 14830, 14832, 14834, 14835,
|
||||
14837, 14838, 14840, 14841, 14843, 14844, 14845, 14848,
|
||||
14849, 14850, 14852, 14853, 14854, 14856, 14857, 14861,
|
||||
14864, 14867, 14868, 14872, 14873, 14874, 14881, 14884,
|
||||
14885, 14886, 14887, 14888, 14889, 14890, 14891, 14898,
|
||||
14899, 14900, 14905, 14906, 14910, 14912, 14915, 14916,
|
||||
14918, 14919, 14921, 14922, 14923, 14924, 14925, 14926,
|
||||
14929, 14931, 14932, 14933, 14934, 14935, 14937, 14939,
|
||||
14941, 14942, 14943, 14947, 14949, 14950, 14958, 14959,
|
||||
14960, 14964, 14967, 14968, 14969, 14970, 14972, 14973,
|
||||
14974, 14975, 14978, 14983, 14984, 14985, 14986, 14989,
|
||||
14991, 14992, 14994, 14997, 14999, 15000, 15002)
|
||||
|
||||
|
||||
class NotAPublicKey:
|
||||
_serial_bytes_length = 5
|
||||
_serial = 10000
|
||||
|
||||
_umbral_pubkey_from_bytes = UmbralPublicKey.from_bytes
|
||||
|
||||
@classmethod
|
||||
def tick(cls):
|
||||
cls._serial += 1
|
||||
while cls._serial in serials_which_produce_bytes_which_are_not_viable_as_a_pubkey:
|
||||
cls._serial += 1
|
||||
def _tick():
|
||||
for serial in good_serials:
|
||||
yield serial
|
||||
tick = _tick()
|
||||
|
||||
def __init__(self, serial=None):
|
||||
if serial is None:
|
||||
self.tick()
|
||||
self.serial = str(self._serial).encode()
|
||||
serial_int = next(self.tick)
|
||||
self.serial = serial_int.to_bytes(self._serial_bytes_length, byteorder="big")
|
||||
else:
|
||||
self.serial = serial
|
||||
|
||||
|
@ -386,12 +74,16 @@ class NotAPublicKey:
|
|||
|
||||
@classmethod
|
||||
def reset(cls):
|
||||
cls._serial = 10000
|
||||
cls.tick = cls._tick()
|
||||
|
||||
@classmethod
|
||||
def from_bytes(cls, some_bytes):
|
||||
return cls(serial=some_bytes[-5:])
|
||||
|
||||
@classmethod
|
||||
def from_int(cls, serial):
|
||||
return cls(serial.to_bytes(cls._serial_bytes_length, byteorder="big"))
|
||||
|
||||
def to_bytes(self, *args, **kwargs):
|
||||
return b"this is not a public key... but it is 64 bytes.. so, ya know" + self.serial
|
||||
|
||||
|
@ -555,5 +247,21 @@ def mock_pubkey_from_bytes(*args, **kwargs):
|
|||
yield
|
||||
NotAPublicKey.reset()
|
||||
|
||||
|
||||
mock_stamp_call = patch('nucypher.crypto.signing.SignatureStamp.__call__', new=NotAPrivateKey.stamp)
|
||||
mock_signature_bytes = patch('umbral.signing.Signature.__bytes__', new=NotAPrivateKey.signature_bytes)
|
||||
|
||||
|
||||
def _determine_good_serials(start, end):
|
||||
'''
|
||||
Figure out which serials are good to use in mocks because they won't result in non-viable public keys.
|
||||
'''
|
||||
good_serials = []
|
||||
for i in range(start, end):
|
||||
try:
|
||||
NotAPublicKey.from_int(i).i_want_to_be_a_real_boy()
|
||||
except Exception as e:
|
||||
continue
|
||||
else:
|
||||
good_serials.append(i)
|
||||
return good_serials
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue