Fix noRippleCheck fee field (#786)

Fixes #709
This commit is contained in:
Arihant Kothari
2023-07-26 14:22:17 -04:00
committed by GitHub
parent 71aabc8c29
commit 1d0a43669b
6 changed files with 5 additions and 17 deletions

View File

@@ -308,10 +308,6 @@ BackendInterface::fetchFees(std::uint32_t const seq, boost::asio::yield_context&
if (sle.getFieldIndex(ripple::sfBaseFee) != -1) if (sle.getFieldIndex(ripple::sfBaseFee) != -1)
fees.base = sle.getFieldU64(ripple::sfBaseFee); fees.base = sle.getFieldU64(ripple::sfBaseFee);
// deprecated?
// if (sle.getFieldIndex(ripple::sfReferenceFeeUnits) != -1)
// fees.units = sle.getFieldU32(ripple::sfReferenceFeeUnits);
if (sle.getFieldIndex(ripple::sfReserveBase) != -1) if (sle.getFieldIndex(ripple::sfReserveBase) != -1)
fees.reserve = sle.getFieldU32(ripple::sfReserveBase); fees.reserve = sle.getFieldU32(ripple::sfReserveBase);

View File

@@ -46,8 +46,7 @@ NoRippleCheckHandler::process(NoRippleCheckHandler::Input input, Context const&
auto sle = ripple::SLE{it, keylet}; auto sle = ripple::SLE{it, keylet};
auto accountSeq = sle.getFieldU32(ripple::sfSequence); auto accountSeq = sle.getFieldU32(ripple::sfSequence);
bool const bDefaultRipple = sle.getFieldU32(ripple::sfFlags) & ripple::lsfDefaultRipple; bool const bDefaultRipple = sle.getFieldU32(ripple::sfFlags) & ripple::lsfDefaultRipple;
// TODO: remove if no longer needed auto const fees = input.transactions ? sharedPtrBackend_->fetchFees(lgrInfo.seq, ctx.yield) : std::nullopt;
// auto const fees = input.transactions ? sharedPtrBackend_->fetchFees(lgrInfo.seq, ctx.yield) : std::nullopt;
auto output = NoRippleCheckHandler::Output(); auto output = NoRippleCheckHandler::Output();
@@ -58,8 +57,7 @@ NoRippleCheckHandler::process(NoRippleCheckHandler::Input input, Context const&
boost::json::object tx; boost::json::object tx;
tx[JS(Sequence)] = accountSeq; tx[JS(Sequence)] = accountSeq;
tx[JS(Account)] = ripple::toBase58(accountID); tx[JS(Account)] = ripple::toBase58(accountID);
// TODO: deprecated? tx[JS(Fee)] = toBoostJson(fees->base.jsonClipped());
// tx[JS(Fee)] = toBoostJson(fees->units.jsonClipped());
return tx; return tx;
}; };

View File

@@ -53,8 +53,6 @@ getLedgerPubMessage(
pubMsg["ledger_hash"] = to_string(lgrInfo.hash); pubMsg["ledger_hash"] = to_string(lgrInfo.hash);
pubMsg["ledger_time"] = lgrInfo.closeTime.time_since_epoch().count(); pubMsg["ledger_time"] = lgrInfo.closeTime.time_since_epoch().count();
// deprecated?
// pubMsg["fee_ref"] = RPC::toBoostJson(fees.units.jsonClipped());
pubMsg["fee_base"] = RPC::toBoostJson(fees.base.jsonClipped()); pubMsg["fee_base"] = RPC::toBoostJson(fees.base.jsonClipped());
pubMsg["reserve_base"] = RPC::toBoostJson(fees.reserve.jsonClipped()); pubMsg["reserve_base"] = RPC::toBoostJson(fees.reserve.jsonClipped());
pubMsg["reserve_inc"] = RPC::toBoostJson(fees.increment.jsonClipped()); pubMsg["reserve_inc"] = RPC::toBoostJson(fees.increment.jsonClipped());

View File

@@ -302,7 +302,6 @@ TEST_F(SubscriptionManagerSimpleBackendTest, SubscriptionManagerLedger)
"ledger_index":30, "ledger_index":30,
"ledger_hash":"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652", "ledger_hash":"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652",
"ledger_time":0, "ledger_time":0,
"fee_ref":4,
"fee_base":1, "fee_base":1,
"reserve_base":3, "reserve_base":3,
"reserve_inc":2 "reserve_inc":2
@@ -323,7 +322,6 @@ TEST_F(SubscriptionManagerSimpleBackendTest, SubscriptionManagerLedger)
"ledger_index":31, "ledger_index":31,
"ledger_hash":"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652", "ledger_hash":"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652",
"ledger_time":0, "ledger_time":0,
"fee_ref":0,
"fee_base":0, "fee_base":0,
"reserve_base":10, "reserve_base":10,
"reserve_inc":0, "reserve_inc":0,

View File

@@ -616,14 +616,14 @@ TEST_F(RPCNoRippleCheckTest, NormalPathTransactions)
{{ {{
"Sequence":{}, "Sequence":{},
"Account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "Account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Fee":4, "Fee":1,
"TransactionType":"AccountSet", "TransactionType":"AccountSet",
"SetFlag":8 "SetFlag":8
}}, }},
{{ {{
"Sequence":{}, "Sequence":{},
"Account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "Account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Fee":4, "Fee":1,
"TransactionType":"TrustSet", "TransactionType":"TrustSet",
"LimitAmount":{{ "LimitAmount":{{
"currency":"USD", "currency":"USD",
@@ -635,7 +635,7 @@ TEST_F(RPCNoRippleCheckTest, NormalPathTransactions)
{{ {{
"Sequence":{}, "Sequence":{},
"Account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "Account":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Fee":4, "Fee":1,
"TransactionType":"TrustSet", "TransactionType":"TrustSet",
"LimitAmount":{{ "LimitAmount":{{
"currency":"USD", "currency":"USD",

View File

@@ -588,7 +588,6 @@ TEST_F(RPCSubscribeHandlerTest, StreamsLedger)
"ledger_index":30, "ledger_index":30,
"ledger_hash":"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652", "ledger_hash":"4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652",
"ledger_time":0, "ledger_time":0,
"fee_ref":4,
"fee_base":1, "fee_base":1,
"reserve_base":3, "reserve_base":3,
"reserve_inc":2 "reserve_inc":2
@@ -615,7 +614,6 @@ TEST_F(RPCSubscribeHandlerTest, StreamsLedger)
auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}}; auto const handler = AnyHandler{SubscribeHandler{mockBackendPtr, subManager_}};
auto const output = handler.process(input, Context{std::ref(yield), session_}); auto const output = handler.process(input, Context{std::ref(yield), session_});
ASSERT_TRUE(output); ASSERT_TRUE(output);
// FIXME: fee_ref is missing now. this is possibly correct. need to confirm:
EXPECT_EQ(output->as_object(), json::parse(expectedOutput)); EXPECT_EQ(output->as_object(), json::parse(expectedOutput));
std::this_thread::sleep_for(20ms); std::this_thread::sleep_for(20ms);
auto const report = subManager_->report(); auto const report = subManager_->report();