def test_get_unconfirmed_move(fx_session, fx_user, fx_novice_status): assert not get_unconfirmed_move(fx_user.address) move = fx_user.create_novice(fx_novice_status) assert get_unconfirmed_move(fx_user.address) # invalid move should not be recognized as unconfirmed move move.id = ('00000000000000000000000000000000' '00000000000000000000000000000000') assert not get_unconfirmed_move(fx_user.address)
def test_post_move_broadcasting( fx_test_client: FlaskClient, fx_user: User, fx_private_key: PrivateKey, fx_session: scoped_session, ): with unittest.mock.patch('nekoyume.game.multicast') as m: fx_test_client.post('/login', data={ 'private_key': fx_private_key.to_hex(), 'name': 'test_user', }, follow_redirects=True) fx_test_client.post('/new') Block.create(fx_user, fx_session.query(Move).filter_by(block_id=None).all()) assert not get_unconfirmed_move(fx_user.address) res = fx_test_client.post('/session_moves', data={'name': 'hack_and_slash'}) assert res.status_code == 302 move = fx_session.query(Move).filter( Move.name == 'hack_and_slash', ).first() assert move serialized = move.serialize( use_bencode=False, include_signature=True, include_id=True, ) assert m.called args = m.call_args[1] assert serialized == args['serialized'] my_node = args['my_node'] assert isinstance(my_node, Node) assert my_node.url == 'http://localhost' broadcast = args['broadcast'] assert isinstance(broadcast, typing.Callable) assert broadcast.__name__ == 'broadcast_move'