20TEST(TransactionsLoanSetTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
53 principalRequestedValue,
59 builder.setData(dataValue);
60 builder.setCounterparty(counterpartyValue);
61 builder.setCounterpartySignature(counterpartySignatureValue);
62 builder.setLoanOriginationFee(loanOriginationFeeValue);
63 builder.setLoanServiceFee(loanServiceFeeValue);
64 builder.setLatePaymentFee(latePaymentFeeValue);
65 builder.setClosePaymentFee(closePaymentFeeValue);
66 builder.setOverpaymentFee(overpaymentFeeValue);
67 builder.setInterestRate(interestRateValue);
68 builder.setLateInterestRate(lateInterestRateValue);
69 builder.setCloseInterestRate(closeInterestRateValue);
70 builder.setOverpaymentInterestRate(overpaymentInterestRateValue);
71 builder.setPaymentTotal(paymentTotalValue);
72 builder.setPaymentInterval(paymentIntervalValue);
73 builder.setGracePeriod(gracePeriodValue);
75 auto tx = builder.build(publicKey, secretKey);
78 EXPECT_TRUE(tx.validate(reason)) << reason;
81 EXPECT_FALSE(tx.getSigningPubKey().empty());
82 EXPECT_TRUE(tx.hasTxnSignature());
85 EXPECT_EQ(tx.getAccount(), accountValue);
86 EXPECT_EQ(tx.getSequence(), sequenceValue);
87 EXPECT_EQ(tx.getFee(), feeValue);
91 auto const& expected = loanBrokerIDValue;
92 auto const actual = tx.getLoanBrokerID();
97 auto const& expected = principalRequestedValue;
98 auto const actual = tx.getPrincipalRequested();
104 auto const& expected = dataValue;
105 auto const actualOpt = tx.getData();
106 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfData should be present";
108 EXPECT_TRUE(tx.hasData());
112 auto const& expected = counterpartyValue;
113 auto const actualOpt = tx.getCounterparty();
114 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCounterparty should be present";
116 EXPECT_TRUE(tx.hasCounterparty());
120 auto const& expected = counterpartySignatureValue;
121 auto const actualOpt = tx.getCounterpartySignature();
122 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCounterpartySignature should be present";
124 EXPECT_TRUE(tx.hasCounterpartySignature());
128 auto const& expected = loanOriginationFeeValue;
129 auto const actualOpt = tx.getLoanOriginationFee();
130 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLoanOriginationFee should be present";
132 EXPECT_TRUE(tx.hasLoanOriginationFee());
136 auto const& expected = loanServiceFeeValue;
137 auto const actualOpt = tx.getLoanServiceFee();
138 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLoanServiceFee should be present";
140 EXPECT_TRUE(tx.hasLoanServiceFee());
144 auto const& expected = latePaymentFeeValue;
145 auto const actualOpt = tx.getLatePaymentFee();
146 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLatePaymentFee should be present";
148 EXPECT_TRUE(tx.hasLatePaymentFee());
152 auto const& expected = closePaymentFeeValue;
153 auto const actualOpt = tx.getClosePaymentFee();
154 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfClosePaymentFee should be present";
156 EXPECT_TRUE(tx.hasClosePaymentFee());
160 auto const& expected = overpaymentFeeValue;
161 auto const actualOpt = tx.getOverpaymentFee();
162 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOverpaymentFee should be present";
164 EXPECT_TRUE(tx.hasOverpaymentFee());
168 auto const& expected = interestRateValue;
169 auto const actualOpt = tx.getInterestRate();
170 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfInterestRate should be present";
172 EXPECT_TRUE(tx.hasInterestRate());
176 auto const& expected = lateInterestRateValue;
177 auto const actualOpt = tx.getLateInterestRate();
178 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLateInterestRate should be present";
180 EXPECT_TRUE(tx.hasLateInterestRate());
184 auto const& expected = closeInterestRateValue;
185 auto const actualOpt = tx.getCloseInterestRate();
186 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCloseInterestRate should be present";
188 EXPECT_TRUE(tx.hasCloseInterestRate());
192 auto const& expected = overpaymentInterestRateValue;
193 auto const actualOpt = tx.getOverpaymentInterestRate();
194 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOverpaymentInterestRate should be present";
196 EXPECT_TRUE(tx.hasOverpaymentInterestRate());
200 auto const& expected = paymentTotalValue;
201 auto const actualOpt = tx.getPaymentTotal();
202 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPaymentTotal should be present";
204 EXPECT_TRUE(tx.hasPaymentTotal());
208 auto const& expected = paymentIntervalValue;
209 auto const actualOpt = tx.getPaymentInterval();
210 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPaymentInterval should be present";
212 EXPECT_TRUE(tx.hasPaymentInterval());
216 auto const& expected = gracePeriodValue;
217 auto const actualOpt = tx.getGracePeriod();
218 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfGracePeriod should be present";
220 EXPECT_TRUE(tx.hasGracePeriod());
227TEST(TransactionsLoanSetTests, BuilderFromStTxRoundTrip)
230 auto const [publicKey, secretKey] =
261 principalRequestedValue,
266 initialBuilder.setData(dataValue);
267 initialBuilder.setCounterparty(counterpartyValue);
268 initialBuilder.setCounterpartySignature(counterpartySignatureValue);
269 initialBuilder.setLoanOriginationFee(loanOriginationFeeValue);
270 initialBuilder.setLoanServiceFee(loanServiceFeeValue);
271 initialBuilder.setLatePaymentFee(latePaymentFeeValue);
272 initialBuilder.setClosePaymentFee(closePaymentFeeValue);
273 initialBuilder.setOverpaymentFee(overpaymentFeeValue);
274 initialBuilder.setInterestRate(interestRateValue);
275 initialBuilder.setLateInterestRate(lateInterestRateValue);
276 initialBuilder.setCloseInterestRate(closeInterestRateValue);
277 initialBuilder.setOverpaymentInterestRate(overpaymentInterestRateValue);
278 initialBuilder.setPaymentTotal(paymentTotalValue);
279 initialBuilder.setPaymentInterval(paymentIntervalValue);
280 initialBuilder.setGracePeriod(gracePeriodValue);
282 auto initialTx = initialBuilder.build(publicKey, secretKey);
287 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
290 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
293 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
294 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
295 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
299 auto const& expected = loanBrokerIDValue;
300 auto const actual = rebuiltTx.getLoanBrokerID();
305 auto const& expected = principalRequestedValue;
306 auto const actual = rebuiltTx.getPrincipalRequested();
312 auto const& expected = dataValue;
313 auto const actualOpt = rebuiltTx.getData();
314 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfData should be present";
319 auto const& expected = counterpartyValue;
320 auto const actualOpt = rebuiltTx.getCounterparty();
321 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCounterparty should be present";
326 auto const& expected = counterpartySignatureValue;
327 auto const actualOpt = rebuiltTx.getCounterpartySignature();
328 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCounterpartySignature should be present";
333 auto const& expected = loanOriginationFeeValue;
334 auto const actualOpt = rebuiltTx.getLoanOriginationFee();
335 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLoanOriginationFee should be present";
340 auto const& expected = loanServiceFeeValue;
341 auto const actualOpt = rebuiltTx.getLoanServiceFee();
342 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLoanServiceFee should be present";
347 auto const& expected = latePaymentFeeValue;
348 auto const actualOpt = rebuiltTx.getLatePaymentFee();
349 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLatePaymentFee should be present";
354 auto const& expected = closePaymentFeeValue;
355 auto const actualOpt = rebuiltTx.getClosePaymentFee();
356 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfClosePaymentFee should be present";
361 auto const& expected = overpaymentFeeValue;
362 auto const actualOpt = rebuiltTx.getOverpaymentFee();
363 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOverpaymentFee should be present";
368 auto const& expected = interestRateValue;
369 auto const actualOpt = rebuiltTx.getInterestRate();
370 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfInterestRate should be present";
375 auto const& expected = lateInterestRateValue;
376 auto const actualOpt = rebuiltTx.getLateInterestRate();
377 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLateInterestRate should be present";
382 auto const& expected = closeInterestRateValue;
383 auto const actualOpt = rebuiltTx.getCloseInterestRate();
384 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCloseInterestRate should be present";
389 auto const& expected = overpaymentInterestRateValue;
390 auto const actualOpt = rebuiltTx.getOverpaymentInterestRate();
391 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfOverpaymentInterestRate should be present";
396 auto const& expected = paymentTotalValue;
397 auto const actualOpt = rebuiltTx.getPaymentTotal();
398 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPaymentTotal should be present";
403 auto const& expected = paymentIntervalValue;
404 auto const actualOpt = rebuiltTx.getPaymentInterval();
405 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPaymentInterval should be present";
410 auto const& expected = gracePeriodValue;
411 auto const actualOpt = rebuiltTx.getGracePeriod();
412 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfGracePeriod should be present";
447TEST(TransactionsLoanSetTests, OptionalFieldsReturnNullopt)
450 auto const [publicKey, secretKey] =
465 principalRequestedValue,
472 auto tx = builder.build(publicKey, secretKey);
475 EXPECT_FALSE(tx.hasData());
476 EXPECT_FALSE(tx.getData().has_value());
477 EXPECT_FALSE(tx.hasCounterparty());
478 EXPECT_FALSE(tx.getCounterparty().has_value());
479 EXPECT_FALSE(tx.hasCounterpartySignature());
480 EXPECT_FALSE(tx.getCounterpartySignature().has_value());
481 EXPECT_FALSE(tx.hasLoanOriginationFee());
482 EXPECT_FALSE(tx.getLoanOriginationFee().has_value());
483 EXPECT_FALSE(tx.hasLoanServiceFee());
484 EXPECT_FALSE(tx.getLoanServiceFee().has_value());
485 EXPECT_FALSE(tx.hasLatePaymentFee());
486 EXPECT_FALSE(tx.getLatePaymentFee().has_value());
487 EXPECT_FALSE(tx.hasClosePaymentFee());
488 EXPECT_FALSE(tx.getClosePaymentFee().has_value());
489 EXPECT_FALSE(tx.hasOverpaymentFee());
490 EXPECT_FALSE(tx.getOverpaymentFee().has_value());
491 EXPECT_FALSE(tx.hasInterestRate());
492 EXPECT_FALSE(tx.getInterestRate().has_value());
493 EXPECT_FALSE(tx.hasLateInterestRate());
494 EXPECT_FALSE(tx.getLateInterestRate().has_value());
495 EXPECT_FALSE(tx.hasCloseInterestRate());
496 EXPECT_FALSE(tx.getCloseInterestRate().has_value());
497 EXPECT_FALSE(tx.hasOverpaymentInterestRate());
498 EXPECT_FALSE(tx.getOverpaymentInterestRate().has_value());
499 EXPECT_FALSE(tx.hasPaymentTotal());
500 EXPECT_FALSE(tx.getPaymentTotal().has_value());
501 EXPECT_FALSE(tx.hasPaymentInterval());
502 EXPECT_FALSE(tx.getPaymentInterval().has_value());
503 EXPECT_FALSE(tx.hasGracePeriod());
504 EXPECT_FALSE(tx.getGracePeriod().has_value());