mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 11:45:53 +00:00
@@ -36,11 +36,13 @@
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/SField.h>
|
||||
#include <ripple/protocol/STObject.h>
|
||||
#include <ripple/protocol/UintTypes.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <variant>
|
||||
@@ -502,3 +504,38 @@ TEST_F(RPCHelpersTest, TransactionAndMetadataBinaryJsonV2)
|
||||
EXPECT_TRUE(json.contains(JS(tx_blob)));
|
||||
EXPECT_TRUE(json.contains(JS(meta_blob)));
|
||||
}
|
||||
|
||||
TEST_F(RPCHelpersTest, ParseIssue)
|
||||
{
|
||||
auto issue = parseIssue(boost::json::parse(
|
||||
R"({
|
||||
"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun",
|
||||
"currency": "JPY"
|
||||
})"
|
||||
)
|
||||
.as_object());
|
||||
EXPECT_TRUE(issue.account == GetAccountIDWithString(ACCOUNT2));
|
||||
|
||||
issue = parseIssue(boost::json::parse(R"({"currency": "XRP"})").as_object());
|
||||
EXPECT_TRUE(ripple::isXRP(issue.currency));
|
||||
|
||||
EXPECT_THROW(parseIssue(boost::json::parse(R"({"currency": 2})").as_object()), std::runtime_error);
|
||||
|
||||
EXPECT_THROW(parseIssue(boost::json::parse(R"({"currency": "XRP2"})").as_object()), std::runtime_error);
|
||||
|
||||
EXPECT_THROW(
|
||||
parseIssue(boost::json::parse(
|
||||
R"({
|
||||
"issuer": "abcd",
|
||||
"currency": "JPY"
|
||||
})"
|
||||
)
|
||||
.as_object()),
|
||||
std::runtime_error
|
||||
);
|
||||
|
||||
EXPECT_THROW(
|
||||
parseIssue(boost::json::parse(R"({"issuer": "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun"})").as_object()),
|
||||
std::runtime_error
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,10 @@
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
#include <ripple/protocol/Issue.h>
|
||||
#include <ripple/protocol/LedgerFormats.h>
|
||||
#include <ripple/protocol/STObject.h>
|
||||
#include <ripple/protocol/STXChainBridge.h>
|
||||
#include <ripple/protocol/UintTypes.h>
|
||||
|
||||
#include <optional>
|
||||
@@ -49,6 +51,7 @@ using namespace testing;
|
||||
constexpr static auto INDEX1 = "05FB0EB4B899F056FA095537C5817163801F544BAFCEA39C995D76DB4D16F9DD";
|
||||
constexpr static auto ACCOUNT = "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn";
|
||||
constexpr static auto ACCOUNT2 = "rLEsXccBGNR3UPuPu2hUXPjziKC3qKSBun";
|
||||
constexpr static auto ACCOUNT3 = "rhzcyub9SbyZ4YF1JYskN5rLrTDUuLZG6D";
|
||||
constexpr static auto RANGEMIN = 10;
|
||||
constexpr static auto RANGEMAX = 30;
|
||||
constexpr static auto LEDGERHASH = "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652";
|
||||
@@ -881,6 +884,668 @@ generateTestValuesForParametersTest()
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeMissingBridgeAccount",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeCurrencyIsNumber",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": {},
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
1,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeIssuerIsNumber",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": {}
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeIssuingChainIssueIsNotObject",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue": 1
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeWithInvalidBridgeAccount",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "abcd",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeDoorInvalid",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "abcd",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeIssuerInvalid",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "invalid"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY"
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeIssueCurrencyInvalid",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "JPJPJP",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeIssueXRPCurrencyInvalid",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP",
|
||||
"issuer": "{}"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "JPY",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT2,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeIssueJPYCurrencyInvalid",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "JPY"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeMissingLockingChainDoor",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP",
|
||||
"issuer": "{}"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "JPY",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT2,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeMissingIssuingChainDoor",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "JPY",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeMissingLockingChainIssue",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "JPY",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeMissingIssuingChainIssue",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge":
|
||||
{{
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "JPY",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"BridgeInvalidType",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"bridge_account": "{}",
|
||||
"bridge": "invalid"
|
||||
}})",
|
||||
ACCOUNT
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedClaimIdInvalidType",
|
||||
R"({
|
||||
"xchain_owned_claim_id": 123
|
||||
})",
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedClaimIdJsonMissingClaimId",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_claim_id":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedClaimIdJsonMissingDoor",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_claim_id":
|
||||
{{
|
||||
"xchain_owned_claim_id": 10,
|
||||
"LockingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedClaimIdJsonMissingIssue",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_claim_id":
|
||||
{{
|
||||
"xchain_owned_claim_id": 10,
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT
|
||||
),
|
||||
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedClaimIdJsonInvalidDoor",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_claim_id":
|
||||
{{
|
||||
"xchain_owned_claim_id": 10,
|
||||
"LockingChainDoor": "abcd",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedClaimIdJsonInvalidIssue",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_claim_id":
|
||||
{{
|
||||
"xchain_owned_claim_id": 10,
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY"
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedCreateAccountClaimIdInvalidType",
|
||||
R"({
|
||||
"xchain_owned_create_account_claim_id": 123
|
||||
})",
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedCreateAccountClaimIdJsonMissingClaimId",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_create_account_claim_id":
|
||||
{{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedCreateAccountClaimIdJsonMissingDoor",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_create_account_claim_id":
|
||||
{{
|
||||
"xchain_owned_create_account_claim_id": 10,
|
||||
"LockingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedCreateAccountClaimIdJsonMissingIssue",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_create_account_claim_id":
|
||||
{{
|
||||
"xchain_owned_create_account_claim_id": 10,
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT
|
||||
),
|
||||
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedCreateAccountClaimIdJsonInvalidDoor",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_create_account_claim_id":
|
||||
{{
|
||||
"xchain_owned_create_account_claim_id": 10,
|
||||
"LockingChainDoor": "abcd",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}",
|
||||
"issuer": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
"JPY",
|
||||
ACCOUNT2
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
ParamTestCaseBundle{
|
||||
"OwnedCreateAccountClaimIdJsonInvalidIssue",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"xchain_owned_create_account_claim_id":
|
||||
{{
|
||||
"xchain_owned_create_account_claim_id": 10,
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue":
|
||||
{{
|
||||
"currency": "XRP"
|
||||
}},
|
||||
"IssuingChainIssue":
|
||||
{{
|
||||
"currency": "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
"JPY"
|
||||
),
|
||||
"malformedRequest",
|
||||
"Malformed request."
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1314,7 +1979,145 @@ generateTestValuesForNormalPathTest()
|
||||
),
|
||||
ripple::keylet::amm(GetIssue("XRP", ripple::toBase58(ripple::xrpAccount())), GetIssue("JPY", ACCOUNT2)).key,
|
||||
CreateAMMObject(ACCOUNT, "XRP", ripple::toBase58(ripple::xrpAccount()), "JPY", ACCOUNT2)
|
||||
}
|
||||
},
|
||||
NormalPathTestBundle{
|
||||
"BridgeLocking",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"binary": true,
|
||||
"bridge_account": "{}",
|
||||
"bridge": {{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue": {{
|
||||
"currency" : "XRP"
|
||||
}},
|
||||
"IssuingChainIssue": {{
|
||||
"currency" : "JPY",
|
||||
"issuer" : "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT3
|
||||
),
|
||||
ripple::keylet::bridge(
|
||||
ripple::STXChainBridge(
|
||||
GetAccountIDWithString(ACCOUNT),
|
||||
ripple::xrpIssue(),
|
||||
GetAccountIDWithString(ACCOUNT2),
|
||||
GetIssue("JPY", ACCOUNT3)
|
||||
),
|
||||
ripple::STXChainBridge::ChainType::locking
|
||||
)
|
||||
.key,
|
||||
CreateBridgeObject(ACCOUNT, ACCOUNT, ACCOUNT2, "JPY", ACCOUNT3)
|
||||
},
|
||||
NormalPathTestBundle{
|
||||
"BridgeIssuing",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"binary": true,
|
||||
"bridge_account": "{}",
|
||||
"bridge": {{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue": {{
|
||||
"currency" : "XRP"
|
||||
}},
|
||||
"IssuingChainIssue": {{
|
||||
"currency" : "JPY",
|
||||
"issuer" : "{}"
|
||||
}}
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT2,
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT3
|
||||
),
|
||||
ripple::keylet::bridge(
|
||||
ripple::STXChainBridge(
|
||||
GetAccountIDWithString(ACCOUNT),
|
||||
ripple::xrpIssue(),
|
||||
GetAccountIDWithString(ACCOUNT2),
|
||||
GetIssue("JPY", ACCOUNT3)
|
||||
),
|
||||
ripple::STXChainBridge::ChainType::issuing
|
||||
)
|
||||
.key,
|
||||
CreateBridgeObject(ACCOUNT, ACCOUNT, ACCOUNT2, "JPY", ACCOUNT3)
|
||||
},
|
||||
NormalPathTestBundle{
|
||||
"XChainOwnedClaimId",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"binary": true,
|
||||
"xchain_owned_claim_id": {{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue": {{
|
||||
"currency" : "XRP"
|
||||
}},
|
||||
"IssuingChainIssue": {{
|
||||
"currency" : "JPY",
|
||||
"issuer" : "{}"
|
||||
}},
|
||||
"xchain_owned_claim_id": 10
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT3
|
||||
),
|
||||
ripple::keylet::xChainClaimID(
|
||||
ripple::STXChainBridge(
|
||||
GetAccountIDWithString(ACCOUNT),
|
||||
ripple::xrpIssue(),
|
||||
GetAccountIDWithString(ACCOUNT2),
|
||||
GetIssue("JPY", ACCOUNT3)
|
||||
),
|
||||
10
|
||||
)
|
||||
.key,
|
||||
CreateChainOwnedClaimIDObject(ACCOUNT, ACCOUNT, ACCOUNT2, "JPY", ACCOUNT3, ACCOUNT)
|
||||
},
|
||||
NormalPathTestBundle{
|
||||
"XChainOwnedCreateAccountClaimId",
|
||||
fmt::format(
|
||||
R"({{
|
||||
"binary": true,
|
||||
"xchain_owned_create_account_claim_id": {{
|
||||
"LockingChainDoor": "{}",
|
||||
"IssuingChainDoor": "{}",
|
||||
"LockingChainIssue": {{
|
||||
"currency" : "XRP"
|
||||
}},
|
||||
"IssuingChainIssue": {{
|
||||
"currency" : "JPY",
|
||||
"issuer" : "{}"
|
||||
}},
|
||||
"xchain_owned_create_account_claim_id": 10
|
||||
}}
|
||||
}})",
|
||||
ACCOUNT,
|
||||
ACCOUNT2,
|
||||
ACCOUNT3
|
||||
),
|
||||
ripple::keylet::xChainCreateAccountClaimID(
|
||||
ripple::STXChainBridge(
|
||||
GetAccountIDWithString(ACCOUNT),
|
||||
ripple::xrpIssue(),
|
||||
GetAccountIDWithString(ACCOUNT2),
|
||||
GetIssue("JPY", ACCOUNT3)
|
||||
),
|
||||
10
|
||||
)
|
||||
.key,
|
||||
CreateChainOwnedClaimIDObject(ACCOUNT, ACCOUNT, ACCOUNT2, "JPY", ACCOUNT3, ACCOUNT)
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <ripple/basics/Slice.h>
|
||||
#include <ripple/basics/base_uint.h>
|
||||
#include <ripple/basics/chrono.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/protocol/AMMCore.h>
|
||||
#include <ripple/protocol/AccountID.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
@@ -838,6 +839,113 @@ CreateAMMObject(
|
||||
return amm;
|
||||
}
|
||||
|
||||
ripple::STObject
|
||||
CreateBridgeObject(
|
||||
std::string_view accountId,
|
||||
std::string_view lockingDoor,
|
||||
std::string_view issuingDoor,
|
||||
std::string_view issuingCurrency,
|
||||
std::string_view issuingIssuer
|
||||
)
|
||||
{
|
||||
auto bridge = ripple::STObject(ripple::sfLedgerEntry);
|
||||
bridge.setFieldU16(ripple::sfLedgerEntryType, ripple::ltBRIDGE);
|
||||
bridge.setAccountID(ripple::sfAccount, GetAccountIDWithString(accountId));
|
||||
bridge.setFieldAmount(ripple::sfSignatureReward, ripple::STAmount(10, false));
|
||||
bridge.setFieldU64(ripple::sfXChainClaimID, 100);
|
||||
bridge.setFieldU64(ripple::sfXChainAccountCreateCount, 100);
|
||||
bridge.setFieldU64(ripple::sfXChainAccountClaimCount, 100);
|
||||
bridge.setFieldU64(ripple::sfOwnerNode, 100);
|
||||
bridge.setFieldH256(ripple::sfPreviousTxnID, ripple::uint256{});
|
||||
bridge.setFieldU32(ripple::sfPreviousTxnLgrSeq, 0);
|
||||
bridge.setFieldU32(ripple::sfFlags, 0);
|
||||
Json::Value lockingIssue;
|
||||
lockingIssue["currency"] = "XRP";
|
||||
Json::Value issuingIssue;
|
||||
issuingIssue["currency"] = std::string(issuingCurrency);
|
||||
issuingIssue["issuer"] = std::string(issuingIssuer);
|
||||
|
||||
bridge[ripple::sfXChainBridge] = ripple::STXChainBridge(
|
||||
GetAccountIDWithString(lockingDoor),
|
||||
ripple::issueFromJson(lockingIssue),
|
||||
GetAccountIDWithString(issuingDoor),
|
||||
ripple::issueFromJson(issuingIssue)
|
||||
);
|
||||
bridge.setFieldU32(ripple::sfFlags, 0);
|
||||
return bridge;
|
||||
}
|
||||
|
||||
ripple::STObject
|
||||
CreateChainOwnedClaimIDObject(
|
||||
std::string_view accountId,
|
||||
std::string_view lockingDoor,
|
||||
std::string_view issuingDoor,
|
||||
std::string_view issuingCurrency,
|
||||
std::string_view issuingIssuer,
|
||||
std::string_view otherChainSource
|
||||
)
|
||||
{
|
||||
auto chainOwnedClaimID = ripple::STObject(ripple::sfLedgerEntry);
|
||||
chainOwnedClaimID.setFieldU16(ripple::sfLedgerEntryType, ripple::ltXCHAIN_OWNED_CLAIM_ID);
|
||||
chainOwnedClaimID.setAccountID(ripple::sfAccount, GetAccountIDWithString(accountId));
|
||||
chainOwnedClaimID.setFieldAmount(ripple::sfSignatureReward, ripple::STAmount(10, false));
|
||||
chainOwnedClaimID.setFieldU64(ripple::sfXChainClaimID, 100);
|
||||
chainOwnedClaimID.setFieldU64(ripple::sfOwnerNode, 100);
|
||||
chainOwnedClaimID.setFieldH256(ripple::sfPreviousTxnID, ripple::uint256{});
|
||||
chainOwnedClaimID.setFieldU32(ripple::sfPreviousTxnLgrSeq, 0);
|
||||
chainOwnedClaimID.setFieldU32(ripple::sfFlags, 0);
|
||||
Json::Value lockingIssue;
|
||||
lockingIssue["currency"] = "XRP";
|
||||
Json::Value issuingIssue;
|
||||
issuingIssue["currency"] = std::string(issuingCurrency);
|
||||
issuingIssue["issuer"] = std::string(issuingIssuer);
|
||||
|
||||
chainOwnedClaimID[ripple::sfXChainBridge] = ripple::STXChainBridge(
|
||||
GetAccountIDWithString(lockingDoor),
|
||||
ripple::issueFromJson(lockingIssue),
|
||||
GetAccountIDWithString(issuingDoor),
|
||||
ripple::issueFromJson(issuingIssue)
|
||||
);
|
||||
chainOwnedClaimID.setFieldU32(ripple::sfFlags, 0);
|
||||
chainOwnedClaimID.setAccountID(ripple::sfOtherChainSource, GetAccountIDWithString(otherChainSource));
|
||||
chainOwnedClaimID.setFieldArray(ripple::sfXChainClaimAttestations, ripple::STArray{});
|
||||
return chainOwnedClaimID;
|
||||
}
|
||||
|
||||
ripple::STObject
|
||||
CreateChainOwnedCreateAccountClaimID(
|
||||
std::string_view accountId,
|
||||
std::string_view lockingDoor,
|
||||
std::string_view issuingDoor,
|
||||
std::string_view issuingCurrency,
|
||||
std::string_view issuingIssuer
|
||||
)
|
||||
{
|
||||
auto chainOwnedCreateAccountClaimID = ripple::STObject(ripple::sfLedgerEntry);
|
||||
chainOwnedCreateAccountClaimID.setFieldU16(ripple::sfLedgerEntryType, ripple::ltXCHAIN_OWNED_CLAIM_ID);
|
||||
chainOwnedCreateAccountClaimID.setAccountID(ripple::sfAccount, GetAccountIDWithString(accountId));
|
||||
chainOwnedCreateAccountClaimID.setFieldU64(ripple::sfXChainAccountCreateCount, 100);
|
||||
chainOwnedCreateAccountClaimID.setFieldU64(ripple::sfOwnerNode, 100);
|
||||
chainOwnedCreateAccountClaimID.setFieldH256(ripple::sfPreviousTxnID, ripple::uint256{});
|
||||
chainOwnedCreateAccountClaimID.setFieldU32(ripple::sfPreviousTxnLgrSeq, 0);
|
||||
chainOwnedCreateAccountClaimID.setFieldU32(ripple::sfFlags, 0);
|
||||
Json::Value lockingIssue;
|
||||
lockingIssue["currency"] = "XRP";
|
||||
Json::Value issuingIssue;
|
||||
issuingIssue["currency"] = std::string(issuingCurrency);
|
||||
issuingIssue["issuer"] = std::string(issuingIssuer);
|
||||
|
||||
chainOwnedCreateAccountClaimID[ripple::sfXChainBridge] = ripple::STXChainBridge(
|
||||
GetAccountIDWithString(lockingDoor),
|
||||
ripple::issueFromJson(lockingIssue),
|
||||
GetAccountIDWithString(issuingDoor),
|
||||
ripple::issueFromJson(issuingIssue)
|
||||
);
|
||||
chainOwnedCreateAccountClaimID.setFieldU32(ripple::sfFlags, 0);
|
||||
chainOwnedCreateAccountClaimID.setFieldArray(ripple::sfXChainCreateAccountAttestations, ripple::STArray{});
|
||||
return chainOwnedCreateAccountClaimID;
|
||||
}
|
||||
|
||||
void
|
||||
AMMAddVoteSlot(ripple::STObject& amm, ripple::AccountID const& accountId, uint16_t tradingFee, uint32_t voteWeight)
|
||||
{
|
||||
|
||||
@@ -303,6 +303,34 @@ CreateAMMObject(
|
||||
uint64_t ownerNode = 0u
|
||||
);
|
||||
|
||||
[[nodiscard]] ripple::STObject
|
||||
CreateBridgeObject(
|
||||
std::string_view accountId,
|
||||
std::string_view lockingDoor,
|
||||
std::string_view issuingDoor,
|
||||
std::string_view issuingCurrency,
|
||||
std::string_view issuingIssuer
|
||||
);
|
||||
|
||||
[[nodiscard]] ripple::STObject
|
||||
CreateChainOwnedClaimIDObject(
|
||||
std::string_view accountId,
|
||||
std::string_view lockingDoor,
|
||||
std::string_view issuingDoor,
|
||||
std::string_view issuingCurrency,
|
||||
std::string_view issuingIssuer,
|
||||
std::string_view otherChainSource
|
||||
);
|
||||
|
||||
[[nodiscard]] ripple::STObject
|
||||
CreateChainOwnedCreateAccountClaimID(
|
||||
std::string_view accountId,
|
||||
std::string_view lockingDoor,
|
||||
std::string_view issuingDoor,
|
||||
std::string_view issuingCurrency,
|
||||
std::string_view issuingIssuer
|
||||
);
|
||||
|
||||
void
|
||||
AMMAddVoteSlot(ripple::STObject& amm, ripple::AccountID const& accountId, uint16_t tradingFee, uint32_t voteWeight);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user