# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class NoScriptError(ResponseError):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x


import asyncio
import pytest
from aredis.exceptions import RedisClusterException, NoScriptError, ResponseError
from aredis.utils import b
        # 2 * 3 == 6
        assert await r.eval(multiply_script, 1, 'a', 3) == 6

    @pytest.mark.asyncio()
    async def test_eval_same_slot(self, r):
        await r.set('A{foo}', 2)
        await r.set('B{foo}', 4)
        # 2 * 4 == 8

        script = """
        local value = redis.call('GET', KEYS[1])
        local value2 = redis.call('GET', KEYS[2])
        return value * value2
        """
        result = await r.eval(script, 2, 'A{foo}', 'B{foo}')
        assert result == 8

    @pytest.mark.asyncio()
    async def test_eval_crossslot(self, r):
        """
        This test assumes that {foo} and {bar} will not go to the same
        server when used. In 3 masters + 3 slaves config this should pass.
        """
        await r.set('A{foo}', 2)
        await r.set('B{bar}', 4)
        # 2 * 4 == 8

        script = """
        local value = redis.call('GET', KEYS[1])
        local value2 = redis.call('GET', KEYS[2])

# Path: aredis/exceptions.py
# class RedisClusterException(Exception):
#     pass
# 
# class NoScriptError(ResponseError):
#     pass
# 
# class ResponseError(RedisError):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x


# Path: tests/cluster/test_scripting.py
import asyncio
import pytest
from aredis.exceptions import RedisClusterException, NoScriptError, ResponseError
from aredis.utils import b

        # 2 * 3 == 6
        assert await r.eval(multiply_script, 1, 'a', 3) == 6

    @pytest.mark.asyncio()
    async def test_eval_same_slot(self, r):
        await r.set('A{foo}', 2)
        await r.set('B{foo}', 4)
        # 2 * 4 == 8

        script = """
        local value = redis.call('GET', KEYS[1])
        local value2 = redis.call('GET', KEYS[2])
        return value * value2
        """
        result = await r.eval(script, 2, 'A{foo}', 'B{foo}')
        assert result == 8

    @pytest.mark.asyncio()
    async def test_eval_crossslot(self, r):
        """
        This test assumes that {foo} and {bar} will not go to the same
        server when used. In 3 masters + 3 slaves config this should pass.
        """
        await r.set('A{foo}', 2)
        await r.set('B{bar}', 4)
        # 2 * 4 == 8

        script = """
        local value = redis.call('GET', KEYS[1])
        local value2 = redis.call('GET', KEYS[2])

        return value * value2