Skip to content

Commit

Permalink
test: update multicall test
Browse files Browse the repository at this point in the history
  • Loading branch information
banteg committed Apr 3, 2024
1 parent ad49b70 commit 88b72cd
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/functional/test_multicall.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
from typing import List
from typing import NamedTuple

import pytest
from eth_pydantic_types import HexBytes
from ethpm_types import ContractType

from ape.exceptions import APINotImplementedError
from ape_ethereum.multicall import Call
from ape_ethereum.multicall.constants import MULTICALL3_ADDRESS, MULTICALL3_CONTRACT_TYPE
from ape_ethereum.multicall.constants import (
MULTICALL3_ADDRESS,
MULTICALL3_CONTRACT_TYPE,
)
from ape_ethereum.multicall.exceptions import UnsupportedChainError

RETURNDATA = HexBytes("0x4a821464")


class ReturndataClass:
returnData: List[HexBytes] = [RETURNDATA]
class ReturnData(NamedTuple):
success: bool
returnData: bytes


RETURNDATA_PARAMS = {
"result": ReturndataClass(),
# Happens when using Call() for a single call.
"result_single": [False, RETURNDATA],
"result_ok": (ReturnData(True, RETURNDATA), RETURNDATA),
"result_fail": (ReturnData(False, RETURNDATA), None),
}


Expand Down Expand Up @@ -53,7 +56,10 @@ def test_unsupported_chain(call_handler_with_struct_input, struct_input_for_call


def test_aggregate3_input(
aggregate3, call_handler_with_struct_input, struct_input_for_call, vyper_contract_instance
aggregate3,
call_handler_with_struct_input,
struct_input_for_call,
vyper_contract_instance,
):
call = Call()

Expand All @@ -67,7 +73,7 @@ def test_aggregate3_input(

@pytest.mark.parametrize("returndata_key", RETURNDATA_PARAMS)
def test_returndata(returndata_key):
returndata = RETURNDATA_PARAMS[returndata_key]
result, output = RETURNDATA_PARAMS[returndata_key]
call = Call()
call._result = returndata # type: ignore
assert call.returnData[0] == HexBytes("0x4a821464")
call._result = [result] # type: ignore
assert call.returnData[0] == output

0 comments on commit 88b72cd

Please sign in to comment.