mirror of
https://github.com/Xahau/xahaud.git
synced 2026-08-23 08:20:52 +00:00
fix(hooks): report exports separately from emits
This commit is contained in:
@@ -485,7 +485,7 @@ struct Export_test : public beast::unit_test::suite
|
||||
json(jss::HookParameters, params),
|
||||
ter(tesSUCCESS));
|
||||
|
||||
// Verify hook fired successfully with exactly 1 emission.
|
||||
// Verify hook fired successfully with exactly 1 export.
|
||||
{
|
||||
auto const m = env.meta();
|
||||
BEAST_EXPECT(m);
|
||||
@@ -496,12 +496,14 @@ struct Export_test : public beast::unit_test::suite
|
||||
|
||||
// result=3 is ExitType::ACCEPT
|
||||
BEAST_EXPECT(execs[0].getFieldU8(sfHookResult) == 3);
|
||||
BEAST_EXPECT(execs[0].getFieldU16(sfHookEmitCount) == 1);
|
||||
BEAST_EXPECT(execs[0].getFieldU16(sfHookEmitCount) == 0);
|
||||
BEAST_EXPECT(execs[0].getFieldU16(sfHookExportCount) == 1);
|
||||
BEAST_EXPECT(execs[0].getFieldU64(sfHookReturnCode) == 0);
|
||||
|
||||
// Emissions metadata should be present.
|
||||
BEAST_EXPECT(m->isFieldPresent(sfHookEmissions));
|
||||
BEAST_EXPECT(m->getFieldArray(sfHookEmissions).size() == 1);
|
||||
// HookEmissions tracks normal emitted transactions. Export wrappers
|
||||
// use the emitted directory for scheduling but are counted
|
||||
// separately as HookExportCount.
|
||||
BEAST_EXPECT(!m->isFieldPresent(sfHookEmissions));
|
||||
|
||||
// The emitted dir should NOT be empty (ttEXPORT is in it).
|
||||
BEAST_EXPECT(!dirIsEmpty(*env.current(), keylet::emittedDir()));
|
||||
|
||||
@@ -1533,8 +1533,12 @@ hook::finalizeHookResult(
|
||||
.getField(sfEmitDetails)
|
||||
.downcast<STObject>();
|
||||
|
||||
emission_txnid.emplace_back(
|
||||
id, emitDetails.getFieldH256(sfEmitNonce));
|
||||
if (ptr->getTxnType() == ttEXPORT)
|
||||
exported_txnid.emplace_back(id);
|
||||
else
|
||||
emission_txnid.emplace_back(
|
||||
id, emitDetails.getFieldH256(sfEmitNonce));
|
||||
|
||||
sleEmitted = std::make_shared<SLE>(emittedId);
|
||||
|
||||
// RH TODO: add a new constructor to STObject to avoid this
|
||||
|
||||
Reference in New Issue
Block a user