예제 #1
0
파일: cli.py 프로젝트: doodoori2/nekoyume
def neko(private_key):
    app.app_context().push()
    while True:
        Block.sync()
        block = User(private_key).create_block(
            Move.query.filter_by(block=None).limit(20).all(),
            click=click,
        )
        if block:
            block.broadcast()
            click.echo(block)
예제 #2
0
def neko(private_key):
    app.app_context().push()
    Client(os.environ.get('SENTRY_DSN'))

    while True:
        Block.sync()
        block = User(private_key).create_block(
            [
                m for m in Move.query.filter_by(block=None).limit(20).all()
                if m.valid
            ],
            click=click,
        )
        if block:
            block.broadcast()
            click.echo(block)
예제 #3
0
def test_new_character_creation(fx_test_client, fx_session):
    fx_test_client.post('/login',
                        data={'private_key': 'test'},
                        follow_redirects=True)

    assert fx_session.query(Move).filter_by(user=User('test').address,
                                            name='create_novice').first()
예제 #4
0
def test_prevent_hack_and_slash_when_dead(
    fx_test_client: FlaskClient,
    fx_session: Session,
    fx_user: User,
    fx_private_key: PrivateKey,
    fx_novice_status: typing.Dict[str, str],
):
    move = fx_user.create_novice(fx_novice_status)
    Block.create(fx_user, [move])

    assert fx_user.avatar().dead is False
    while fx_user.avatar().hp > 0:
        move = fx_user.hack_and_slash()
        Block.create(fx_user, [move])
    assert fx_user.avatar().dead is True

    response = fx_test_client.post('/session_moves',
                                   data={'name': 'hack_and_slash'})
    assert response.status_code == 302
예제 #5
0
 def decorated_function(*args, **kwargs):
     private_key_hex = session.get('private_key')
     error = None
     if private_key_hex is not None:
         if private_key_hex.startswith(('0x', '0X')):
             private_key_hex = private_key_hex[2:]
         try:
             private_key_bytes = bytes.fromhex(private_key_hex)
             private_key = PrivateKey(private_key_bytes)
         except (ValueError, TypeError):
             error = 'invalid-private-key'
         else:
             g.user = User(private_key)
             return f(*args, **kwargs)
     return redirect(url_for('.get_login', next=request.url, error=error))
예제 #6
0
def fx_user2(fx_session):
    user = User('test2')
    user.session = fx_session
    return user
예제 #7
0
def fx_other_user(fx_other_session):
    user = User('other_test')
    user.session = fx_other_session
    return user
예제 #8
0
def fx_user(fx_session, fx_private_key: PrivateKey):
    user = User(fx_private_key)
    user.session = fx_session
    return user
예제 #9
0
def fx_other_user(fx_other_session):
    user = User(PrivateKey())
    user.session = fx_other_session
    return user
예제 #10
0
def fx_user2(fx_session):
    user = User(PrivateKey())
    user.session = fx_session
    return user
예제 #11
0
 def decorated_function(*args, **kwargs):
     if session.get('private_key') is None:
         return redirect(url_for('.get_login', next=request.url))
     else:
         g.user = User(session['private_key'])
     return f(*args, **kwargs)