mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
compile
This commit is contained in:
1
src/test/app/.env
Normal file
1
src/test/app/.env
Normal file
@@ -0,0 +1 @@
|
||||
HOOKS_COMPILE_HOST=http://localhost:9000
|
||||
@@ -32,7 +32,7 @@ namespace ripple {
|
||||
|
||||
namespace test {
|
||||
|
||||
class SetHook_test : public beast::unit_test::suite
|
||||
class SetHookV3_test : public beast::unit_test::suite
|
||||
{
|
||||
private:
|
||||
// helper
|
||||
@@ -50,13 +50,12 @@ public:
|
||||
std::string
|
||||
loadHook()
|
||||
{
|
||||
std::string name = "/Users/darkmatter/projects/ledger-works/xahaud/src/test/app/base.wasm";
|
||||
std::string name = "/Users/darkmatter/projects/ledger-works/xahaud/src/test/app/wasm/custom.wasm";
|
||||
if (!std::filesystem::exists(name)) {
|
||||
std::cout << "File does not exist: " << name << "\n";
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
std::ifstream hookFile(name, std::ios::binary);
|
||||
|
||||
if (!hookFile)
|
||||
@@ -100,6 +99,7 @@ public:
|
||||
env.close();
|
||||
|
||||
std::string hook = loadHook();
|
||||
std::cout << "Hook: " << hook << "\n";
|
||||
|
||||
// install the hook on alice
|
||||
env(ripple::test::jtx::hook(alice, {{hso(hook, overrideFlag)}}, 0),
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
void
|
||||
testWithFeatures(FeatureBitset features)
|
||||
{
|
||||
testSimple(sa);
|
||||
testSimple(features);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
10
src/test/app/contracts/base.c
Normal file
10
src/test/app/contracts/base.c
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
#include "hookapi.h"
|
||||
|
||||
int64_t hook(uint32_t reserved) {
|
||||
TRACESTR("Base.c: Called.");
|
||||
_g(1,1);
|
||||
return accept(SBUF("base: Finished."), __LINE__);;
|
||||
}
|
||||
@@ -9,16 +9,12 @@
|
||||
// #define GUARD(maxiter) _g((1ULL << 31U) + __LINE__, (maxiter)+1)
|
||||
// #define GUARDM(maxiter, n) _g(( (1ULL << 31U) + (__LINE__ << 16) + n), (maxiter)+1)
|
||||
|
||||
// int64_t methodCreate(uint32_t reserved) {
|
||||
// TRACESTR("somefunc.c: Called.");
|
||||
// for (int i = 0; GUARD(10), i < 10; i++) {
|
||||
// TRACESTR("somefunc.c: Iterating.");
|
||||
// }
|
||||
// return accept(SBUF("somefunc.c: Finished."), __LINE__);
|
||||
// }
|
||||
// hooks-cli compile-c contracts/custom.c build
|
||||
|
||||
int64_t hook(uint32_t reserved) {
|
||||
TRACESTR("Base.c: Called.");
|
||||
_g(1,1);
|
||||
return accept(SBUF("base.c: Finished."), __LINE__);;
|
||||
int64_t methodCreate(uint32_t reserved) {
|
||||
TRACESTR("somefunc.c: Called.");
|
||||
for (int i = 0; GUARD(10), i < 10; i++) {
|
||||
TRACESTR("somefunc.c: Iterating.");
|
||||
}
|
||||
return accept(SBUF("somefunc.c: Finished."), __LINE__);
|
||||
}
|
||||
Reference in New Issue
Block a user