mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-27 09:00:32 +00:00
Update protocol autogen files
This commit is contained in:
@@ -51,7 +51,6 @@ TEST(LoanTests, BuilderSettersRoundTrip)
|
||||
LoanBuilder builder{
|
||||
previousTxnIDValue,
|
||||
previousTxnLgrSeqValue,
|
||||
ownerNodeValue,
|
||||
loanBrokerNodeValue,
|
||||
loanBrokerIDValue,
|
||||
loanSequenceValue,
|
||||
@@ -61,6 +60,7 @@ TEST(LoanTests, BuilderSettersRoundTrip)
|
||||
periodicPaymentValue
|
||||
};
|
||||
|
||||
builder.setOwnerNode(ownerNodeValue);
|
||||
builder.setLoanOriginationFee(loanOriginationFeeValue);
|
||||
builder.setLoanServiceFee(loanServiceFeeValue);
|
||||
builder.setLatePaymentFee(latePaymentFeeValue);
|
||||
@@ -100,12 +100,6 @@ TEST(LoanTests, BuilderSettersRoundTrip)
|
||||
expectEqualField(expected, actual, "sfPreviousTxnLgrSeq");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = ownerNodeValue;
|
||||
auto const actual = entry.getOwnerNode();
|
||||
expectEqualField(expected, actual, "sfOwnerNode");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = loanBrokerNodeValue;
|
||||
auto const actual = entry.getLoanBrokerNode();
|
||||
@@ -148,6 +142,14 @@ TEST(LoanTests, BuilderSettersRoundTrip)
|
||||
expectEqualField(expected, actual, "sfPeriodicPayment");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = ownerNodeValue;
|
||||
auto const actualOpt = entry.getOwnerNode();
|
||||
ASSERT_TRUE(actualOpt.has_value());
|
||||
expectEqualField(expected, *actualOpt, "sfOwnerNode");
|
||||
EXPECT_TRUE(entry.hasOwnerNode());
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = loanOriginationFeeValue;
|
||||
auto const actualOpt = entry.getLoanOriginationFee();
|
||||
@@ -384,16 +386,6 @@ TEST(LoanTests, BuilderFromSleRoundTrip)
|
||||
expectEqualField(expected, fromBuilder, "sfPreviousTxnLgrSeq");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = ownerNodeValue;
|
||||
|
||||
auto const fromSle = entryFromSle.getOwnerNode();
|
||||
auto const fromBuilder = entryFromBuilder.getOwnerNode();
|
||||
|
||||
expectEqualField(expected, fromSle, "sfOwnerNode");
|
||||
expectEqualField(expected, fromBuilder, "sfOwnerNode");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = loanBrokerNodeValue;
|
||||
|
||||
@@ -464,6 +456,19 @@ TEST(LoanTests, BuilderFromSleRoundTrip)
|
||||
expectEqualField(expected, fromBuilder, "sfPeriodicPayment");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = ownerNodeValue;
|
||||
|
||||
auto const fromSleOpt = entryFromSle.getOwnerNode();
|
||||
auto const fromBuilderOpt = entryFromBuilder.getOwnerNode();
|
||||
|
||||
ASSERT_TRUE(fromSleOpt.has_value());
|
||||
ASSERT_TRUE(fromBuilderOpt.has_value());
|
||||
|
||||
expectEqualField(expected, *fromSleOpt, "sfOwnerNode");
|
||||
expectEqualField(expected, *fromBuilderOpt, "sfOwnerNode");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = loanOriginationFeeValue;
|
||||
|
||||
@@ -732,7 +737,6 @@ TEST(LoanTests, OptionalFieldsReturnNullopt)
|
||||
|
||||
auto const previousTxnIDValue = canonical_UINT256();
|
||||
auto const previousTxnLgrSeqValue = canonical_UINT32();
|
||||
auto const ownerNodeValue = canonical_UINT64();
|
||||
auto const loanBrokerNodeValue = canonical_UINT64();
|
||||
auto const loanBrokerIDValue = canonical_UINT256();
|
||||
auto const loanSequenceValue = canonical_UINT32();
|
||||
@@ -744,7 +748,6 @@ TEST(LoanTests, OptionalFieldsReturnNullopt)
|
||||
LoanBuilder builder{
|
||||
previousTxnIDValue,
|
||||
previousTxnLgrSeqValue,
|
||||
ownerNodeValue,
|
||||
loanBrokerNodeValue,
|
||||
loanBrokerIDValue,
|
||||
loanSequenceValue,
|
||||
@@ -757,6 +760,8 @@ TEST(LoanTests, OptionalFieldsReturnNullopt)
|
||||
auto const entry = builder.build(index);
|
||||
|
||||
// Verify optional fields are not present
|
||||
EXPECT_FALSE(entry.hasOwnerNode());
|
||||
EXPECT_FALSE(entry.getOwnerNode().has_value());
|
||||
EXPECT_FALSE(entry.hasLoanOriginationFee());
|
||||
EXPECT_FALSE(entry.getLoanOriginationFee().has_value());
|
||||
EXPECT_FALSE(entry.hasLoanServiceFee());
|
||||
|
||||
@@ -35,6 +35,7 @@ TEST(VaultTests, BuilderSettersRoundTrip)
|
||||
auto const shareMPTIDValue = canonical_UINT192();
|
||||
auto const withdrawalPolicyValue = canonical_UINT8();
|
||||
auto const scaleValue = canonical_UINT8();
|
||||
auto const assetsReservedValue = canonical_NUMBER();
|
||||
|
||||
VaultBuilder builder{
|
||||
previousTxnIDValue,
|
||||
@@ -54,6 +55,7 @@ TEST(VaultTests, BuilderSettersRoundTrip)
|
||||
builder.setAssetsMaximum(assetsMaximumValue);
|
||||
builder.setLossUnrealized(lossUnrealizedValue);
|
||||
builder.setScale(scaleValue);
|
||||
builder.setAssetsReserved(assetsReservedValue);
|
||||
|
||||
builder.setLedgerIndex(index);
|
||||
builder.setFlags(0x1u);
|
||||
@@ -166,6 +168,14 @@ TEST(VaultTests, BuilderSettersRoundTrip)
|
||||
EXPECT_TRUE(entry.hasScale());
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = assetsReservedValue;
|
||||
auto const actualOpt = entry.getAssetsReserved();
|
||||
ASSERT_TRUE(actualOpt.has_value());
|
||||
expectEqualField(expected, *actualOpt, "sfAssetsReserved");
|
||||
EXPECT_TRUE(entry.hasAssetsReserved());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(entry.hasLedgerIndex());
|
||||
auto const ledgerIndex = entry.getLedgerIndex();
|
||||
ASSERT_TRUE(ledgerIndex.has_value());
|
||||
@@ -194,6 +204,7 @@ TEST(VaultTests, BuilderFromSleRoundTrip)
|
||||
auto const shareMPTIDValue = canonical_UINT192();
|
||||
auto const withdrawalPolicyValue = canonical_UINT8();
|
||||
auto const scaleValue = canonical_UINT8();
|
||||
auto const assetsReservedValue = canonical_NUMBER();
|
||||
|
||||
auto sle = std::make_shared<SLE>(Vault::entryType, index);
|
||||
|
||||
@@ -212,6 +223,7 @@ TEST(VaultTests, BuilderFromSleRoundTrip)
|
||||
sle->at(sfShareMPTID) = shareMPTIDValue;
|
||||
sle->at(sfWithdrawalPolicy) = withdrawalPolicyValue;
|
||||
sle->at(sfScale) = scaleValue;
|
||||
sle->at(sfAssetsReserved) = assetsReservedValue;
|
||||
|
||||
VaultBuilder builderFromSle{sle};
|
||||
EXPECT_TRUE(builderFromSle.validate());
|
||||
@@ -390,6 +402,19 @@ TEST(VaultTests, BuilderFromSleRoundTrip)
|
||||
expectEqualField(expected, *fromBuilderOpt, "sfScale");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = assetsReservedValue;
|
||||
|
||||
auto const fromSleOpt = entryFromSle.getAssetsReserved();
|
||||
auto const fromBuilderOpt = entryFromBuilder.getAssetsReserved();
|
||||
|
||||
ASSERT_TRUE(fromSleOpt.has_value());
|
||||
ASSERT_TRUE(fromBuilderOpt.has_value());
|
||||
|
||||
expectEqualField(expected, *fromSleOpt, "sfAssetsReserved");
|
||||
expectEqualField(expected, *fromBuilderOpt, "sfAssetsReserved");
|
||||
}
|
||||
|
||||
EXPECT_EQ(entryFromSle.getKey(), index);
|
||||
EXPECT_EQ(entryFromBuilder.getKey(), index);
|
||||
}
|
||||
@@ -472,5 +497,7 @@ TEST(VaultTests, OptionalFieldsReturnNullopt)
|
||||
EXPECT_FALSE(entry.getLossUnrealized().has_value());
|
||||
EXPECT_FALSE(entry.hasScale());
|
||||
EXPECT_FALSE(entry.getScale().has_value());
|
||||
EXPECT_FALSE(entry.hasAssetsReserved());
|
||||
EXPECT_FALSE(entry.getAssetsReserved().has_value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
// Auto-generated unit tests for transaction LoanAccept
|
||||
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <protocol_autogen/TestHelpers.h>
|
||||
|
||||
#include <xrpl/protocol/SecretKey.h>
|
||||
#include <xrpl/protocol/Seed.h>
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
#include <xrpl/protocol_autogen/transactions/LoanAccept.h>
|
||||
#include <xrpl/protocol_autogen/transactions/AccountSet.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace xrpl::transactions {
|
||||
|
||||
// 1 & 4) Set fields via builder setters, build, then read them back via
|
||||
// wrapper getters. After build(), validate() should succeed.
|
||||
TEST(TransactionsLoanAcceptTests, BuilderSettersRoundTrip)
|
||||
{
|
||||
// Generate a deterministic keypair for signing
|
||||
auto const [publicKey, secretKey] =
|
||||
generateKeyPair(KeyType::Secp256k1, generateSeed("testLoanAccept"));
|
||||
|
||||
// Common transaction fields
|
||||
auto const accountValue = calcAccountID(publicKey);
|
||||
std::uint32_t const sequenceValue = 1;
|
||||
auto const feeValue = canonical_AMOUNT();
|
||||
|
||||
// Transaction-specific field values
|
||||
auto const loanIDValue = canonical_UINT256();
|
||||
|
||||
LoanAcceptBuilder builder{
|
||||
accountValue,
|
||||
loanIDValue,
|
||||
sequenceValue,
|
||||
feeValue
|
||||
};
|
||||
|
||||
// Set optional fields
|
||||
|
||||
auto tx = builder.build(publicKey, secretKey);
|
||||
|
||||
std::string reason;
|
||||
EXPECT_TRUE(tx.validate(reason)) << reason;
|
||||
|
||||
// Verify signing was applied
|
||||
EXPECT_FALSE(tx.getSigningPubKey().empty());
|
||||
EXPECT_TRUE(tx.hasTxnSignature());
|
||||
|
||||
// Verify common fields
|
||||
EXPECT_EQ(tx.getAccount(), accountValue);
|
||||
EXPECT_EQ(tx.getSequence(), sequenceValue);
|
||||
EXPECT_EQ(tx.getFee(), feeValue);
|
||||
|
||||
// Verify required fields
|
||||
{
|
||||
auto const& expected = loanIDValue;
|
||||
auto const actual = tx.getLoanID();
|
||||
expectEqualField(expected, actual, "sfLoanID");
|
||||
}
|
||||
|
||||
// Verify optional fields
|
||||
}
|
||||
|
||||
// 2 & 4) Start from an STTx, construct a builder from it, build a new wrapper,
|
||||
// and verify all fields match.
|
||||
TEST(TransactionsLoanAcceptTests, BuilderFromStTxRoundTrip)
|
||||
{
|
||||
// Generate a deterministic keypair for signing
|
||||
auto const [publicKey, secretKey] =
|
||||
generateKeyPair(KeyType::Secp256k1, generateSeed("testLoanAcceptFromTx"));
|
||||
|
||||
// Common transaction fields
|
||||
auto const accountValue = calcAccountID(publicKey);
|
||||
std::uint32_t const sequenceValue = 2;
|
||||
auto const feeValue = canonical_AMOUNT();
|
||||
|
||||
// Transaction-specific field values
|
||||
auto const loanIDValue = canonical_UINT256();
|
||||
|
||||
// Build an initial transaction
|
||||
LoanAcceptBuilder initialBuilder{
|
||||
accountValue,
|
||||
loanIDValue,
|
||||
sequenceValue,
|
||||
feeValue
|
||||
};
|
||||
|
||||
|
||||
auto initialTx = initialBuilder.build(publicKey, secretKey);
|
||||
|
||||
// Create builder from existing STTx
|
||||
LoanAcceptBuilder builderFromTx{initialTx.getSTTx()};
|
||||
|
||||
auto rebuiltTx = builderFromTx.build(publicKey, secretKey);
|
||||
|
||||
std::string reason;
|
||||
EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
|
||||
|
||||
// Verify common fields
|
||||
EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
|
||||
EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
|
||||
EXPECT_EQ(rebuiltTx.getFee(), feeValue);
|
||||
|
||||
// Verify required fields
|
||||
{
|
||||
auto const& expected = loanIDValue;
|
||||
auto const actual = rebuiltTx.getLoanID();
|
||||
expectEqualField(expected, actual, "sfLoanID");
|
||||
}
|
||||
|
||||
// Verify optional fields
|
||||
}
|
||||
|
||||
// 3) Verify wrapper throws when constructed from wrong transaction type.
|
||||
TEST(TransactionsLoanAcceptTests, WrapperThrowsOnWrongTxType)
|
||||
{
|
||||
// Build a valid transaction of a different type
|
||||
auto const [pk, sk] =
|
||||
generateKeyPair(KeyType::Secp256k1, generateSeed("testWrongType"));
|
||||
auto const account = calcAccountID(pk);
|
||||
|
||||
AccountSetBuilder wrongBuilder{account, 1, canonical_AMOUNT()};
|
||||
auto wrongTx = wrongBuilder.build(pk, sk);
|
||||
|
||||
EXPECT_THROW(LoanAccept{wrongTx.getSTTx()}, std::runtime_error);
|
||||
}
|
||||
|
||||
// 4) Verify builder throws when constructed from wrong transaction type.
|
||||
TEST(TransactionsLoanAcceptTests, BuilderThrowsOnWrongTxType)
|
||||
{
|
||||
// Build a valid transaction of a different type
|
||||
auto const [pk, sk] =
|
||||
generateKeyPair(KeyType::Secp256k1, generateSeed("testWrongTypeBuilder"));
|
||||
auto const account = calcAccountID(pk);
|
||||
|
||||
AccountSetBuilder wrongBuilder{account, 1, canonical_AMOUNT()};
|
||||
auto wrongTx = wrongBuilder.build(pk, sk);
|
||||
|
||||
EXPECT_THROW(LoanAcceptBuilder{wrongTx.getSTTx()}, std::runtime_error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ TEST(TransactionsLoanSetTests, BuilderSettersRoundTrip)
|
||||
// Transaction-specific field values
|
||||
auto const loanBrokerIDValue = canonical_UINT256();
|
||||
auto const dataValue = canonical_VL();
|
||||
auto const borrowerValue = canonical_ACCOUNT();
|
||||
auto const counterpartyValue = canonical_ACCOUNT();
|
||||
auto const counterpartySignatureValue = canonical_OBJECT();
|
||||
auto const loanOriginationFeeValue = canonical_NUMBER();
|
||||
@@ -57,6 +58,7 @@ TEST(TransactionsLoanSetTests, BuilderSettersRoundTrip)
|
||||
|
||||
// Set optional fields
|
||||
builder.setData(dataValue);
|
||||
builder.setBorrower(borrowerValue);
|
||||
builder.setCounterparty(counterpartyValue);
|
||||
builder.setCounterpartySignature(counterpartySignatureValue);
|
||||
builder.setLoanOriginationFee(loanOriginationFeeValue);
|
||||
@@ -108,6 +110,14 @@ TEST(TransactionsLoanSetTests, BuilderSettersRoundTrip)
|
||||
EXPECT_TRUE(tx.hasData());
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = borrowerValue;
|
||||
auto const actualOpt = tx.getBorrower();
|
||||
ASSERT_TRUE(actualOpt.has_value()) << "Optional field sfBorrower should be present";
|
||||
expectEqualField(expected, *actualOpt, "sfBorrower");
|
||||
EXPECT_TRUE(tx.hasBorrower());
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = counterpartyValue;
|
||||
auto const actualOpt = tx.getCounterparty();
|
||||
@@ -238,6 +248,7 @@ TEST(TransactionsLoanSetTests, BuilderFromStTxRoundTrip)
|
||||
// Transaction-specific field values
|
||||
auto const loanBrokerIDValue = canonical_UINT256();
|
||||
auto const dataValue = canonical_VL();
|
||||
auto const borrowerValue = canonical_ACCOUNT();
|
||||
auto const counterpartyValue = canonical_ACCOUNT();
|
||||
auto const counterpartySignatureValue = canonical_OBJECT();
|
||||
auto const loanOriginationFeeValue = canonical_NUMBER();
|
||||
@@ -264,6 +275,7 @@ TEST(TransactionsLoanSetTests, BuilderFromStTxRoundTrip)
|
||||
};
|
||||
|
||||
initialBuilder.setData(dataValue);
|
||||
initialBuilder.setBorrower(borrowerValue);
|
||||
initialBuilder.setCounterparty(counterpartyValue);
|
||||
initialBuilder.setCounterpartySignature(counterpartySignatureValue);
|
||||
initialBuilder.setLoanOriginationFee(loanOriginationFeeValue);
|
||||
@@ -315,6 +327,13 @@ TEST(TransactionsLoanSetTests, BuilderFromStTxRoundTrip)
|
||||
expectEqualField(expected, *actualOpt, "sfData");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = borrowerValue;
|
||||
auto const actualOpt = rebuiltTx.getBorrower();
|
||||
ASSERT_TRUE(actualOpt.has_value()) << "Optional field sfBorrower should be present";
|
||||
expectEqualField(expected, *actualOpt, "sfBorrower");
|
||||
}
|
||||
|
||||
{
|
||||
auto const& expected = counterpartyValue;
|
||||
auto const actualOpt = rebuiltTx.getCounterparty();
|
||||
@@ -474,6 +493,8 @@ TEST(TransactionsLoanSetTests, OptionalFieldsReturnNullopt)
|
||||
// Verify optional fields are not present
|
||||
EXPECT_FALSE(tx.hasData());
|
||||
EXPECT_FALSE(tx.getData().has_value());
|
||||
EXPECT_FALSE(tx.hasBorrower());
|
||||
EXPECT_FALSE(tx.getBorrower().has_value());
|
||||
EXPECT_FALSE(tx.hasCounterparty());
|
||||
EXPECT_FALSE(tx.getCounterparty().has_value());
|
||||
EXPECT_FALSE(tx.hasCounterpartySignature());
|
||||
|
||||
Reference in New Issue
Block a user