refactor: rename info() to header() (#6138)

This change renames all the `info()` functions to `header()`, since they return `LedgerHeader` structs. It also renames the underlying variables from `info_` to `header_`.
This commit is contained in:
Mayukha Vadari
2025-12-10 16:04:37 -05:00
committed by GitHub
parent bff5954acf
commit 62efecbfb1
90 changed files with 609 additions and 582 deletions

View File

@@ -68,7 +68,7 @@ public:
}
env.fund(XRP(10000), alice);
env.close();
LedgerHeader const ledger3Info = env.closed()->info();
LedgerHeader const ledger3Info = env.closed()->header();
BEAST_EXPECT(ledger3Info.seq == 3);
{
@@ -118,7 +118,7 @@ public:
env(pay(gw1, alice, gw1Currency(50 + c)));
}
env.close();
LedgerHeader const ledger4Info = env.closed()->info();
LedgerHeader const ledger4Info = env.closed()->header();
BEAST_EXPECT(ledger4Info.seq == 4);
// Add another set of trust lines in another ledger so we can see
@@ -153,7 +153,7 @@ public:
tfSetNoRipple | tfSetFreeze | tfSetDeepFreeze));
}
env.close();
LedgerHeader const ledger58Info = env.closed()->info();
LedgerHeader const ledger58Info = env.closed()->header();
BEAST_EXPECT(ledger58Info.seq == 58);
// A re-usable test for historic ledgers.
@@ -817,7 +817,7 @@ public:
}
env.fund(XRP(10000), alice);
env.close();
LedgerHeader const ledger3Info = env.closed()->info();
LedgerHeader const ledger3Info = env.closed()->header();
BEAST_EXPECT(ledger3Info.seq == 3);
{
@@ -899,7 +899,7 @@ public:
env(pay(gw1, alice, gw1Currency(50 + c)));
}
env.close();
LedgerHeader const ledger4Info = env.closed()->info();
LedgerHeader const ledger4Info = env.closed()->header();
BEAST_EXPECT(ledger4Info.seq == 4);
// Add another set of trust lines in another ledger so we can see
@@ -934,7 +934,7 @@ public:
tfSetNoRipple | tfSetFreeze | tfSetDeepFreeze));
}
env.close();
LedgerHeader const ledger58Info = env.closed()->info();
LedgerHeader const ledger58Info = env.closed()->header();
BEAST_EXPECT(ledger58Info.seq == 58);
// A re-usable test for historic ledgers.

View File

