From 374563bbe57588eb224e93026d9fee12809d2190 Mon Sep 17 00:00:00 2001 From: xermicus Date: Mon, 10 Feb 2025 18:50:12 +0100 Subject: [PATCH] integration: add function pointer integration test (#205) Signed-off-by: Cyrill Leutwiler --- .../integration/contracts/FunctionPointer.sol | 42 +++++++++++++++++++ crates/integration/src/tests.rs | 1 + 2 files changed, 43 insertions(+) create mode 100644 crates/integration/contracts/FunctionPointer.sol diff --git a/crates/integration/contracts/FunctionPointer.sol b/crates/integration/contracts/FunctionPointer.sol new file mode 100644 index 0000000..fbf18d1 --- /dev/null +++ b/crates/integration/contracts/FunctionPointer.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8; + +/* runner.json +{ + "differential": true, + "actions": [ + { + "Instantiate": { + "code": { + "Solidity": { + "contract": "FunctionPointer" + } + } + } + }, + { + "Call": { + "dest": { + "Instantiated": 0 + }, + "data": "26121ff0" + } + } + ] +} +*/ + +contract FunctionPointer { + bool public flag = false; + + function f0() public { + flag = true; + } + + function f() public returns (bool) { + function() internal x = f0; + x(); + return flag; + } +} diff --git a/crates/integration/src/tests.rs b/crates/integration/src/tests.rs index 2863f88..ed874ea 100644 --- a/crates/integration/src/tests.rs +++ b/crates/integration/src/tests.rs @@ -54,6 +54,7 @@ test_spec!(coinbase, "Coinbase", "Coinbase.sol"); test_spec!(create2, "CreateB", "Create2.sol"); test_spec!(transfer, "Transfer", "Transfer.sol"); test_spec!(send, "Send", "Send.sol"); +test_spec!(function_pointer, "FunctionPointer", "FunctionPointer.sol"); fn instantiate(path: &str, contract: &str) -> Vec { vec![Instantiate {