increase size of hook state to 256 bytes, parameters too, change the reserve requirement to 1:1 for hook state, allow weak execution on rollback if hook_again was specified, add further state_set tests

This commit is contained in:
Richard Holland
2022-12-11 13:03:08 +00:00
parent 90949b8a59
commit e4aa7db5cb
7 changed files with 159 additions and 22 deletions

View File

@@ -21,6 +21,7 @@
#include <ripple/protocol/jss.h>
#include <stdexcept>
#include <test/jtx/hook.h>
#include <ripple/app/hook/Enum.h>
namespace ripple {
namespace test {
@@ -65,9 +66,23 @@ std::string uint64_hex(uint64_t x)
nibble(x >> 4U) + nibble(x >> 0U);
}
Json::Value
hso_delete(void (*f)(Json::Value& jv))
{
Json::Value jv;
jv[jss::CreateCode] = "";
jv[jss::Flags] = hsfOVERRIDE;
if (f)
f(jv);
return jv;
}
Json::Value
hso(std::vector<uint8_t> const& wasmBytes, void (*f)(Json::Value& jv))
{
if (wasmBytes.size() == 0)
throw std::runtime_error("empty hook wasm passed to hso()");
@@ -78,12 +93,12 @@ hso(std::vector<uint8_t> const& wasmBytes, void (*f)(Json::Value& jv))
jv[jss::HookNamespace] = to_string(uint256{beast::zero});
jv[jss::HookApiVersion] = Json::Value{0};
}
if (f)
if (f)
f(jv);
return jv;
}
} // namespace jtx