4#include <gtest/gtest.h>
6#include <protocol_autogen/TestHelpers.h>
8#include <xrpl/protocol/SecretKey.h>
9#include <xrpl/protocol/Seed.h>
10#include <xrpl/protocol/STTx.h>
11#include <xrpl/protocol_autogen/transactions/LoanBrokerCoverClawback.h>
12#include <xrpl/protocol_autogen/transactions/AccountSet.h>
20TEST(TransactionsLoanBrokerCoverClawbackTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
45 auto tx = builder.
build(publicKey, secretKey);
48 EXPECT_TRUE(tx.validate(reason)) << reason;
51 EXPECT_FALSE(tx.getSigningPubKey().empty());
52 EXPECT_TRUE(tx.hasTxnSignature());
55 EXPECT_EQ(tx.getAccount(), accountValue);
56 EXPECT_EQ(tx.getSequence(), sequenceValue);
57 EXPECT_EQ(tx.getFee(), feeValue);
62 auto const& expected = loanBrokerIDValue;
63 auto const actualOpt = tx.getLoanBrokerID();
64 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLoanBrokerID should be present";
66 EXPECT_TRUE(tx.hasLoanBrokerID());
70 auto const& expected = amountValue;
71 auto const actualOpt = tx.getAmount();
72 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
74 EXPECT_TRUE(tx.hasAmount());
81TEST(TransactionsLoanBrokerCoverClawbackTests, BuilderFromStTxRoundTrip)
84 auto const [publicKey, secretKey] =
106 auto initialTx = initialBuilder.
build(publicKey, secretKey);
111 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
114 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
117 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
118 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
119 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
124 auto const& expected = loanBrokerIDValue;
125 auto const actualOpt = rebuiltTx.getLoanBrokerID();
126 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLoanBrokerID should be present";
131 auto const& expected = amountValue;
132 auto const actualOpt = rebuiltTx.getAmount();
133 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
140TEST(TransactionsLoanBrokerCoverClawbackTests, WrapperThrowsOnWrongTxType)
143 auto const [pk, sk] =
148 auto wrongTx = wrongBuilder.
build(pk, sk);
154TEST(TransactionsLoanBrokerCoverClawbackTests, BuilderThrowsOnWrongTxType)
157 auto const [pk, sk] =
162 auto wrongTx = wrongBuilder.
build(pk, sk);
168TEST(TransactionsLoanBrokerCoverClawbackTests, OptionalFieldsReturnNullopt)
171 auto const [publicKey, secretKey] =
189 auto tx = builder.
build(publicKey, secretKey);
192 EXPECT_FALSE(tx.hasLoanBrokerID());
193 EXPECT_FALSE(tx.getLoanBrokerID().has_value());
194 EXPECT_FALSE(tx.hasAmount());
195 EXPECT_FALSE(tx.getAmount().has_value());
Builder for AccountSet transactions.
AccountSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AccountSet wrapper.
Builder for LoanBrokerCoverClawback transactions.
LoanBrokerCoverClawbackBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (SoeOptional).
LoanBrokerCoverClawback build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the LoanBrokerCoverClawback wrapper.
LoanBrokerCoverClawbackBuilder & setLoanBrokerID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Transaction-specific field setters.
Transaction: LoanBrokerCoverClawback.
TEST(TransactionsAccountDeleteTests, BuilderSettersRoundTrip)
UInt256Value canonical_UINT256()
Seed generateSeed(std::string const &passPhrase)
Generate a seed deterministically.
std::pair< PublicKey, SecretKey > generateKeyPair(KeyType type, Seed const &seed)
Generate a key pair deterministically.
AmountValue canonical_AMOUNT()
AccountID calcAccountID(PublicKey const &pk)
void expectEqualField(T const &expected, T const &actual, char const *fieldName)