diff --git a/src/etl/MPTHelpers.cpp b/src/etl/MPTHelpers.cpp index 00eadc5d..23767cbe 100644 --- a/src/etl/MPTHelpers.cpp +++ b/src/etl/MPTHelpers.cpp @@ -18,6 +18,7 @@ //============================================================================== #include "data/DBHelpers.hpp" +#include "util/Assert.hpp" #include #include @@ -71,6 +72,9 @@ getMPTHolderFromTx(ripple::TxMeta const& txMeta, ripple::STTx const& sttx) std::optional getMPTHolderFromObj(std::string const& key, std::string const& blob) { + // https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0033-multi-purpose-tokens#2121-mptoken-ledger-identifier + ASSERT(key.size() == ripple::uint256::size(), "The size of the key is expected to fit uint256 exactly"); + ripple::STLedgerEntry const sle = ripple::STLedgerEntry(ripple::SerialIter{blob.data(), blob.size()}, ripple::uint256::fromVoid(key.data())); diff --git a/tests/common/util/BinaryTestObject.cpp b/tests/common/util/BinaryTestObject.cpp index d03a2ef6..25ee516e 100644 --- a/tests/common/util/BinaryTestObject.cpp +++ b/tests/common/util/BinaryTestObject.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -152,7 +153,7 @@ createObjectWithTwoNFTs() // key is a token made up from owner's account ID followed by unused (in Clio) value described here: // https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0020-non-fungible-tokens#tokenpage-id-format - auto constexpr kEXTRA_BYTES = "000000000000"; + constexpr auto kEXTRA_BYTES = "000000000000"; auto const key = std::string(std::begin(account), std::end(account)) + kEXTRA_BYTES; return { @@ -173,11 +174,17 @@ createObjectWithMPT() constexpr auto kACCOUNT = "rM2AGCCCRb373FRuD8wHyUwUsh2dV4BW5Q"; auto const account = getAccountIdWithString(kACCOUNT); - auto const mptokenObject = createMpTokenObject(kACCOUNT, ripple::makeMptID(2, getAccountIdWithString(kACCOUNT))); + auto const mptID = ripple::makeMptID(2, getAccountIdWithString(kACCOUNT)); + auto const mptokenObject = createMpTokenObject(kACCOUNT, mptID); + + // key is a token made up from several fields described here: + // https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0033-multi-purpose-tokens#2121-mptoken-ledger-identifier + constexpr auto kSPACE_KEY = 0x007F; + auto const keySha512Half = ripple::sha512Half(kSPACE_KEY, mptID, account); return { .key = {}, - .keyRaw = std::string(reinterpret_cast(account.data()), ripple::AccountID::size()), + .keyRaw = std::string(std::begin(keySha512Half), std::end(keySha512Half)), .data = {}, .dataRaw = std::string( static_cast(mptokenObject.getSerializer().getDataPtr()), diff --git a/tests/integration/migration/cassandra/CassandraMigrationManagerTests.cpp b/tests/integration/migration/cassandra/CassandraMigrationManagerTests.cpp index d8528aa7..393b4249 100644 --- a/tests/integration/migration/cassandra/CassandraMigrationManagerTests.cpp +++ b/tests/integration/migration/cassandra/CassandraMigrationManagerTests.cpp @@ -223,7 +223,7 @@ class MigrationCassandraManagerTxTableTest : public MigrationCassandraSimpleTest TEST_F(MigrationCassandraManagerTxTableTest, MigrateExampleTransactionsMigrator) { - auto constexpr kTRANSACTIONS_MIGRATOR_NAME = "ExampleTransactionsMigrator"; + constexpr auto kTRANSACTIONS_MIGRATOR_NAME = "ExampleTransactionsMigrator"; EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kTRANSACTIONS_MIGRATOR_NAME), MigratorStatus::NotMigrated); ExampleTransactionsMigrator::count = 0; @@ -274,7 +274,7 @@ class MigrationCassandraManagerObjectsTableTest : public MigrationCassandraSimpl TEST_F(MigrationCassandraManagerObjectsTableTest, MigrateExampleObjectsMigrator) { - auto constexpr kOBJECTS_MIGRATOR_NAME = "ExampleObjectsMigrator"; + constexpr auto kOBJECTS_MIGRATOR_NAME = "ExampleObjectsMigrator"; EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kOBJECTS_MIGRATOR_NAME), MigratorStatus::NotMigrated); testMigrationManager_->runMigration(kOBJECTS_MIGRATOR_NAME); @@ -302,7 +302,7 @@ class MigrationCassandraManagerLedgerTableTest : public MigrationCassandraSimple TEST_F(MigrationCassandraManagerLedgerTableTest, MigrateExampleLedgerMigrator) { - auto constexpr kHEADER_MIGRATOR_NAME = "ExampleLedgerMigrator"; + constexpr auto kHEADER_MIGRATOR_NAME = "ExampleLedgerMigrator"; EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kHEADER_MIGRATOR_NAME), MigratorStatus::NotMigrated); testMigrationManager_->runMigration(kHEADER_MIGRATOR_NAME); @@ -334,7 +334,7 @@ class MigrationCassandraManagerDropTableTest : public MigrationCassandraSimpleTe TEST_F(MigrationCassandraManagerDropTableTest, MigrateDropTableMigrator) { - auto constexpr kDROP_TABLE_MIGRATOR_NAME = "ExampleDropTableMigrator"; + constexpr auto kDROP_TABLE_MIGRATOR_NAME = "ExampleDropTableMigrator"; EXPECT_EQ(testMigrationManager_->getMigratorStatusByName(kDROP_TABLE_MIGRATOR_NAME), MigratorStatus::NotMigrated); auto const beforeDropSize = diff --git a/tests/unit/etl/NFTHelpersTests.cpp b/tests/unit/etl/NFTHelpersTests.cpp index a5bed974..4bb44a7b 100644 --- a/tests/unit/etl/NFTHelpersTests.cpp +++ b/tests/unit/etl/NFTHelpersTests.cpp @@ -478,7 +478,7 @@ TEST_F(NFTHelpersTest, NFTDataFromLedgerObject) // key is a token made up from owner's account ID followed by unused (in Clio) value described here: // https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0020-non-fungible-tokens#tokenpage-id-format - auto constexpr kEXTRA_BYTES = "000000000000"; + constexpr auto kEXTRA_BYTES = "000000000000"; auto const key = std::string(std::begin(account), std::end(account)) + kEXTRA_BYTES; uint32_t constexpr kSEQ{5}; diff --git a/tests/unit/rpc/RPCHelpersTests.cpp b/tests/unit/rpc/RPCHelpersTests.cpp index 7123fd48..f607fa89 100644 --- a/tests/unit/rpc/RPCHelpersTests.cpp +++ b/tests/unit/rpc/RPCHelpersTests.cpp @@ -419,7 +419,7 @@ TEST_F(RPCHelpersTest, DeliverMaxAliasV1) TEST_F(RPCHelpersTest, DeliverMaxAliasV2) { - auto constexpr kJSON = R"JSON({ + constexpr auto kJSON = R"JSON({ "TransactionType": "Payment", "Amount": { "test": "test" @@ -522,7 +522,7 @@ TEST_F(RPCHelpersTest, TransactionAndMetadataBinaryJsonV2) TEST_F(RPCHelpersTest, ParseIssue) { - auto constexpr kJSON = R"JSON({ + constexpr auto kJSON = R"JSON({ "issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun", "currency": "JPY" })JSON"; @@ -536,7 +536,7 @@ TEST_F(RPCHelpersTest, ParseIssue) EXPECT_THROW(parseIssue(boost::json::parse(R"JSON({"currency": "XRP2"})JSON").as_object()), std::runtime_error); - auto constexpr kJSON2 = R"JSON({ + constexpr auto kJSON2 = R"JSON({ "issuer": "abcd", "currency": "JPY" })JSON";