diff --git a/src/test/jtx/hook.h b/src/test/jtx/hook.h index 6bad339cc..c9713cdcf 100644 --- a/src/test/jtx/hook.h +++ b/src/test/jtx/hook.h @@ -37,6 +37,10 @@ hook( Json::Value hso(std::vector const& wasmBytes, void (*f)(Json::Value& jv) = 0); +Json::Value +hso(std::vector const& wasmBytes, uint16_t apiVersion, void (*f)(Json::Value& jv) = 0); + + Json::Value hso(std::string const& wasmHex, void (*f)(Json::Value& jv) = 0); diff --git a/src/test/jtx/impl/hook.cpp b/src/test/jtx/impl/hook.cpp index 08067a2a2..e5cbafc09 100644 --- a/src/test/jtx/impl/hook.cpp +++ b/src/test/jtx/impl/hook.cpp @@ -81,6 +81,27 @@ hso(std::vector const& wasmBytes, void (*f)(Json::Value& jv)) return jv; } +Json::Value +hso(std::vector const& wasmBytes, uint16_t apiVersion = 0, void (*f)(Json::Value& jv)) +{ + if (wasmBytes.size() == 0) + throw std::runtime_error("empty hook wasm passed to hso()"); + + Json::Value jv; + jv[jss::CreateCode] = strHex(wasmBytes); + { + jv[jss::HookOn] = + "0000000000000000000000000000000000000000000000000000000000000000"; + jv[jss::HookNamespace] = to_string(uint256{beast::zero}); + jv[jss::HookApiVersion] = Json::Value{apiVersion}; + } + + if (f) + f(jv); + + return jv; +} + Json::Value hso(std::string const& wasmHex, void (*f)(Json::Value& jv)) {