mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Simplify & modernize code:
- Simplify and consolidate code for parsing hex input. - Replace beast::endian::order with boost::endian::order. - Simplify CountedObject code. - Remove pre-C++17 workarounds in favor of C++17 based solutions. - Improve `base_uint` and simplify its hex-parsing interface by consolidating the `SexHex` and `SetHexExact` methods into one API: `parseHex` which forces callers to verify the result of the operation; as a result some public-facing API endpoints may now return errors when passed values that were previously accepted. - Remove the simple fallback implementations of SHA2 and RIPEMD introduced to reduce our dependency on OpenSSL. The code is slow and rarely, if ever, exercised and we rely on OpenSSL functionality for Boost.ASIO as well.
This commit is contained in:
@@ -602,14 +602,29 @@ public:
|
||||
std::uint32_t sequence = 0;
|
||||
|
||||
// public key with invalid type
|
||||
auto const ret = strUnHex(
|
||||
"9930E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02"
|
||||
"0");
|
||||
auto const badKey = Slice{ret->data(), ret->size()};
|
||||
std::array<std::uint8_t, 33> const badKey{
|
||||
0x99, 0x30, 0xE7, 0xFC, 0x9D, 0x56, 0xBB, 0x25, 0xD6, 0x89, 0x3B,
|
||||
0xA3, 0xF3, 0x17, 0xAE, 0x5B, 0xCF, 0x33, 0xB3, 0x29, 0x1B, 0xD6,
|
||||
0x3D, 0xB3, 0x26, 0x54, 0xA3, 0x13, 0x22, 0x2F, 0x7F, 0xD0, 0x20};
|
||||
|
||||
// short public key
|
||||
auto const retShort = strUnHex("0330");
|
||||
auto const shortKey = Slice{retShort->data(), retShort->size()};
|
||||
// Short public key:
|
||||
std::array<std::uint8_t, 16> const shortKey{
|
||||
0x03,
|
||||
0x30,
|
||||
0xE7,
|
||||
0xFC,
|
||||
0x9D,
|
||||
0x56,
|
||||
0xBB,
|
||||
0x25,
|
||||
0xD6,
|
||||
0x89,
|
||||
0x3B,
|
||||
0xA3,
|
||||
0xF3,
|
||||
0x17,
|
||||
0xAE,
|
||||
0x5B};
|
||||
|
||||
auto toString = [](STObject const& st) {
|
||||
Serializer s;
|
||||
@@ -749,13 +764,13 @@ public:
|
||||
{
|
||||
// reject invalid public key type
|
||||
auto badSt = st;
|
||||
badSt[sfPublicKey] = badKey;
|
||||
badSt[sfPublicKey] = makeSlice(badKey);
|
||||
BEAST_EXPECT(!deserializeManifest(toString(badSt)));
|
||||
}
|
||||
{
|
||||
// reject short public key
|
||||
auto badSt = st;
|
||||
badSt[sfPublicKey] = shortKey;
|
||||
badSt[sfPublicKey] = makeSlice(shortKey);
|
||||
BEAST_EXPECT(!deserializeManifest(toString(badSt)));
|
||||
}
|
||||
{
|
||||
@@ -767,13 +782,13 @@ public:
|
||||
{
|
||||
// reject invalid signing public key type
|
||||
auto badSt = st;
|
||||
badSt[sfSigningPubKey] = badKey;
|
||||
badSt[sfSigningPubKey] = makeSlice(badKey);
|
||||
BEAST_EXPECT(!deserializeManifest(toString(badSt)));
|
||||
}
|
||||
{
|
||||
// reject short signing public key
|
||||
auto badSt = st;
|
||||
badSt[sfSigningPubKey] = shortKey;
|
||||
badSt[sfSigningPubKey] = makeSlice(shortKey);
|
||||
BEAST_EXPECT(!deserializeManifest(toString(badSt)));
|
||||
}
|
||||
{
|
||||
|
||||
@@ -802,7 +802,7 @@ public:
|
||||
"issuer" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
|
||||
"value" : "1000"
|
||||
},
|
||||
"HighNode" : "0000000000000000",
|
||||
"HighNode" : "0",
|
||||
"HighQualityIn" : 2000,
|
||||
"HighQualityOut" : 1400000000,
|
||||
"LedgerEntryType" : "RippleState",
|
||||
@@ -811,7 +811,7 @@ public:
|
||||
"issuer" : "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
|
||||
"value" : "0"
|
||||
},
|
||||
"LowNode" : "0000000000000000"
|
||||
"LowNode" : "0"
|
||||
})",
|
||||
jv);
|
||||
|
||||
@@ -847,14 +847,14 @@ public:
|
||||
"issuer" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
|
||||
"value" : "1000"
|
||||
},
|
||||
"HighNode" : "0000000000000000",
|
||||
"HighNode" : "0",
|
||||
"LedgerEntryType" : "RippleState",
|
||||
"LowLimit" : {
|
||||
"currency" : "USD",
|
||||
"issuer" : "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
|
||||
"value" : "1000"
|
||||
},
|
||||
"LowNode" : "0000000000000000"
|
||||
"LowNode" : "0"
|
||||
})",
|
||||
jv);
|
||||
|
||||
@@ -900,7 +900,7 @@ public:
|
||||
"issuer" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
|
||||
"value" : "0"
|
||||
},
|
||||
"HighNode" : "0000000000000000",
|
||||
"HighNode" : "0",
|
||||
"LedgerEntryType" : "RippleState",
|
||||
"LowLimit" :
|
||||
{
|
||||
@@ -908,7 +908,7 @@ public:
|
||||
"issuer" : "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
|
||||
"value" : "0"
|
||||
},
|
||||
"LowNode" : "0000000000000000"
|
||||
"LowNode" : "0"
|
||||
})",
|
||||
jv);
|
||||
|
||||
|
||||
@@ -454,30 +454,24 @@ class TrustAndBalance_test : public beast::unit_test::suite
|
||||
jvs[jss::streams].append("transactions");
|
||||
BEAST_EXPECT(wsc->invoke("subscribe", jvs)[jss::status] == "success");
|
||||
|
||||
char const* invoiceid =
|
||||
"243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89";
|
||||
|
||||
Json::Value jv;
|
||||
auto tx = env.jt(
|
||||
pay(env.master, alice, XRP(10000)),
|
||||
json(sfInvoiceID.fieldName, "DEADBEEF"));
|
||||
json(sfInvoiceID.fieldName, invoiceid));
|
||||
jv[jss::tx_blob] = strHex(tx.stx->getSerializer().slice());
|
||||
auto jrr = wsc->invoke("submit", jv)[jss::result];
|
||||
BEAST_EXPECT(jrr[jss::status] == "success");
|
||||
BEAST_EXPECT(
|
||||
jrr[jss::tx_json][sfInvoiceID.fieldName] ==
|
||||
"0000000000000000"
|
||||
"0000000000000000"
|
||||
"0000000000000000"
|
||||
"00000000DEADBEEF");
|
||||
BEAST_EXPECT(jrr[jss::tx_json][sfInvoiceID.fieldName] == invoiceid);
|
||||
env.close();
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
BEAST_EXPECT(wsc->findMsg(2s, [](auto const& jval) {
|
||||
BEAST_EXPECT(wsc->findMsg(2s, [invoiceid](auto const& jval) {
|
||||
auto const& t = jval[jss::transaction];
|
||||
return t[jss::TransactionType] == jss::Payment &&
|
||||
t[sfInvoiceID.fieldName] ==
|
||||
"0000000000000000"
|
||||
"0000000000000000"
|
||||
"0000000000000000"
|
||||
"00000000DEADBEEF";
|
||||
t[sfInvoiceID.fieldName] == invoiceid;
|
||||
}));
|
||||
|
||||
BEAST_EXPECT(wsc->invoke("unsubscribe", jv)[jss::status] == "success");
|
||||
|
||||
Reference in New Issue
Block a user