20TEST(TransactionsSetFeeTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
48 builder.setLedgerSequence(ledgerSequenceValue);
49 builder.setBaseFee(baseFeeValue);
50 builder.setReferenceFeeUnits(referenceFeeUnitsValue);
51 builder.setReserveBase(reserveBaseValue);
52 builder.setReserveIncrement(reserveIncrementValue);
53 builder.setBaseFeeDrops(baseFeeDropsValue);
54 builder.setReserveBaseDrops(reserveBaseDropsValue);
55 builder.setReserveIncrementDrops(reserveIncrementDropsValue);
57 auto tx = builder.build(publicKey, secretKey);
60 EXPECT_TRUE(tx.validate(reason)) << reason;
63 EXPECT_FALSE(tx.getSigningPubKey().empty());
64 EXPECT_TRUE(tx.hasTxnSignature());
67 EXPECT_EQ(tx.getAccount(), accountValue);
68 EXPECT_EQ(tx.getSequence(), sequenceValue);
69 EXPECT_EQ(tx.getFee(), feeValue);
74 auto const& expected = ledgerSequenceValue;
75 auto const actualOpt = tx.getLedgerSequence();
76 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLedgerSequence should be present";
78 EXPECT_TRUE(tx.hasLedgerSequence());
82 auto const& expected = baseFeeValue;
83 auto const actualOpt = tx.getBaseFee();
84 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBaseFee should be present";
86 EXPECT_TRUE(tx.hasBaseFee());
90 auto const& expected = referenceFeeUnitsValue;
91 auto const actualOpt = tx.getReferenceFeeUnits();
92 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReferenceFeeUnits should be present";
94 EXPECT_TRUE(tx.hasReferenceFeeUnits());
98 auto const& expected = reserveBaseValue;
99 auto const actualOpt = tx.getReserveBase();
100 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveBase should be present";
102 EXPECT_TRUE(tx.hasReserveBase());
106 auto const& expected = reserveIncrementValue;
107 auto const actualOpt = tx.getReserveIncrement();
108 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveIncrement should be present";
110 EXPECT_TRUE(tx.hasReserveIncrement());
114 auto const& expected = baseFeeDropsValue;
115 auto const actualOpt = tx.getBaseFeeDrops();
116 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBaseFeeDrops should be present";
118 EXPECT_TRUE(tx.hasBaseFeeDrops());
122 auto const& expected = reserveBaseDropsValue;
123 auto const actualOpt = tx.getReserveBaseDrops();
124 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveBaseDrops should be present";
126 EXPECT_TRUE(tx.hasReserveBaseDrops());
130 auto const& expected = reserveIncrementDropsValue;
131 auto const actualOpt = tx.getReserveIncrementDrops();
132 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveIncrementDrops should be present";
134 EXPECT_TRUE(tx.hasReserveIncrementDrops());
141TEST(TransactionsSetFeeTests, BuilderFromStTxRoundTrip)
144 auto const [publicKey, secretKey] =
169 initialBuilder.setLedgerSequence(ledgerSequenceValue);
170 initialBuilder.setBaseFee(baseFeeValue);
171 initialBuilder.setReferenceFeeUnits(referenceFeeUnitsValue);
172 initialBuilder.setReserveBase(reserveBaseValue);
173 initialBuilder.setReserveIncrement(reserveIncrementValue);
174 initialBuilder.setBaseFeeDrops(baseFeeDropsValue);
175 initialBuilder.setReserveBaseDrops(reserveBaseDropsValue);
176 initialBuilder.setReserveIncrementDrops(reserveIncrementDropsValue);
178 auto initialTx = initialBuilder.build(publicKey, secretKey);
183 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
186 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
189 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
190 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
191 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
196 auto const& expected = ledgerSequenceValue;
197 auto const actualOpt = rebuiltTx.getLedgerSequence();
198 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLedgerSequence should be present";
203 auto const& expected = baseFeeValue;
204 auto const actualOpt = rebuiltTx.getBaseFee();
205 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBaseFee should be present";
210 auto const& expected = referenceFeeUnitsValue;
211 auto const actualOpt = rebuiltTx.getReferenceFeeUnits();
212 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReferenceFeeUnits should be present";
217 auto const& expected = reserveBaseValue;
218 auto const actualOpt = rebuiltTx.getReserveBase();
219 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveBase should be present";
224 auto const& expected = reserveIncrementValue;
225 auto const actualOpt = rebuiltTx.getReserveIncrement();
226 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveIncrement should be present";
231 auto const& expected = baseFeeDropsValue;
232 auto const actualOpt = rebuiltTx.getBaseFeeDrops();
233 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfBaseFeeDrops should be present";
238 auto const& expected = reserveBaseDropsValue;
239 auto const actualOpt = rebuiltTx.getReserveBaseDrops();
240 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveBaseDrops should be present";
245 auto const& expected = reserveIncrementDropsValue;
246 auto const actualOpt = rebuiltTx.getReserveIncrementDrops();
247 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfReserveIncrementDrops should be present";
282TEST(TransactionsSetFeeTests, OptionalFieldsReturnNullopt)
285 auto const [publicKey, secretKey] =
303 auto tx = builder.build(publicKey, secretKey);
306 EXPECT_FALSE(tx.hasLedgerSequence());
307 EXPECT_FALSE(tx.getLedgerSequence().has_value());
308 EXPECT_FALSE(tx.hasBaseFee());
309 EXPECT_FALSE(tx.getBaseFee().has_value());
310 EXPECT_FALSE(tx.hasReferenceFeeUnits());
311 EXPECT_FALSE(tx.getReferenceFeeUnits().has_value());
312 EXPECT_FALSE(tx.hasReserveBase());
313 EXPECT_FALSE(tx.getReserveBase().has_value());
314 EXPECT_FALSE(tx.hasReserveIncrement());
315 EXPECT_FALSE(tx.getReserveIncrement().has_value());
316 EXPECT_FALSE(tx.hasBaseFeeDrops());
317 EXPECT_FALSE(tx.getBaseFeeDrops().has_value());
318 EXPECT_FALSE(tx.hasReserveBaseDrops());
319 EXPECT_FALSE(tx.getReserveBaseDrops().has_value());
320 EXPECT_FALSE(tx.hasReserveIncrementDrops());
321 EXPECT_FALSE(tx.getReserveIncrementDrops().has_value());