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/NFTokenAcceptOffer.h>
12#include <xrpl/protocol_autogen/transactions/AccountSet.h>
20TEST(TransactionsNFTokenAcceptOfferTests, 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);
64 auto const& expected = nFTokenBuyOfferValue;
65 auto const actualOpt = tx.getNFTokenBuyOffer();
66 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfNFTokenBuyOffer should be present";
68 EXPECT_TRUE(tx.hasNFTokenBuyOffer());
72 auto const& expected = nFTokenSellOfferValue;
73 auto const actualOpt = tx.getNFTokenSellOffer();
74 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfNFTokenSellOffer should be present";
76 EXPECT_TRUE(tx.hasNFTokenSellOffer());
80 auto const& expected = nFTokenBrokerFeeValue;
81 auto const actualOpt = tx.getNFTokenBrokerFee();
82 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfNFTokenBrokerFee should be present";
84 EXPECT_TRUE(tx.hasNFTokenBrokerFee());
91TEST(TransactionsNFTokenAcceptOfferTests, BuilderFromStTxRoundTrip)
94 auto const [publicKey, secretKey] =
118 auto initialTx = initialBuilder.
build(publicKey, secretKey);
123 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
126 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
129 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
130 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
131 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
136 auto const& expected = nFTokenBuyOfferValue;
137 auto const actualOpt = rebuiltTx.getNFTokenBuyOffer();
138 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfNFTokenBuyOffer should be present";
143 auto const& expected = nFTokenSellOfferValue;
144 auto const actualOpt = rebuiltTx.getNFTokenSellOffer();
145 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfNFTokenSellOffer should be present";
150 auto const& expected = nFTokenBrokerFeeValue;
151 auto const actualOpt = rebuiltTx.getNFTokenBrokerFee();
152 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfNFTokenBrokerFee should be present";
159TEST(TransactionsNFTokenAcceptOfferTests, WrapperThrowsOnWrongTxType)
162 auto const [pk, sk] =
167 auto wrongTx = wrongBuilder.
build(pk, sk);
173TEST(TransactionsNFTokenAcceptOfferTests, BuilderThrowsOnWrongTxType)
176 auto const [pk, sk] =
181 auto wrongTx = wrongBuilder.
build(pk, sk);
187TEST(TransactionsNFTokenAcceptOfferTests, OptionalFieldsReturnNullopt)
190 auto const [publicKey, secretKey] =
208 auto tx = builder.
build(publicKey, secretKey);
211 EXPECT_FALSE(tx.hasNFTokenBuyOffer());
212 EXPECT_FALSE(tx.getNFTokenBuyOffer().has_value());
213 EXPECT_FALSE(tx.hasNFTokenSellOffer());
214 EXPECT_FALSE(tx.getNFTokenSellOffer().has_value());
215 EXPECT_FALSE(tx.hasNFTokenBrokerFee());
216 EXPECT_FALSE(tx.getNFTokenBrokerFee().has_value());
Builder for AccountSet transactions.
AccountSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AccountSet wrapper.
Builder for NFTokenAcceptOffer transactions.
NFTokenAcceptOfferBuilder & setNFTokenBuyOffer(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Transaction-specific field setters.
NFTokenAcceptOffer build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the NFTokenAcceptOffer wrapper.
NFTokenAcceptOfferBuilder & setNFTokenSellOffer(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfNFTokenSellOffer (SoeOptional).
NFTokenAcceptOfferBuilder & setNFTokenBrokerFee(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfNFTokenBrokerFee (SoeOptional).
Transaction: NFTokenAcceptOffer.
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)