Test Filler Plugin¶
Top-level pytest configuration file providing: - Command-line options, - Test-fixtures that can be used by all test cases, and that modifies pytest hooks in order to fill test specs for all tests and writes the generated fixtures to file.
fill_test(t8n, test_spec, fork, engine, spec, eips=None)
¶
Fills fixtures for the specified fork.
Source code in src/ethereum_test_tools/filling/fill.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
BlockchainTest
dataclass
¶
Bases: BaseTest
Filler type that tests multiple blocks (valid or invalid) in a chain.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
pytest_parameter_name()
classmethod
¶
Returns the parameter name used to identify this filler in a test.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
41 42 43 44 45 46 | |
make_genesis(t8n, fork)
¶
Create a genesis block from the state test definition.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
make_block(t8n, fork, block, previous_env, previous_alloc, previous_head, chain_id=1, eips=None)
¶
Produces a block based on the previous environment and allocation. If the block is an invalid block, the environment and allocation returned are the same as passed as parameters. Raises exception on invalid test behavior.
Returns¶
FixtureBlock: Block to be appended to the fixture.
Environment: Environment for the next block to produce.
If the produced block is invalid, this is exactly the same
environment as the one passed as parameter.
Dict[str, Any]: Allocation for the next block to produce.
If the produced block is invalid, this is exactly the same
allocation as the one passed as parameter.
str: Hash of the head of the chain, only updated if the produced
block is not invalid.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
make_blocks(t8n, genesis, fork, chain_id=1, eips=None)
¶
Create a block list from the blockchain test definition. Performs checks against the expected behavior of the test. Raises exception on invalid test behavior.
Source code in src/ethereum_test_tools/spec/blockchain_test.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
TransitionTool
¶
Transition tool abstract base class which should be inherited by all transition tool implementations.
Source code in src/evm_transition_tool/transition_tool.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
__init__(*, binary=None, trace=False)
abstractmethod
¶
Abstract initialization method that all subclasses must implement.
Source code in src/evm_transition_tool/transition_tool.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
__init_subclass__()
¶
Registers all subclasses of TransitionTool as possible tools.
Source code in src/evm_transition_tool/transition_tool.py
70 71 72 73 74 | |
register_tool(tool_subclass)
classmethod
¶
Registers a given subclass as tool option.
Source code in src/evm_transition_tool/transition_tool.py
76 77 78 79 80 81 | |
set_default_tool(tool_subclass)
classmethod
¶
Registers the default tool subclass.
Source code in src/evm_transition_tool/transition_tool.py
83 84 85 86 87 88 | |
from_binary_path(*, binary_path, **kwargs)
classmethod
¶
Instantiates the appropriate TransitionTool subclass derived from the tool's binary path.
Source code in src/evm_transition_tool/transition_tool.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
detect_binary(binary_output)
classmethod
¶
Returns True if the binary matches the tool
Source code in src/evm_transition_tool/transition_tool.py
129 130 131 132 133 134 135 136 | |
evaluate(alloc, txs, env, fork, chain_id=1, reward=0, eips=None)
abstractmethod
¶
Simulate a state transition with specified parameters
Source code in src/evm_transition_tool/transition_tool.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
version()
abstractmethod
¶
Return name and version of tool used to state transition
Source code in src/evm_transition_tool/transition_tool.py
154 155 156 157 158 159 | |
is_fork_supported(fork)
abstractmethod
¶
Returns True if the fork is supported by the tool
Source code in src/evm_transition_tool/transition_tool.py
161 162 163 164 165 166 | |
reset_traces()
¶
Resets the internal trace storage for a new test to begin
Source code in src/evm_transition_tool/transition_tool.py
168 169 170 171 172 | |
append_traces(new_traces)
¶
Appends a list of traces of a state transition to the current list
Source code in src/evm_transition_tool/transition_tool.py
174 175 176 177 178 179 180 | |
get_traces()
¶
Returns the accumulated traces
Source code in src/evm_transition_tool/transition_tool.py
182 183 184 185 186 | |
calc_state_root(alloc, fork)
¶
Calculate the state root for the given alloc.
Source code in src/evm_transition_tool/transition_tool.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
calc_withdrawals_root(withdrawals, fork)
¶
Calculate the state root for the given alloc.
Source code in src/evm_transition_tool/transition_tool.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
pytest_addoption(parser)
¶
Adds command-line options to pytest.
Source code in src/pytest_plugins/test_filler/test_filler.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
StateTest
dataclass
¶
Bases: BaseTest
Filler type that tests transactions over the period of a single block.
Source code in src/ethereum_test_tools/spec/state_test.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
pytest_parameter_name()
classmethod
¶
Returns the parameter name used to identify this filler in a test.
Source code in src/ethereum_test_tools/spec/state_test.py
46 47 48 49 50 51 | |
make_genesis(t8n, fork)
¶
Create a genesis block from the state test definition.
Source code in src/ethereum_test_tools/spec/state_test.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
make_blocks(t8n, genesis, fork, chain_id=1, eips=None)
¶
Create a block from the state test definition. Performs checks against the expected behavior of the test. Raises exception on invalid test behavior.
Source code in src/ethereum_test_tools/spec/state_test.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
Yul
¶
Bases: Code
Yul compiler. Compiles Yul source code into bytecode.
Source code in src/ethereum_test_tools/code/yul.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
assemble()
¶
Assembles using solc --assemble.
Source code in src/ethereum_test_tools/code/yul.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
version()
¶
Return solc's version string
Source code in src/ethereum_test_tools/code/yul.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
BaseTest
¶
Represents a base Ethereum test which must return a genesis and a blockchain.
Source code in src/ethereum_test_tools/spec/base_test.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
make_genesis(t8n, fork)
abstractmethod
¶
Create a genesis block from the test definition.
Source code in src/ethereum_test_tools/spec/base_test.py
80 81 82 83 84 85 86 87 88 89 | |
make_blocks(t8n, genesis, fork, chain_id=1, eips=None)
abstractmethod
¶
Generate the blockchain that must be executed sequentially during test.
Source code in src/ethereum_test_tools/spec/base_test.py
91 92 93 94 95 96 97 98 99 100 101 102 103 | |
pytest_parameter_name()
classmethod
abstractmethod
¶
Must return the name of the parameter used in pytest to select this spec type as filler for the test.
Source code in src/ethereum_test_tools/spec/base_test.py
105 106 107 108 109 110 111 112 | |
pytest_configure(config)
¶
Register the plugin's custom markers and process command-line options.
Custom marker registration: https://docs.pytest.org/en/7.1.x/how-to/writing_plugins.html#registering-custom-markers
Source code in src/pytest_plugins/test_filler/test_filler.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
EIPSpecTestItem
¶
Bases: Item
Custom pytest test item to test EIP spec versions.
Source code in src/pytest_plugins/spec_version_checker/spec_version_checker.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
from_parent(parent, module)
classmethod
¶
Public constructor to define new tests. https://docs.pytest.org/en/latest/reference/reference.html#pytest.nodes.Node.from_parent
Source code in src/pytest_plugins/spec_version_checker/spec_version_checker.py
120 121 122 123 124 125 126 | |
runtest()
¶
Define the test to execute for this item.
Source code in src/pytest_plugins/spec_version_checker/spec_version_checker.py
128 129 130 131 132 | |
reportinfo()
¶
Get location information for this test item to use test reports.
Source code in src/pytest_plugins/spec_version_checker/spec_version_checker.py
134 135 136 137 138 | |
pytest_report_header(config, start_path)
¶
Add lines to pytest's console output header
Source code in src/pytest_plugins/test_filler/test_filler.py
124 125 126 127 128 129 130 131 132 | |
evm_bin(request)
¶
Returns the configured evm tool binary path.
Source code in src/pytest_plugins/test_filler/test_filler.py
135 136 137 138 139 140 | |
solc_bin(request)
¶
Returns the configured solc binary path.
Source code in src/pytest_plugins/test_filler/test_filler.py
143 144 145 146 147 148 | |
t8n(request, evm_bin)
¶
Returns the configured transition tool.
Source code in src/pytest_plugins/test_filler/test_filler.py
151 152 153 154 155 156 157 158 | |
strip_test_prefix(name)
¶
Removes the test prefix from a test case name.
Source code in src/pytest_plugins/test_filler/test_filler.py
161 162 163 164 165 166 167 168 | |
FixtureCollector
¶
Collects all fixtures generated by the test cases.
Source code in src/pytest_plugins/test_filler/test_filler.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
add_fixture(item, fixture)
¶
Adds a fixture to the list of fixtures of a given test case.
Source code in src/pytest_plugins/test_filler/test_filler.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
dump_fixtures()
¶
Dumps all collected fixtures to their respective files.
Source code in src/pytest_plugins/test_filler/test_filler.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
fixture_collector(request)
¶
Returns the configured fixture collector instance used for all tests in one test module.
Source code in src/pytest_plugins/test_filler/test_filler.py
241 242 243 244 245 246 247 248 249 250 251 252 | |
engine()
¶
Returns the sealEngine used in the generated test fixtures.
Source code in src/pytest_plugins/test_filler/test_filler.py
255 256 257 258 259 260 | |
filler_path(request)
¶
Returns the directory containing the tests to execute.
Source code in src/pytest_plugins/test_filler/test_filler.py
263 264 265 266 267 268 | |
eips()
¶
A fixture specifying that, by default, no EIPs should be activated for tests.
This fixture (function) may be redefined in test filler modules in order to overwrite this default and return a list of integers specifying which EIPs should be activated for the tests in scope.
Source code in src/pytest_plugins/test_filler/test_filler.py
271 272 273 274 275 276 277 278 279 280 281 | |
yul(fork, request)
¶
A fixture that allows contract code to be defined with Yul code.
This fixture defines a class that wraps the ::ethereum_test_tools.Yul class so that upon instantiation within the test case, it provides the test case's current fork parameter. The forks is then available for use in solc's arguments for the Yul code compilation.
Test cases can override the default value by specifying a fixed version with the @pytest.mark.compile_yul_with(FORK) marker.
Source code in src/pytest_plugins/test_filler/test_filler.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
state_test(request, t8n, fork, engine, reference_spec, eips, fixture_collector)
¶
Fixture used to instantiate an auto-fillable StateTest object from within a test function.
Every test that defines a StateTest filler must explicitly specify this fixture in its function arguments and set the StateTestWrapper's spec property.
Implementation detail: It must be scoped on test function level to avoid leakage between tests.
Source code in src/pytest_plugins/test_filler/test_filler.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
blockchain_test(request, t8n, fork, engine, reference_spec, eips, fixture_collector)
¶
Fixture used to define an auto-fillable BlockchainTest analogous to the state_test fixture for StateTests. See the state_test fixture docstring for details.
Source code in src/pytest_plugins/test_filler/test_filler.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
pytest_collection_modifyitems(items, config)
¶
A pytest hook called during collection, after all items have been collected.
Here we dynamically apply "state_test" or "blockchain_test" markers to a test if the test function uses the corresponding fixture.
Source code in src/pytest_plugins/test_filler/test_filler.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
pytest_make_parametrize_id(config, val, argname)
¶
Pytest hook called when generating test ids. We use this to generate more readable test ids for the generated tests.
Source code in src/pytest_plugins/test_filler/test_filler.py
400 401 402 403 404 405 | |
pytest_runtest_call(item)
¶
Pytest hook called in the context of test execution.
Source code in src/pytest_plugins/test_filler/test_filler.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
Fixture
dataclass
¶
Cross-client compatible Ethereum test fixture.
Source code in src/ethereum_test_tools/common/types.py
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 | |
__post_init__()
¶
Post init hook to convert to JSON after instantiation.
Source code in src/ethereum_test_tools/common/types.py
1513 1514 1515 1516 1517 | |
fill_info(t8n, ref_spec)
¶
Fill the info field for this fixture
Source code in src/ethereum_test_tools/common/types.py
1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 | |
JSONEncoder
¶
Bases: json.JSONEncoder
Custom JSON encoder for ethereum_test types.
Source code in src/ethereum_test_tools/common/types.py
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 | |
default(obj)
¶
Enocdes types defined in this module using basic python facilities.
Source code in src/ethereum_test_tools/common/types.py
1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 | |