CTID sync rippled (#114)

* clang-format

* add `'` seperator to hex constants

fix bad seperator

clang-format

* remove impossible validation

add parenthesis

* pre-increment `it`

* add leading 0

* use boost_regex

* add leading 0

* `const` after declare variable

* clang-format

* add extra check on std::optional

* move guard

* add test

* update test to match

* rename `txnIDfromIndex` -> `txnIdFromIndex`

* update test to match guard

* fix test naming

---------

Co-authored-by: Richard Holland <richard.holland@starstone.co.nz>
This commit is contained in:
Denis Angell
2023-09-26 15:46:19 +02:00
committed by GitHub
parent 785ba90712
commit 522cfe9d6a
7 changed files with 57 additions and 38 deletions

View File

@@ -38,7 +38,7 @@ class LedgerMaster_test : public beast::unit_test::suite
}
void
testTxnIDfromIndex(FeatureBitset features)
testTxnIdFromIndex(FeatureBitset features)
{
testcase("tx_id_from_index");
@@ -72,39 +72,49 @@ class LedgerMaster_test : public beast::unit_test::suite
std::uint32_t ledgerSeq = -1;
std::uint32_t txnIndex = 0;
auto result =
env.app().getLedgerMaster().txnIDfromIndex(ledgerSeq, txnIndex);
env.app().getLedgerMaster().txnIdFromIndex(ledgerSeq, txnIndex);
BEAST_EXPECT(!result);
}
// test not in ledger
{
uint32_t txnIndex = metas[0]->getFieldU32(sfTransactionIndex);
auto result =
env.app().getLedgerMaster().txnIDfromIndex(0, txnIndex);
env.app().getLedgerMaster().txnIdFromIndex(0, txnIndex);
BEAST_EXPECT(!result);
}
// test empty ledger
{
auto result =
env.app().getLedgerMaster().txnIDfromIndex(endLegSeq, 0);
env.app().getLedgerMaster().txnIdFromIndex(endLegSeq, 0);
BEAST_EXPECT(!result);
}
// ended without result
{
uint32_t txnIndex = metas[0]->getFieldU32(sfTransactionIndex);
auto result = env.app().getLedgerMaster().txnIDfromIndex(
auto result = env.app().getLedgerMaster().txnIdFromIndex(
endLegSeq + 1, txnIndex);
BEAST_EXPECT(!result);
}
// success
// success (first tx)
{
uint32_t txnIndex = metas[0]->getFieldU32(sfTransactionIndex);
auto result = env.app().getLedgerMaster().txnIDfromIndex(
auto result = env.app().getLedgerMaster().txnIdFromIndex(
startLegSeq, txnIndex);
BEAST_EXPECT(
*result ==
uint256("277F4FD89C20B92457FEF05FF63F6405563AD0563C73D967A29727"
"72679ADC65"));
}
// success (second tx)
{
uint32_t txnIndex = metas[1]->getFieldU32(sfTransactionIndex);
auto result = env.app().getLedgerMaster().txnIdFromIndex(
startLegSeq + 1, txnIndex);
BEAST_EXPECT(
*result ==
uint256("293DF7335EBBAF4420D52E70ABF470EB4C5792CAEA2F91F76193C2"
"819F538FDE"));
}
}
public:
@@ -119,7 +129,7 @@ public:
void
testWithFeats(FeatureBitset features)
{
testTxnIDfromIndex(features);
testTxnIdFromIndex(features);
}
};