Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mythril/tests/analysis/abi_decode_test.py

57 lines
2.7 KiB

import pytest
from mythril.analysis.report import Issue
from mythril.disassembler.disassembly import Disassembly
from mythril.laser.ethereum.state.environment import Environment
from mythril.laser.ethereum.state.account import Account
from mythril.laser.ethereum.state.machine_state import MachineState
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.state.world_state import WorldState
from mythril.laser.ethereum.instructions import Instruction
from mythril.laser.ethereum.transaction.transaction_models import MessageCallTransaction
from mythril.laser.smt import symbol_factory, simplify, LShR
test_data = (
(
"0xa9059cbb000000000000000000000000010801010101010120020101020401010408040402",
"func(uint256,uint256)",
(
5887484186314823854737699484601117092168074244,
904625697166532776746648320380374280103671755200316906558262375061821325312,
),
),
(
"0xa9059cbb00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002",
"func(uint256,uint256)",
(2, 2),
),
(
"0xa0cce1b3000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
"func(bytes32,(bytes32,bytes32,uint8,uint8)[],(address[],uint32))",
(
"0000000000000000000000000000000000000000000000000000000000000002",
(
(
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000090",
0,
0,
),
(
"0000000000000000000000000000005000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
1,
0,
),
),
(("0x0000000000000000000000000000000000000000",), 0),
),
),
)
@pytest.mark.parametrize("call_data, signature, expected", test_data)
def test_abi_decode(call_data, signature, expected):
assert Issue.resolve_input(call_data, signature) == expected