Beispiel #1
0
def test_combine_argument_formatters(formatters, value, expected):
    list_formatter = eth_utils.combine_argument_formatters(*formatters)
    if isinstance(expected, type) and issubclass(expected, Exception):
        with pytest.raises(expected):
            list_formatter(value)
    else:
        assert list_formatter(value) == expected
Beispiel #2
0
)
import cytoolz.curried
import eth_utils.curried


environment_formatter = eth_utils.curried.apply_formatters_to_dict({
    "currentCoinbase": to_checksum_address,
    "previousHash": encode_hex,
    "currentNumber": to_hex,
    "currentDifficulty": to_hex,
    "currentGasLimit": to_hex,
    "currentTimestamp": to_hex,
})


storage_item_formatter = combine_argument_formatters(to_hex, to_hex)
storage_formatter = cytoolz.curried.itemmap(storage_item_formatter)


account_state_formatter = eth_utils.curried.apply_formatters_to_dict({
    "balance": to_hex,
    "nonce": to_hex,
    "code": encode_hex,
    "storage": storage_formatter,
})


state_item_formatter = combine_argument_formatters(to_checksum_address, account_state_formatter)
state_formatter = cytoolz.curried.itemmap(state_item_formatter)