Skip to content

Commit be80e88

Browse files
refactor: enforce single property requirement in blockchain test generation
1 parent 50ec823 commit be80e88

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ethereum_test_specs/benchmark.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ def generate_blocks_from_code_generator(self, fork: Fork) -> List[Block]:
174174

175175
def generate_blockchain_test(self, fork: Fork) -> BlockchainTest:
176176
"""Create a BlockchainTest from this BenchmarkTest."""
177+
set_props = [
178+
name
179+
for name, val in [
180+
("code_generator", self.code_generator),
181+
("blocks", self.blocks),
182+
("tx", self.tx),
183+
]
184+
if val is not None
185+
]
186+
187+
if len(set_props) != 1:
188+
raise ValueError(
189+
f"Exactly one must be set, but got {len(set_props)}: {', '.join(set_props)}"
190+
)
191+
177192
if self.code_generator is not None:
178193
generated_blocks = self.generate_blocks_from_code_generator(fork)
179194
return BlockchainTest.from_test(
@@ -183,7 +198,6 @@ def generate_blockchain_test(self, fork: Fork) -> BlockchainTest:
183198
post=self.post,
184199
blocks=generated_blocks,
185200
)
186-
187201
elif self.blocks is not None:
188202
return BlockchainTest.from_test(
189203
base_test=self,

0 commit comments

Comments
 (0)