mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
sethook structure testing done, move on to hook api testing
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,11 @@ cat SetHook_test.cpp | tr '\n' '\f' |
|
||||
xxd -p -u -c 19 |
|
||||
sed -E 's/../0x\0U,/g' | sed -E 's/^/ /g' >> SetHook_wasm.h
|
||||
fi
|
||||
if [ "$?" -gt "0" ]
|
||||
then
|
||||
echo "Compilation error ^"
|
||||
exit 1
|
||||
fi
|
||||
echo '}},' >> SetHook_wasm.h
|
||||
echo >> SetHook_wasm.h
|
||||
COUNTER=`echo $COUNTER + 1 | bc`
|
||||
|
||||
@@ -32,7 +32,7 @@ Json::Value
|
||||
hook(Account const& account, std::optional<std::vector<Json::Value>> hooks, std::uint32_t flags);
|
||||
|
||||
Json::Value
|
||||
hso(std::vector<uint8_t> const& wasmBytes, uint64_t hookOn = 0, uint256 ns = beast::zero, uint8_t apiversion = 0);
|
||||
hso(std::vector<uint8_t> const& wasmBytes, void (*f)(Json::Value& jv) = 0);
|
||||
|
||||
std::string uint64_hex(uint64_t x);
|
||||
|
||||
|
||||
@@ -66,16 +66,22 @@ std::string uint64_hex(uint64_t x)
|
||||
}
|
||||
|
||||
Json::Value
|
||||
hso(std::vector<uint8_t> const& wasmBytes, uint64_t hookOn, uint256 ns, uint8_t apiversion)
|
||||
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()");
|
||||
|
||||
Json::Value jv;
|
||||
jv[jss::CreateCode] = strHex(wasmBytes);
|
||||
jv[jss::HookOn] = uint64_hex(hookOn);
|
||||
jv[jss::HookNamespace] = to_string(ns);
|
||||
jv[jss::HookApiVersion] = Json::Value{apiversion};
|
||||
{
|
||||
jv[jss::HookOn] = uint64_hex(0);
|
||||
jv[jss::HookNamespace] = to_string(uint256{beast::zero});
|
||||
jv[jss::HookApiVersion] = Json::Value{0};
|
||||
}
|
||||
|
||||
|
||||
if (f)
|
||||
f(jv);
|
||||
|
||||
return jv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user