@@ -242,7 +242,7 @@ class AccountTx_test : public beast::unit_test::suite
env.rpc("json", "account_tx", to_string(p)),
rpcLGR_IDX_MALFORMED));
p[jss::ledger_index_min] = env.current()->info().seq;
p[jss::ledger_index_min] = env.current()->header().seq;
BEAST_EXPECT(isErr(
env.rpc("json", "account_tx", to_string(p)),
(apiVersion == 1 ? rpcLGR_IDXS_INVALID
@@ -256,7 +256,7 @@ class AccountTx_test : public beast::unit_test::suite
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
p[jss::ledger_index_max] = env.current()->info().seq;
p[jss::ledger_index_max] = env.current()->header().seq;
if (apiVersion < 2u)
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
@@ -269,11 +269,11 @@ class AccountTx_test : public beast::unit_test::suite
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
p[jss::ledger_index_max] = env.closed()->info().seq;
p[jss::ledger_index_max] = env.closed()->header().seq;
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
p[jss::ledger_index_max] = env.closed()->info().seq - 1;
p[jss::ledger_index_max] = env.closed()->header().seq - 1;
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
}
@@ -281,19 +281,19 @@ class AccountTx_test : public beast::unit_test::suite
{
Json::Value p{jParams};
p[jss::ledger_index] = env.closed()->info().seq;
p[jss::ledger_index] = env.closed()->header().seq;
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
p[jss::ledger_index] = env.closed()->info().seq - 1;
p[jss::ledger_index] = env.closed()->header().seq - 1;
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
p[jss::ledger_index] = env.current()->info().seq;
p[jss::ledger_index] = env.current()->header().seq;
BEAST_EXPECT(isErr(
env.rpc("json", "account_tx", to_string(p)),
rpcLGR_NOT_VALIDATED));
p[jss::ledger_index] = env.current()->info().seq + 1;
p[jss::ledger_index] = env.current()->header().seq + 1;
BEAST_EXPECT(isErr(
env.rpc("json", "account_tx", to_string(p)), rpcLGR_NOT_FOUND));
}
@@ -302,11 +302,11 @@ class AccountTx_test : public beast::unit_test::suite
{
Json::Value p{jParams};
p[jss::ledger_hash] = to_string(env.closed()->info().hash);
p[jss::ledger_hash] = to_string(env.closed()->header().hash);
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
p[jss::ledger_hash] = to_string(env.closed()->info().parentHash);
p[jss::ledger_hash] = to_string(env.closed()->header().parentHash);
BEAST_EXPECT(noTxs(env.rpc("json", "account_tx", to_string(p))));
}
@@ -333,7 +333,7 @@ class AccountTx_test : public beast::unit_test::suite
// Ledger index max only
{
Json::Value p{jParams};
p[jss::ledger_index_max] = env.current()->info().seq;
p[jss::ledger_index_max] = env.current()->header().seq;
if (apiVersion < 2u)
BEAST_EXPECT(hasTxs(
env.rpc(apiVersion, "json", "account_tx", to_string(p))));
@@ -903,7 +903,7 @@ class AccountTx_test : public beast::unit_test::suite
//
// ledger hash should be fixed regardless any change to account history
// BEAST_EXPECT(
// to_string(env.closed()->info().hash) ==
// to_string(env.closed()->header().hash) ==
// "0BD507BB87D3C0E73B462485E6E381798A8C82FC49BF17FE39C60E08A1AF035D");
// alice authorizes bob

View File

@@ -557,7 +557,7 @@ public:
// check expired credentials
char const credType2[] = "fghijk";
std::uint32_t const x = env.current()
->info()
->header()
.parentCloseTime.time_since_epoch()
.count() +
40;

View File

@@ -217,7 +217,7 @@ public:
if (BEAST_EXPECT(jrr.isMember(jss::ledger)))
BEAST_EXPECT(
jrr[jss::ledger][jss::ledger_hash] ==
to_string(env.closed()->info().hash));
to_string(env.closed()->header().hash));
}
{
// Closed ledger with binary form

View File

@@ -539,7 +539,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env.fund(XRP(10000), alice);
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
{
// Exercise ledger_closed along the way.
Json::Value const jrr = env.rpc("ledger_closed")[jss::result];
@@ -646,7 +646,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(check::create(env.master, alice, XRP(100)));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
{
// Request a check.
Json::Value jvParams;
@@ -765,7 +765,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env.close();
env(delegate::set(alice, bob, {"Payment", "CheckCreate"}));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
std::string delegateIndex;
{
// Request by account and authorize
@@ -823,7 +823,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(deposit::auth(alice, becky));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
std::string depositPreauthIndex;
{
// Request a depositPreauth by owner and authorized.
@@ -1171,7 +1171,7 @@ class LedgerEntry_test : public beast::unit_test::suite
}
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
{
// Exercise ledger_closed along the way.
Json::Value const jrr = env.rpc("ledger_closed")[jss::result];
@@ -1331,7 +1331,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(escrowCreate(alice, alice, XRP(333), env.now() + 2s));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
std::string escrowIndex;
{
// Request the escrow using owner and sequence.
@@ -1379,7 +1379,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(offer(alice, USD(321), XRP(322)));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
std::string offerIndex;
{
// Request the offer using owner and sequence.
@@ -1443,7 +1443,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(payChanCreate(alice, env.master, XRP(57), 18s, alice.pk()));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
uint256 const payChanIndex{
keylet::payChan(alice, env.master, env.seq(alice) - 1).key};
@@ -1495,7 +1495,8 @@ class LedgerEntry_test : public beast::unit_test::suite
// check both aliases
for (auto const& fieldName : {jss::ripple_state, jss::state})
{
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{
to_string(env.closed()->header().hash)};
{
// Request the trust line using the accounts and currency.
Json::Value jvParams;
@@ -1637,7 +1638,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(ticket::create(env.master, 2));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
// Request four tickets: one before the first one we created, the
// two created tickets, and the ticket that would come after the
// last created ticket.
@@ -1734,7 +1735,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(didCreate(alice));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
{
// Request the DID using its index.
@@ -1865,7 +1866,7 @@ class LedgerEntry_test : public beast::unit_test::suite
tfMPTCanTrade | tfMPTCanTransfer | tfMPTCanClawback});
mptAlice.authorize({.account = bob, .holderCount = 1});
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
std::string const badMptID =
"00000193B9DDCAF401B5B3B26875986043F82CD0D13B4315";
@@ -2024,7 +2025,7 @@ class LedgerEntry_test : public beast::unit_test::suite
env(check::create(env.master, alice, XRP(100)));
env.close();
std::string const ledgerHash{to_string(env.closed()->info().hash)};
std::string const ledgerHash{to_string(env.closed()->header().hash)};
{
// Request a check.
Json::Value const jrr =
@@ -2095,7 +2096,7 @@ class LedgerEntry_XChain_test : public beast::unit_test::suite,
createBridgeObjects(mcEnv, scEnv);
std::string const ledgerHash{to_string(mcEnv.closed()->info().hash)};
std::string const ledgerHash{to_string(mcEnv.closed()->header().hash)};
std::string bridge_index;
Json::Value mcBridge;
{

View File

@@ -60,7 +60,7 @@ class LedgerRPC_test : public beast::unit_test::suite
Env env{*this};
env.close();
BEAST_EXPECT(env.current()->info().seq == 4);
BEAST_EXPECT(env.current()->header().seq == 4);
{
Json::Value jvParams;
@@ -87,9 +87,9 @@ class LedgerRPC_test : public beast::unit_test::suite
BEAST_EXPECT(jrr[jss::ledger][jss::closed] == false);
BEAST_EXPECT(
jrr[jss::ledger][jss::ledger_index] ==
std::to_string(env.current()->info().seq));
std::to_string(env.current()->header().seq));
BEAST_EXPECT(
jrr[jss::ledger_current_index] == env.current()->info().seq);
jrr[jss::ledger_current_index] == env.current()->header().seq);
}
}
@@ -182,12 +182,12 @@ class LedgerRPC_test : public beast::unit_test::suite
Env env{*this};
env.close();
BEAST_EXPECT(env.current()->info().seq == 4);
BEAST_EXPECT(env.current()->header().seq == 4);
{
auto const jrr = env.rpc("ledger_current")[jss::result];
BEAST_EXPECT(
jrr[jss::ledger_current_index] == env.current()->info().seq);
jrr[jss::ledger_current_index] == env.current()->header().seq);
}
}
@@ -475,7 +475,7 @@ class LedgerRPC_test : public beast::unit_test::suite
env(noop(alice));
}
BEAST_EXPECT(env.current()->info().seq == 5);
BEAST_EXPECT(env.current()->header().seq == 5);
// Put some txs in the queue
// Alice
auto aliceSeq = env.seq(alice);
@@ -508,7 +508,7 @@ class LedgerRPC_test : public beast::unit_test::suite
env.close();
env.close();
env.close();
BEAST_EXPECT(env.current()->info().seq == 8);
BEAST_EXPECT(env.current()->header().seq == 8);
jrr = env.rpc("json", "ledger", to_string(jv))[jss::result];
BEAST_EXPECT(jrr[jss::queue_data].size() == 11);
@@ -517,7 +517,7 @@ class LedgerRPC_test : public beast::unit_test::suite
jrr = env.rpc("json", "ledger", to_string(jv))[jss::result];
std::string const txid0 = [&]() {
auto const& parentHash = env.current()->info().parentHash;
auto const& parentHash = env.current()->header().parentHash;
if (BEAST_EXPECT(jrr[jss::queue_data].size() == 2))
{
std::string const txid1 = [&]() {
@@ -559,7 +559,7 @@ class LedgerRPC_test : public beast::unit_test::suite
jrr = env.rpc("json", "ledger", to_string(jv))[jss::result];
if (BEAST_EXPECT(jrr[jss::queue_data].size() == 2))
{
auto const& parentHash = env.current()->info().parentHash;
auto const& parentHash = env.current()->header().parentHash;
auto const txid1 = [&]() {
auto const& txj = jrr[jss::queue_data][1u];
BEAST_EXPECT(txj[jss::account] == alice.human());

View File

@@ -32,7 +32,7 @@ public:
env.close();
env.close();
BEAST_EXPECT(env.current()->info().seq == 5);
BEAST_EXPECT(env.current()->header().seq == 5);
{
// arbitrary text is converted to 0.

View File

@@ -1027,7 +1027,7 @@ class Simulate_test : public beast::unit_test::suite
auto jv = credentials::create(subject, issuer, credType);
uint32_t const t =
env.current()->info().parentCloseTime.time_since_epoch().count();
env.current()->header().parentCloseTime.time_since_epoch().count();
jv[sfExpiration.jsonName] = t;
env(jv);
env.close();

View File

@@ -469,11 +469,11 @@ public:
return false;
if (jv[jss::ledger_hash] !=
to_string(env.closed()->info().hash))
to_string(env.closed()->header().hash))
return false;
if (jv[jss::ledger_index] !=
std::to_string(env.closed()->info().seq))
std::to_string(env.closed()->header().seq))
return false;
if (jv[jss::flags] != (vfFullyCanonicalSig | vfFullValidation))
@@ -504,7 +504,7 @@ public:
// Certain fields are only added on a flag ledger.
bool const isFlagLedger =
(env.closed()->info().seq + 1) % 256 == 0;
(env.closed()->header().seq + 1) % 256 == 0;
if (jv.isMember(jss::server_version) != isFlagLedger)
return false;
@@ -520,7 +520,7 @@ public:
// Check stream update. Look at enough stream entries so we see
// at least one flag ledger.
while (env.closed()->info().seq < 300)
while (env.closed()->header().seq < 300)
{
env.close();
using namespace std::chrono_literals;

View File

@@ -50,7 +50,7 @@ class Transaction_test : public beast::unit_test::suite
std::vector<std::shared_ptr<STTx const>> txns;
std::vector<std::shared_ptr<STObject const>> metas;
auto const startLegSeq = env.current()->info().seq;
auto const startLegSeq = env.current()->header().seq;
for (int i = 0; i < 750; ++i)
{
env(noop(alice));
@@ -59,7 +59,7 @@ class Transaction_test : public beast::unit_test::suite
metas.emplace_back(
env.closed()->txRead(env.tx()->getTransactionID()).second);
}
auto const endLegSeq = env.closed()->info().seq;
auto const endLegSeq = env.closed()->header().seq;
// Find the existing transactions
for (size_t i = 0; i < txns.size(); ++i)
@@ -302,7 +302,7 @@ class Transaction_test : public beast::unit_test::suite
std::vector<std::shared_ptr<STTx const>> txns;
std::vector<std::shared_ptr<STObject const>> metas;
auto const startLegSeq = env.current()->info().seq;
auto const startLegSeq = env.current()->header().seq;
for (int i = 0; i < 750; ++i)
{
env(noop(alice));
@@ -311,7 +311,7 @@ class Transaction_test : public beast::unit_test::suite
metas.emplace_back(
env.closed()->txRead(env.tx()->getTransactionID()).second);
}
auto const endLegSeq = env.closed()->info().seq;
auto const endLegSeq = env.closed()->header().seq;
// Find the existing transactions
for (size_t i = 0; i < txns.size(); ++i)
@@ -630,7 +630,7 @@ class Transaction_test : public beast::unit_test::suite
auto const alice = Account("alice");
auto const bob = Account("bob");
auto const startLegSeq = env.current()->info().seq;
auto const startLegSeq = env.current()->header().seq;
env.fund(XRP(10000), alice, bob);
env(pay(alice, bob, XRP(10)));
env.close();
@@ -661,7 +661,7 @@ class Transaction_test : public beast::unit_test::suite
Account const alice = Account("alice");
Account const bob = Account("bob");
std::uint32_t const startLegSeq = env.current()->info().seq;
std::uint32_t const startLegSeq = env.current()->header().seq;
env.fund(XRP(10000), alice, bob);
env(pay(alice, bob, XRP(10)));
env.close();
@@ -709,7 +709,7 @@ class Transaction_test : public beast::unit_test::suite
env(pay(alice, bob, XRP(10)));
env.close();
auto const ledgerSeq = env.current()->info().seq;
auto const ledgerSeq = env.current()->header().seq;
env(noop(alice), ter(tesSUCCESS));
env.close();
@@ -738,7 +738,7 @@ class Transaction_test : public beast::unit_test::suite
auto const alice = Account("alice");
auto const bob = Account("bob");
auto const startLegSeq = env.current()->info().seq;
auto const startLegSeq = env.current()->header().seq;
env.fund(XRP(10000), alice, bob);
env(pay(alice, bob, XRP(10)));
env.close();