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/XChainCreateBridge.h>
12#include <xrpl/protocol_autogen/transactions/AccountSet.h>
20TEST(TransactionsXChainCreateBridgeTests, 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 = xChainBridgeValue;
64 auto const actual = tx.getXChainBridge();
69 auto const& expected = signatureRewardValue;
70 auto const actual = tx.getSignatureReward();
76 auto const& expected = minAccountCreateAmountValue;
77 auto const actualOpt = tx.getMinAccountCreateAmount();
78 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfMinAccountCreateAmount should be present";
80 EXPECT_TRUE(tx.hasMinAccountCreateAmount());
87TEST(TransactionsXChainCreateBridgeTests, BuilderFromStTxRoundTrip)
90 auto const [publicKey, secretKey] =
107 signatureRewardValue,
114 auto initialTx = initialBuilder.
build(publicKey, secretKey);
119 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
122 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
125 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
126 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
127 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
131 auto const& expected = xChainBridgeValue;
132 auto const actual = rebuiltTx.getXChainBridge();
137 auto const& expected = signatureRewardValue;
138 auto const actual = rebuiltTx.getSignatureReward();
144 auto const& expected = minAccountCreateAmountValue;
145 auto const actualOpt = rebuiltTx.getMinAccountCreateAmount();
146 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfMinAccountCreateAmount should be present";
153TEST(TransactionsXChainCreateBridgeTests, WrapperThrowsOnWrongTxType)
156 auto const [pk, sk] =
161 auto wrongTx = wrongBuilder.
build(pk, sk);
167TEST(TransactionsXChainCreateBridgeTests, BuilderThrowsOnWrongTxType)
170 auto const [pk, sk] =
175 auto wrongTx = wrongBuilder.
build(pk, sk);
181TEST(TransactionsXChainCreateBridgeTests, OptionalFieldsReturnNullopt)
184 auto const [publicKey, secretKey] =
199 signatureRewardValue,
206 auto tx = builder.
build(publicKey, secretKey);
209 EXPECT_FALSE(tx.hasMinAccountCreateAmount());
210 EXPECT_FALSE(tx.getMinAccountCreateAmount().has_value());
Builder for AccountSet transactions.
AccountSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AccountSet wrapper.
Builder for XChainCreateBridge transactions.
XChainCreateBridgeBuilder & setMinAccountCreateAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfMinAccountCreateAmount (SoeOptional).
XChainCreateBridge build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the XChainCreateBridge wrapper.
Transaction: XChainCreateBridge.
TEST(TransactionsAccountDeleteTests, BuilderSettersRoundTrip)
Seed generateSeed(std::string const &passPhrase)
Generate a seed deterministically.
XChainBridgeValue canonical_XCHAIN_BRIDGE()
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)