refactor: Use more scoped enums (#7086)

This commit is contained in:
Alex Kremer
2026-05-11 16:39:48 +01:00
committed by GitHub
parent 779b49cd93
commit cdee9a675c
379 changed files with 2771 additions and 2864 deletions

View File

@@ -102,7 +102,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (not a string/int/uint)
{
json::Value j;
j[sfCloseResolution] = json::Value(json::ArrayValue);
j[sfCloseResolution] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -110,7 +110,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (not a string/int/uint)
{
json::Value j;
j[sfCloseResolution] = json::Value(json::ObjectValue);
j[sfCloseResolution] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -193,7 +193,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (not a string/int/uint)
{
json::Value j;
j[sfLedgerEntryType] = json::Value(json::ArrayValue);
j[sfLedgerEntryType] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -201,7 +201,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (not a string/int/uint)
{
json::Value j;
j[sfLedgerEntryType] = json::Value(json::ObjectValue);
j[sfLedgerEntryType] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -271,7 +271,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (arrayValue)
{
json::Value j;
j[sfNetworkID] = json::Value(json::ArrayValue);
j[sfNetworkID] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -279,7 +279,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (objectValue)
{
json::Value j;
j[sfNetworkID] = json::Value(json::ObjectValue);
j[sfNetworkID] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -348,7 +348,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// test arrayValue
{
json::Value j;
j[sfIndexNext] = json::Value(json::ArrayValue);
j[sfIndexNext] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -356,7 +356,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// test objectValue
{
json::Value j;
j[sfIndexNext] = json::Value(json::ObjectValue);
j[sfIndexNext] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -458,7 +458,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Array value for UInt128 (should fail)
{
json::Value j;
j[sfEmailHash] = json::Value(json::ArrayValue);
j[sfEmailHash] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -466,7 +466,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Object value for UInt128 (should fail)
{
json::Value j;
j[sfEmailHash] = json::Value(json::ObjectValue);
j[sfEmailHash] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -545,7 +545,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Array value for UInt160 (should fail)
{
json::Value j;
j[sfTakerPaysCurrency] = json::Value(json::ArrayValue);
j[sfTakerPaysCurrency] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -553,7 +553,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Object value for UInt160 (should fail)
{
json::Value j;
j[sfTakerPaysCurrency] = json::Value(json::ObjectValue);
j[sfTakerPaysCurrency] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -641,7 +641,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Array value for UInt192 (should fail)
{
json::Value j;
j[sfMPTokenIssuanceID] = json::Value(json::ArrayValue);
j[sfMPTokenIssuanceID] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -649,7 +649,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Object value for UInt192 (should fail)
{
json::Value j;
j[sfMPTokenIssuanceID] = json::Value(json::ObjectValue);
j[sfMPTokenIssuanceID] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -746,7 +746,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Array value for UInt256 (should fail)
{
json::Value j;
j[sfLedgerHash] = json::Value(json::ArrayValue);
j[sfLedgerHash] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -754,7 +754,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Object value for UInt256 (should fail)
{
json::Value j;
j[sfLedgerHash] = json::Value(json::ObjectValue);
j[sfLedgerHash] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -865,7 +865,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (arrayValue)
{
json::Value j;
j[sfLoanScale] = json::Value(json::ArrayValue);
j[sfLoanScale] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -873,7 +873,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test bad_type (objectValue)
{
json::Value j;
j[sfLoanScale] = json::Value(json::ObjectValue);
j[sfLoanScale] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -941,7 +941,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test array value for blob (should fail)
{
json::Value j;
j[sfPublicKey] = json::Value(json::ArrayValue);
j[sfPublicKey] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -949,7 +949,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test object value for blob (should fail)
{
json::Value j;
j[sfPublicKey] = json::Value(json::ObjectValue);
j[sfPublicKey] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -962,7 +962,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with valid array of hex strings for Vector256
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value arr(json::ValueType::Array);
arr.append(
"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCD"
"EF");
@@ -983,7 +983,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test empty array for Vector256 (should be valid, size 0)
{
json::Value j;
json::Value const arr(json::ArrayValue);
json::Value const arr(json::ValueType::Array);
j[sfHashes] = arr;
STParsedJSONObject obj("Test", j);
BEAST_EXPECT(obj.object.has_value());
@@ -997,7 +997,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test array with invalid hex string (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value arr(json::ValueType::Array);
arr.append("nothexstring");
j[sfHashes] = arr;
STParsedJSONObject const obj("Test", j);
@@ -1007,7 +1007,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test array with string of wrong length (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value arr(json::ValueType::Array);
arr.append("0123456789ABCDEF"); // too short for uint256
j[sfHashes] = arr;
STParsedJSONObject const obj("Test", j);
@@ -1017,7 +1017,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test array with non-string element (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value arr(json::ValueType::Array);
arr.append(12345);
j[sfHashes] = arr;
STParsedJSONObject const obj("Test", j);
@@ -1035,8 +1035,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test array with object element (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value objElem(json::ObjectValue);
json::Value arr(json::ValueType::Array);
json::Value objElem(json::ValueType::Object);
objElem["foo"] = "bar";
arr.append(objElem);
j[sfHashes] = arr;
@@ -1119,7 +1119,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Array value for AccountID (should fail)
{
json::Value j;
j[sfAccount] = json::Value(json::ArrayValue);
j[sfAccount] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1127,7 +1127,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Object value for AccountID (should fail)
{
json::Value j;
j[sfAccount] = json::Value(json::ObjectValue);
j[sfAccount] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1229,7 +1229,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Array value for currency (should fail)
{
json::Value j;
j[sfBaseAsset] = json::Value(json::ArrayValue);
j[sfBaseAsset] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1237,7 +1237,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Object value for currency (should fail)
{
json::Value j;
j[sfBaseAsset] = json::Value(json::ObjectValue);
j[sfBaseAsset] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1298,7 +1298,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with object value for Amount (should fail)
{
json::Value j;
j[sfAmount] = json::Value(json::ObjectValue);
j[sfAmount] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1311,13 +1311,13 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid test: single path with single element
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["account"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
elem["currency"] = "USD";
elem["issuer"] = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe";
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject obj("Test", j);
@@ -1343,13 +1343,13 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid test: non-standard currency code
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["account"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
elem["currency"] = "0123456789ABCDEF01230123456789ABCDEF0123";
elem["issuer"] = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe";
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject obj("Test", j);
@@ -1372,7 +1372,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with array containing non-array element (should fail)
{
json::Value j;
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append("notanarray");
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1383,9 +1383,9 @@ class STParsedJSON_test : public beast::unit_test::Suite
// fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value path(json::ValueType::Array);
path.append("notanobject");
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1396,11 +1396,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["foo"] = "bar"; // not a valid path element key
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1411,11 +1411,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// value (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["account"] = "notAValidBase58Account";
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1425,11 +1425,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with account not string (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["account"] = 12345;
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1439,11 +1439,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with currency not string (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["currency"] = 12345;
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1453,11 +1453,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with non-standard currency not hex (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["currency"] = "notAValidCurrency";
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1467,11 +1467,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with issuer not string (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["issuer"] = 12345;
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1481,11 +1481,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with issuer not base58 (should fail)
{
json::Value j;
json::Value path(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value path(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["issuer"] = "notAValidBase58Account";
path.append(elem);
json::Value pathset(json::ArrayValue);
json::Value pathset(json::ValueType::Array);
pathset.append(path);
j[sfPaths] = pathset;
STParsedJSONObject const obj("Test", j);
@@ -1500,7 +1500,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid Issue: currency and issuer as base58
{
json::Value j;
json::Value issueJson(json::ObjectValue);
json::Value issueJson(json::ValueType::Object);
issueJson["currency"] = "USD";
issueJson["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
j[sfAsset] = issueJson;
@@ -1523,7 +1523,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid Issue: currency as hex
{
json::Value j;
json::Value issueJson(json::ObjectValue);
json::Value issueJson(json::ValueType::Object);
issueJson["currency"] = "0123456789ABCDEF01230123456789ABCDEF0123";
issueJson["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
j[sfAsset] = issueJson;
@@ -1541,7 +1541,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid Issue: MPTID
{
json::Value j;
json::Value issueJson(json::ObjectValue);
json::Value issueJson(json::ValueType::Object);
issueJson["mpt_issuance_id"] = "0000000000000000000000004D5054494431323334234234";
j[sfAsset] = issueJson;
STParsedJSONObject obj("Test", j);
@@ -1557,7 +1557,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid Issue: missing currency
{
json::Value j;
json::Value issue(json::ObjectValue);
json::Value issue(json::ValueType::Object);
issue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
j[sfAsset] = issue;
STParsedJSONObject const obj("Test", j);
@@ -1567,7 +1567,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid Issue: missing issuer
{
json::Value j;
json::Value issue(json::ObjectValue);
json::Value issue(json::ValueType::Object);
issue["currency"] = "USD";
j[sfAsset] = issue;
STParsedJSONObject const obj("Test", j);
@@ -1577,7 +1577,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid Issue: currency too long
{
json::Value j;
json::Value issue(json::ObjectValue);
json::Value issue(json::ValueType::Object);
issue["currency"] = "USDD";
issue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
j[sfAsset] = issue;
@@ -1588,7 +1588,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid Issue: issuer not base58 or hex
{
json::Value j;
json::Value issue(json::ObjectValue);
json::Value issue(json::ValueType::Object);
issue["currency"] = "USD";
issue["issuer"] = "notAValidIssuer";
j[sfAsset] = issue;
@@ -1599,8 +1599,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid Issue: currency not string
{
json::Value j;
json::Value issue(json::ObjectValue);
issue["currency"] = json::Value(json::ArrayValue);
json::Value issue(json::ValueType::Object);
issue["currency"] = json::Value(json::ValueType::Array);
issue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
j[sfAsset] = issue;
STParsedJSONObject const obj("Test", j);
@@ -1610,9 +1610,9 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid Issue: issuer not string
{
json::Value j;
json::Value issue(json::ObjectValue);
json::Value issue(json::ValueType::Object);
issue["currency"] = "USD";
issue["issuer"] = json::Value(json::ObjectValue);
issue["issuer"] = json::Value(json::ValueType::Object);
j[sfAsset] = issue;
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
@@ -1634,11 +1634,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid XChainBridge
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value issuingChainIssue(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value issuingChainIssue(json::ValueType::Object);
issuingChainIssue["currency"] = "USD";
issuingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1659,11 +1659,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Valid XChainBridge: issues as hex currency
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value issuingChainIssue(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value issuingChainIssue(json::ValueType::Object);
issuingChainIssue["currency"] = "0123456789ABCDEF01230123456789ABCDEF0123";
issuingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "0123456789ABCDEF01230123456789ABCDEF0123";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1684,8 +1684,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: missing LockingChainIssue
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value issuingChainIssue(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value issuingChainIssue(json::ValueType::Object);
issuingChainIssue["currency"] = "USD";
issuingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["IssuingChainIssue"] = issuingChainIssue;
@@ -1699,8 +1699,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: missing IssuingChainIssue
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value lockingChainIssue(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1714,12 +1714,12 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: missing LockingChainDoor
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value issuingChainIssue(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value issuingChainIssue(json::ValueType::Object);
issuingChainIssue["currency"] = "USD";
issuingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["IssuingChainIssue"] = issuingChainIssue;
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1732,12 +1732,12 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: missing IssuingChainDoor
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value issuingChainIssue(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value issuingChainIssue(json::ValueType::Object);
issuingChainIssue["currency"] = "USD";
issuingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["IssuingChainIssue"] = issuingChainIssue;
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1750,7 +1750,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: IssuingChainIssue not an object
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
bridge["LockingChainIssue"] = "notanobject";
bridge["IssuingChainIssue"] = "notanobject";
j[sfXChainBridge] = bridge;
@@ -1761,10 +1761,10 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: IssuingChainIssue missing currency
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value asset(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value asset(json::ValueType::Object);
asset["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1777,10 +1777,10 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: asset missing issuer
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value asset(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value asset(json::ValueType::Object);
asset["currency"] = "USD";
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1793,11 +1793,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid XChainBridge: asset issuer not base58
{
json::Value j;
json::Value bridge(json::ObjectValue);
json::Value asset(json::ObjectValue);
json::Value bridge(json::ValueType::Object);
json::Value asset(json::ValueType::Object);
asset["currency"] = "USD";
asset["issuer"] = "notAValidBase58Account";
json::Value lockingChainIssue(json::ObjectValue);
json::Value lockingChainIssue(json::ValueType::Object);
lockingChainIssue["currency"] = "EUR";
lockingChainIssue["issuer"] = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
bridge["LockingChainIssue"] = lockingChainIssue;
@@ -1903,7 +1903,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid array value for STNumber
{
json::Value j;
j[sfNumber] = json::Value(json::ArrayValue);
j[sfNumber] = json::Value(json::ValueType::Array);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1911,7 +1911,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Invalid object value for STNumber
{
json::Value j;
j[sfNumber] = json::Value(json::ObjectValue);
j[sfNumber] = json::Value(json::ValueType::Object);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1932,7 +1932,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with valid object for Object
{
json::Value j;
json::Value objVal(json::ObjectValue);
json::Value objVal(json::ValueType::Object);
objVal[sfTransactionResult] = 1;
j[sfTransactionMetaData] = objVal;
STParsedJSONObject obj("Test", j);
@@ -1955,7 +1955,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with array value for Object (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value arr(json::ValueType::Array);
arr.append(1);
j[sfTransactionMetaData] = arr;
STParsedJSONObject const obj("Test", j);
@@ -1965,7 +1965,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with null value for Object (should fail)
{
json::Value j;
j[sfTransactionMetaData] = json::Value(json::NullValue);
j[sfTransactionMetaData] = json::Value(json::ValueType::Null);
STParsedJSONObject const obj("Test", j);
BEAST_EXPECT(!obj.object.has_value());
}
@@ -1974,11 +1974,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// max depth is 64
{
json::Value j;
json::Value obj(json::ObjectValue);
json::Value obj(json::ValueType::Object);
json::Value* current = &obj;
for (int i = 0; i < 63; ++i)
{
json::Value const next(json::ObjectValue);
json::Value const next(json::ValueType::Object);
(*current)[sfTransactionMetaData] = next;
current = &((*current)[sfTransactionMetaData]);
}
@@ -1993,11 +1993,11 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with depth exceeding maxDepth (should fail)
{
json::Value j;
json::Value obj(json::ObjectValue);
json::Value obj(json::ValueType::Object);
json::Value* current = &obj;
for (int i = 0; i < 64; ++i)
{
json::Value const next(json::ObjectValue);
json::Value const next(json::ValueType::Object);
(*current)[sfTransactionMetaData] = next;
current = &((*current)[sfTransactionMetaData]);
}
@@ -2015,10 +2015,10 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with valid array for Array
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value arr(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem[sfTransactionResult] = 2;
json::Value elem2(json::ObjectValue);
json::Value elem2(json::ValueType::Object);
elem2[sfTransactionMetaData] = elem;
arr.append(elem2);
j[sfSignerEntries] = arr;
@@ -2038,7 +2038,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with array containing non-object element (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value arr(json::ValueType::Array);
arr.append("notanobject");
j[sfSignerEntries] = arr;
STParsedJSONObject const obj("Test", j);
@@ -2048,8 +2048,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with array containing object with invalid field (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value arr(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem["invalidField"] = 1;
arr.append(elem);
j[sfSignerEntries] = arr;
@@ -2060,8 +2060,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with array containing object with multiple keys (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value arr(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem[sfTransactionResult] = 2;
elem[sfNetworkID] = 3;
arr.append(elem);
@@ -2082,8 +2082,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// (should fail)
{
json::Value j;
json::Value arr(json::ArrayValue);
json::Value elem(json::ObjectValue);
json::Value arr(json::ValueType::Array);
json::Value elem(json::ValueType::Object);
elem[sfTransactionResult] = "notanint";
arr.append(elem);
j[sfSignerEntries] = arr;
@@ -2094,7 +2094,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with empty array for Array (should be valid)
{
json::Value j;
json::Value const arr(json::ArrayValue);
json::Value const arr(json::ValueType::Array);
j[sfSignerEntries] = arr;
STParsedJSONObject obj("Test", j);
BEAST_EXPECT(obj.object.has_value());
@@ -2105,8 +2105,8 @@ class STParsedJSON_test : public beast::unit_test::Suite
// Test with object provided but not object SField
{
json::Value j;
json::Value obj(json::ArrayValue);
obj.append(json::Value(json::ObjectValue));
json::Value obj(json::ValueType::Array);
obj.append(json::Value(json::ValueType::Object));
obj[0u][sfTransactionResult] = 1;
j[sfSignerEntries] = obj;
STParsedJSONObject const parsed("Test", j);
@@ -2173,7 +2173,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
{
std::string const& serialized(
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
to_string(parsed.object->getJson(JsonOptions::KNone)));
to_string(parsed.object->getJson(JsonOptions::Values::None)));
BEAST_EXPECT(serialized == goodJson);
}
}
@@ -2198,7 +2198,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
{
std::string const& serialized(
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
to_string(parsed.object->getJson(JsonOptions::KNone)));
to_string(parsed.object->getJson(JsonOptions::Values::None)));
BEAST_EXPECT(serialized == expectedJson);
}
}
@@ -2223,7 +2223,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
{
std::string const& serialized(
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
to_string(parsed.object->getJson(JsonOptions::KNone)));
to_string(parsed.object->getJson(JsonOptions::Values::None)));
BEAST_EXPECT(serialized == expectedJson);
}
}
@@ -2332,7 +2332,7 @@ class STParsedJSON_test : public beast::unit_test::Suite
{
std::string const& serialized(
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
to_string(parsed.object->getJson(JsonOptions::KNone)));
to_string(parsed.object->getJson(JsonOptions::Values::None)));
BEAST_EXPECT(serialized == expectedJson);
}
}