Skip to content

Commit

Permalink
fix: remove deprecated fields in ledger method (#4244)
Browse files Browse the repository at this point in the history
Remove deprecated fields from the ledger command:
* accepted
* hash (use ledger_hash instead)
* seqNum (use ledger_index instead)
* totalCoins (use total_coins instead)

Update SHAMapStore unit tests to use `jss:ledger_hash` instead of the
deprecated `hash` field.

Fix #3214
  • Loading branch information
ckeshava authored Jun 28, 2023
1 parent 6b4437d commit 0e98352
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
5 changes: 0 additions & 5 deletions src/ripple/app/ledger/impl/LedgerToJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ fillJson(Object& json, bool closed, LedgerInfo const& info, bool bFull)
{
json[jss::parent_hash] = to_string(info.parentHash);
json[jss::ledger_index] = to_string(info.seq);
json[jss::seqNum] = to_string(info.seq); // DEPRECATED

if (closed)
{
Expand All @@ -70,10 +69,6 @@ fillJson(Object& json, bool closed, LedgerInfo const& info, bool bFull)
json[jss::account_hash] = to_string(info.accountHash);
json[jss::total_coins] = to_string(info.drops);

// These next three are DEPRECATED.
json[jss::hash] = to_string(info.hash);
json[jss::totalCoins] = to_string(info.drops);
json[jss::accepted] = closed;
json[jss::close_flags] = info.closeFlags;

// Always show fields that contribute to the ledger hash
Expand Down
2 changes: 0 additions & 2 deletions src/ripple/protocol/jss.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ JSS(send_max); // in: PathRequest, RipplePathFind
JSS(seq); // in: LedgerEntry;
// out: NetworkOPs, RPCSub, AccountOffers,
// ValidatorList, ValidatorInfo, Manifest
JSS(seqNum); // out: LedgerToJson
JSS(sequence); // in: UNL
JSS(sequence_count); // out: AccountInfo
JSS(server_domain); // out: NetworkOPs
Expand Down Expand Up @@ -583,7 +582,6 @@ JSS(timeouts); // out: InboundLedger
JSS(track); // out: PeerImp
JSS(traffic); // out: Overlay
JSS(total); // out: counters
JSS(totalCoins); // out: LedgerToJson
JSS(total_bytes_recv); // out: Peers
JSS(total_bytes_sent); // out: Peers
JSS(total_coins); // out: LedgerToJson
Expand Down
9 changes: 5 additions & 4 deletions src/test/app/SHAMapStore_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class SHAMapStore_test : public beast::unit_test::suite
const std::string outTxHash = to_string(info.txHash);

auto const& ledger = json[jss::result][jss::ledger];
return outHash == ledger[jss::hash].asString() && outSeq == seq &&
return outHash == ledger[jss::ledger_hash].asString() &&
outSeq == seq &&
outParentHash == ledger[jss::parent_hash].asString() &&
outDrops == ledger[jss::total_coins].asString() &&
outCloseTime == ledger[jss::close_time].asUInt() &&
Expand All @@ -111,9 +112,9 @@ class SHAMapStore_test : public beast::unit_test::suite
BEAST_EXPECT(
json.isMember(jss::result) &&
json[jss::result].isMember(jss::ledger) &&
json[jss::result][jss::ledger].isMember(jss::hash) &&
json[jss::result][jss::ledger][jss::hash].isString());
return json[jss::result][jss::ledger][jss::hash].asString();
json[jss::result][jss::ledger].isMember(jss::ledger_hash) &&
json[jss::result][jss::ledger][jss::ledger_hash].isString());
return json[jss::result][jss::ledger][jss::ledger_hash].asString();
}

void
Expand Down
8 changes: 0 additions & 8 deletions src/test/rpc/LedgerRPC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ class LedgerRPC_test : public beast::unit_test::suite
env.rpc("json", "ledger", to_string(jvParams))[jss::result];
BEAST_EXPECT(jrr[jss::ledger][jss::closed] == true);
BEAST_EXPECT(jrr[jss::ledger][jss::ledger_index] == "1");
BEAST_EXPECT(jrr[jss::ledger][jss::accepted] == true);
BEAST_EXPECT(
jrr[jss::ledger][jss::totalCoins] ==
env.balance(env.master).value().getText());
}

{
Expand All @@ -91,10 +87,6 @@ class LedgerRPC_test : public beast::unit_test::suite
env.rpc("json", "ledger", to_string(jvParams))[jss::result];
BEAST_EXPECT(jrr[jss::ledger][jss::closed] == true);
BEAST_EXPECT(jrr[jss::ledger][jss::ledger_index] == "1");
BEAST_EXPECT(jrr[jss::ledger][jss::accepted] == true);
BEAST_EXPECT(
jrr[jss::ledger][jss::totalCoins] ==
env.balance(env.master).value().getText());
}

{
Expand Down

0 comments on commit 0e98352

Please sign in to comment.