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/LedgerStateFix.h>
12#include <xrpl/protocol_autogen/transactions/AccountSet.h>
20TEST(TransactionsLedgerStateFixTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
47 auto tx = builder.
build(publicKey, secretKey);
50 EXPECT_TRUE(tx.validate(reason)) << reason;
53 EXPECT_FALSE(tx.getSigningPubKey().empty());
54 EXPECT_TRUE(tx.hasTxnSignature());
57 EXPECT_EQ(tx.getAccount(), accountValue);
58 EXPECT_EQ(tx.getSequence(), sequenceValue);
59 EXPECT_EQ(tx.getFee(), feeValue);
63 auto const& expected = ledgerFixTypeValue;
64 auto const actual = tx.getLedgerFixType();
70 auto const& expected = ownerValue;
71 auto const actualOpt = tx.getOwner();
72 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOwner should be present";
74 EXPECT_TRUE(tx.hasOwner());
78 auto const& expected = bookDirectoryValue;
79 auto const actualOpt = tx.getBookDirectory();
80 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBookDirectory should be present";
82 EXPECT_TRUE(tx.hasBookDirectory());
89TEST(TransactionsLedgerStateFixTests, BuilderFromStTxRoundTrip)
92 auto const [publicKey, secretKey] =
113 initialBuilder.
setOwner(ownerValue);
116 auto initialTx = initialBuilder.
build(publicKey, secretKey);
121 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
124 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
127 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
128 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
129 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
133 auto const& expected = ledgerFixTypeValue;
134 auto const actual = rebuiltTx.getLedgerFixType();
140 auto const& expected = ownerValue;
141 auto const actualOpt = rebuiltTx.getOwner();
142 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOwner should be present";
147 auto const& expected = bookDirectoryValue;
148 auto const actualOpt = rebuiltTx.getBookDirectory();
149 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBookDirectory should be present";
156TEST(TransactionsLedgerStateFixTests, WrapperThrowsOnWrongTxType)
159 auto const [pk, sk] =
164 auto wrongTx = wrongBuilder.
build(pk, sk);
170TEST(TransactionsLedgerStateFixTests, BuilderThrowsOnWrongTxType)
173 auto const [pk, sk] =
178 auto wrongTx = wrongBuilder.
build(pk, sk);
184TEST(TransactionsLedgerStateFixTests, OptionalFieldsReturnNullopt)
187 auto const [publicKey, secretKey] =
207 auto tx = builder.
build(publicKey, secretKey);
210 EXPECT_FALSE(tx.hasOwner());
211 EXPECT_FALSE(tx.getOwner().has_value());
212 EXPECT_FALSE(tx.hasBookDirectory());
213 EXPECT_FALSE(tx.getBookDirectory().has_value());
Builder for AccountSet transactions.
AccountSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AccountSet wrapper.
Builder for LedgerStateFix transactions.
LedgerStateFixBuilder & setOwner(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfOwner (SoeOptional).
LedgerStateFix build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the LedgerStateFix wrapper.
LedgerStateFixBuilder & setBookDirectory(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfBookDirectory (SoeOptional).
Transaction: LedgerStateFix.
TEST(TransactionsAccountDeleteTests, BuilderSettersRoundTrip)
AccountValue canonical_ACCOUNT()
UInt16Value canonical_UINT16()
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)