def user1(): with sock(HOST, PORT) as s: force_login(s, 'a') sleep(0.5) send(s, "challenge", {'other_username': '******'}) sleep(0.5) # wait to accept recv(s) # recieve begin_match
def user1(): with sock(HOST, PORT) as s: force_login(s, 'a') sleep(0.2) # wait for the other user to conect send(s, "challenge", {'other_username': '******'}) recv(s) # recive fail response send(s, "challenge", {'other_username': '******'}) recv(s) # challenge refused send(s, "challenge", {'other_username': '******'}) recv(s) # match_begin
def user2(): with sock(HOST, PORT) as s: force_login(s, 'b') r = recv(s) # recieve challenge send(s, 'accept_challenge', {'id': 10000}) # accept fake challenge recv(s) # recive fail response send(s, 'refuse_challenge', {'id': r[1]['challenge_id']}) # refuse real challenge r = recv(s) # recieve challenge send(s, 'accept_challenge', {'id': r[1]['challenge_id']}) # refuse real challenge recv(s) # match_begin
def user2(): with sock(HOST, PORT) as s: force_login(s, 'b') r = recv(s) # recieve challenge send(s, 'accept_challenge', {'id': r[1]['challenge_id']}) recv(s) # recieve begin_match