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/NFTokenBurn.h>
12#include <xrpl/protocol_autogen/transactions/AccountSet.h>
20TEST(TransactionsNFTokenBurnTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
43 builder.setOwner(ownerValue);
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);
61 auto const& expected = nFTokenIDValue;
62 auto const actual = tx.getNFTokenID();
68 auto const& expected = ownerValue;
69 auto const actualOpt = tx.getOwner();
70 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOwner should be present";
72 EXPECT_TRUE(tx.hasOwner());
79TEST(TransactionsNFTokenBurnTests, BuilderFromStTxRoundTrip)
82 auto const [publicKey, secretKey] =
102 initialBuilder.setOwner(ownerValue);
104 auto initialTx = initialBuilder.build(publicKey, secretKey);
109 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
112 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
115 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
116 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
117 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
121 auto const& expected = nFTokenIDValue;
122 auto const actual = rebuiltTx.getNFTokenID();
128 auto const& expected = ownerValue;
129 auto const actualOpt = rebuiltTx.getOwner();
130 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOwner should be present";
137TEST(TransactionsNFTokenBurnTests, WrapperThrowsOnWrongTxType)
140 auto const [pk, sk] =
145 auto wrongTx = wrongBuilder.build(pk, sk);
151TEST(TransactionsNFTokenBurnTests, BuilderThrowsOnWrongTxType)
154 auto const [pk, sk] =
159 auto wrongTx = wrongBuilder.build(pk, sk);
165TEST(TransactionsNFTokenBurnTests, OptionalFieldsReturnNullopt)
168 auto const [publicKey, secretKey] =
188 auto tx = builder.build(publicKey, secretKey);
191 EXPECT_FALSE(tx.hasOwner());
192 EXPECT_FALSE(tx.getOwner().has_value());
Builder for AccountSet transactions.
Builder for NFTokenBurn transactions.
NFTokenBurn build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the NFTokenBurn wrapper.
Transaction: NFTokenBurn.
std::shared_ptr< STTx const > getSTTx() const
Get the underlying STTx object.
TEST(TransactionsAccountDeleteTests, BuilderSettersRoundTrip)
AccountValue canonical_ACCOUNT()
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)
Uint256Value canonical_UINT256()
void expectEqualField(T const &expected, T const &actual, char const *fieldName)