From cb8175fd15fe03f8906a5af11cc582e3069d53d2 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Mon, 8 Jan 2024 08:40:54 +0100 Subject: [PATCH] Add check to validate that a Suave node is running (#22) --- src/Test.sol | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Test.sol b/src/Test.sol index 954a387..f665643 100644 --- a/src/Test.sol +++ b/src/Test.sol @@ -6,12 +6,17 @@ import "forge-std/Test.sol"; contract SuaveEnabled is Test { function setUp() public { - string[] memory inputs = new string[](2); + string[] memory inputs = new string[](3); inputs[0] = "suave"; inputs[1] = "forge"; + inputs[2] = "status"; - try vm.ffi(inputs) returns (bytes memory) {} - catch (bytes memory reason) { + try vm.ffi(inputs) returns (bytes memory response) { + // the prefix is 'not-ok' + if (isPrefix(hex"6e6f742d6f6b", response)) { + revert("Local Suave node not detected running"); + } + } catch (bytes memory reason) { revert(detectFFIErrorMessage(reason)); }