mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
HF cost for smart escrow (#6097)
This commit is contained in:
@@ -390,7 +390,7 @@ struct EscrowSmart_test : public beast::unit_test::suite
|
|||||||
// Tests whether the ledger index is >= 5
|
// Tests whether the ledger index is >= 5
|
||||||
// getLedgerSqn() >= 5}
|
// getLedgerSqn() >= 5}
|
||||||
auto const& wasmHex = ledgerSqnWasmHex;
|
auto const& wasmHex = ledgerSqnWasmHex;
|
||||||
std::uint32_t const allowance = 5;
|
std::uint32_t const allowance = 65;
|
||||||
auto escrowCreate = escrow::create(alice, carol, XRP(1000));
|
auto escrowCreate = escrow::create(alice, carol, XRP(1000));
|
||||||
auto [createFee, finishFee] = [&]() {
|
auto [createFee, finishFee] = [&]() {
|
||||||
Env env(*this, features);
|
Env env(*this, features);
|
||||||
@@ -683,7 +683,7 @@ struct EscrowSmart_test : public beast::unit_test::suite
|
|||||||
{
|
{
|
||||||
env.require(balance(alice, XRP(4000) - txnFees));
|
env.require(balance(alice, XRP(4000) - txnFees));
|
||||||
|
|
||||||
auto const allowance = 14;
|
auto const allowance = 1014;
|
||||||
XRPAmount const finishFee = env.current()->fees().base +
|
XRPAmount const finishFee = env.current()->fees().base +
|
||||||
(allowance * env.current()->fees().gasPrice) /
|
(allowance * env.current()->fees().gasPrice) /
|
||||||
MICRO_DROPS_PER_DROP +
|
MICRO_DROPS_PER_DROP +
|
||||||
@@ -778,7 +778,7 @@ struct EscrowSmart_test : public beast::unit_test::suite
|
|||||||
auto const txMeta = env.meta();
|
auto const txMeta = env.meta();
|
||||||
if (BEAST_EXPECT(txMeta && txMeta->isFieldPresent(sfGasUsed)))
|
if (BEAST_EXPECT(txMeta && txMeta->isFieldPresent(sfGasUsed)))
|
||||||
BEAST_EXPECTS(
|
BEAST_EXPECTS(
|
||||||
txMeta->getFieldU32(sfGasUsed) == 794,
|
txMeta->getFieldU32(sfGasUsed) == 38'554,
|
||||||
std::to_string(txMeta->getFieldU32(sfGasUsed)));
|
std::to_string(txMeta->getFieldU32(sfGasUsed)));
|
||||||
if (BEAST_EXPECT(txMeta->isFieldPresent(sfWasmReturnCode)))
|
if (BEAST_EXPECT(txMeta->isFieldPresent(sfWasmReturnCode)))
|
||||||
BEAST_EXPECT(txMeta->getFieldI32(sfWasmReturnCode) == 1);
|
BEAST_EXPECT(txMeta->getFieldI32(sfWasmReturnCode) == 1);
|
||||||
@@ -863,7 +863,7 @@ struct EscrowSmart_test : public beast::unit_test::suite
|
|||||||
env.close();
|
env.close();
|
||||||
env.close();
|
env.close();
|
||||||
|
|
||||||
auto const allowance = 2'985;
|
auto const allowance = 138'485;
|
||||||
auto const finishFee = env.current()->fees().base +
|
auto const finishFee = env.current()->fees().base +
|
||||||
(allowance * env.current()->fees().gasPrice) /
|
(allowance * env.current()->fees().gasPrice) /
|
||||||
MICRO_DROPS_PER_DROP +
|
MICRO_DROPS_PER_DROP +
|
||||||
|
|||||||
@@ -217,9 +217,8 @@ EscrowCreate::preflight(PreflightContext const& ctx)
|
|||||||
return temMALFORMED;
|
return temMALFORMED;
|
||||||
}
|
}
|
||||||
|
|
||||||
HostFunctions mock;
|
HostFunctions mock(ctx.j);
|
||||||
auto const re =
|
auto const re = preflightEscrowWasm(code, mock, ESCROW_FUNCTION_NAME);
|
||||||
preflightEscrowWasm(code, ESCROW_FUNCTION_NAME, {}, &mock, ctx.j);
|
|
||||||
if (!isTesSuccess(re))
|
if (!isTesSuccess(re))
|
||||||
{
|
{
|
||||||
JLOG(ctx.j.debug()) << "EscrowCreate.FinishFunction bad WASM";
|
JLOG(ctx.j.debug()) << "EscrowCreate.FinishFunction bad WASM";
|
||||||
@@ -1214,7 +1213,7 @@ EscrowFinish::doApply()
|
|||||||
}
|
}
|
||||||
std::uint32_t allowance = ctx_.tx[sfComputationAllowance];
|
std::uint32_t allowance = ctx_.tx[sfComputationAllowance];
|
||||||
auto re = runEscrowWasm(
|
auto re = runEscrowWasm(
|
||||||
wasm, ESCROW_FUNCTION_NAME, {}, &ledgerDataProvider, allowance);
|
wasm, ledgerDataProvider, ESCROW_FUNCTION_NAME, {}, allowance);
|
||||||
JLOG(j_.trace()) << "Escrow WASM ran";
|
JLOG(j_.trace()) << "Escrow WASM ran";
|
||||||
|
|
||||||
if (auto const& data = ledgerDataProvider.getData(); data.has_value())
|
if (auto const& data = ledgerDataProvider.getData(); data.has_value())
|
||||||
|
|||||||
Reference in New Issue
Block a user