From 00e7161bef37e5758982f41b788edda39d09ef12 Mon Sep 17 00:00:00 2001 From: David Meister Date: Sat, 27 Jun 2026 05:29:15 +0000 Subject: [PATCH] refactor(test): extract _buildFlowStack helper to DRY duplicate stack builders Co-Authored-By: Claude --- test/abstract/FlowTest.sol | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/abstract/FlowTest.sol b/test/abstract/FlowTest.sol index 392b308c..2d3b59f8 100644 --- a/test/abstract/FlowTest.sol +++ b/test/abstract/FlowTest.sol @@ -119,14 +119,18 @@ abstract contract FlowTest is FlowTransferOperation, InterpreterMockTest { vm.assume(account != address(0x000000000000000000636F6e736F6c652e6c6f67)); } + function _buildFlowStack(FlowTransferV1 memory transfer) private pure returns (uint256[] memory, bytes32) { + bytes32 transferHash = keccak256(abi.encode(transfer)); + uint256[] memory stack = Sentinel.unwrap(RAIN_FLOW_SENTINEL).generateFlowStack(transfer); + return (stack, transferHash); + } + function burnFlowStack(address, uint256, uint256, FlowTransferV1 memory transfer) internal pure returns (uint256[] memory, bytes32) { - bytes32 transferHash = keccak256(abi.encode(transfer)); - uint256[] memory stack = Sentinel.unwrap(RAIN_FLOW_SENTINEL).generateFlowStack(transfer); - return (stack, transferHash); + return _buildFlowStack(transfer); } function mintFlowStack(address, uint256, uint256, FlowTransferV1 memory transfer) @@ -134,9 +138,7 @@ abstract contract FlowTest is FlowTransferOperation, InterpreterMockTest { pure returns (uint256[] memory, bytes32) { - bytes32 transferHash = keccak256(abi.encode(transfer)); - uint256[] memory stack = Sentinel.unwrap(RAIN_FLOW_SENTINEL).generateFlowStack(transfer); - return (stack, transferHash); + return _buildFlowStack(transfer); } function buildConfig(string memory, string memory, string memory, address, EvaluableConfigV3[] memory flowConfig) @@ -179,8 +181,6 @@ abstract contract FlowTest is FlowTransferOperation, InterpreterMockTest { pure returns (uint256[] memory, bytes32) { - bytes32 transferHash = keccak256(abi.encode(transfer)); - uint256[] memory stack = Sentinel.unwrap(RAIN_FLOW_SENTINEL).generateFlowStack(transfer); - return (stack, transferHash); + return _buildFlowStack(transfer); } }