20TEST(TransactionsPaymentTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
51 builder.setSendMax(sendMaxValue);
52 builder.setPaths(pathsValue);
53 builder.setInvoiceID(invoiceIDValue);
54 builder.setDestinationTag(destinationTagValue);
55 builder.setDeliverMin(deliverMinValue);
56 builder.setCredentialIDs(credentialIDsValue);
57 builder.setDomainID(domainIDValue);
59 auto tx = builder.build(publicKey, secretKey);
62 EXPECT_TRUE(tx.validate(reason)) << reason;
65 EXPECT_FALSE(tx.getSigningPubKey().empty());
66 EXPECT_TRUE(tx.hasTxnSignature());
69 EXPECT_EQ(tx.getAccount(), accountValue);
70 EXPECT_EQ(tx.getSequence(), sequenceValue);
71 EXPECT_EQ(tx.getFee(), feeValue);
75 auto const& expected = destinationValue;
76 auto const actual = tx.getDestination();
81 auto const& expected = amountValue;
82 auto const actual = tx.getAmount();
88 auto const& expected = sendMaxValue;
89 auto const actualOpt = tx.getSendMax();
90 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfSendMax should be present";
92 EXPECT_TRUE(tx.hasSendMax());
96 auto const& expected = pathsValue;
97 auto const actualOpt = tx.getPaths();
98 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPaths should be present";
100 EXPECT_TRUE(tx.hasPaths());
104 auto const& expected = invoiceIDValue;
105 auto const actualOpt = tx.getInvoiceID();
106 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfInvoiceID should be present";
108 EXPECT_TRUE(tx.hasInvoiceID());
112 auto const& expected = destinationTagValue;
113 auto const actualOpt = tx.getDestinationTag();
114 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDestinationTag should be present";
116 EXPECT_TRUE(tx.hasDestinationTag());
120 auto const& expected = deliverMinValue;
121 auto const actualOpt = tx.getDeliverMin();
122 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDeliverMin should be present";
124 EXPECT_TRUE(tx.hasDeliverMin());
128 auto const& expected = credentialIDsValue;
129 auto const actualOpt = tx.getCredentialIDs();
130 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCredentialIDs should be present";
132 EXPECT_TRUE(tx.hasCredentialIDs());
136 auto const& expected = domainIDValue;
137 auto const actualOpt = tx.getDomainID();
138 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDomainID should be present";
140 EXPECT_TRUE(tx.hasDomainID());
147TEST(TransactionsPaymentTests, BuilderFromStTxRoundTrip)
150 auto const [publicKey, secretKey] =
178 initialBuilder.setSendMax(sendMaxValue);
179 initialBuilder.setPaths(pathsValue);
180 initialBuilder.setInvoiceID(invoiceIDValue);
181 initialBuilder.setDestinationTag(destinationTagValue);
182 initialBuilder.setDeliverMin(deliverMinValue);
183 initialBuilder.setCredentialIDs(credentialIDsValue);
184 initialBuilder.setDomainID(domainIDValue);
186 auto initialTx = initialBuilder.build(publicKey, secretKey);
191 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
194 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
197 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
198 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
199 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
203 auto const& expected = destinationValue;
204 auto const actual = rebuiltTx.getDestination();
209 auto const& expected = amountValue;
210 auto const actual = rebuiltTx.getAmount();
216 auto const& expected = sendMaxValue;
217 auto const actualOpt = rebuiltTx.getSendMax();
218 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfSendMax should be present";
223 auto const& expected = pathsValue;
224 auto const actualOpt = rebuiltTx.getPaths();
225 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfPaths should be present";
230 auto const& expected = invoiceIDValue;
231 auto const actualOpt = rebuiltTx.getInvoiceID();
232 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfInvoiceID should be present";
237 auto const& expected = destinationTagValue;
238 auto const actualOpt = rebuiltTx.getDestinationTag();
239 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDestinationTag should be present";
244 auto const& expected = deliverMinValue;
245 auto const actualOpt = rebuiltTx.getDeliverMin();
246 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDeliverMin should be present";
251 auto const& expected = credentialIDsValue;
252 auto const actualOpt = rebuiltTx.getCredentialIDs();
253 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfCredentialIDs should be present";
258 auto const& expected = domainIDValue;
259 auto const actualOpt = rebuiltTx.getDomainID();
260 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDomainID should be present";
295TEST(TransactionsPaymentTests, OptionalFieldsReturnNullopt)
298 auto const [publicKey, secretKey] =
320 auto tx = builder.build(publicKey, secretKey);
323 EXPECT_FALSE(tx.hasSendMax());
324 EXPECT_FALSE(tx.getSendMax().has_value());
325 EXPECT_FALSE(tx.hasPaths());
326 EXPECT_FALSE(tx.getPaths().has_value());
327 EXPECT_FALSE(tx.hasInvoiceID());
328 EXPECT_FALSE(tx.getInvoiceID().has_value());
329 EXPECT_FALSE(tx.hasDestinationTag());
330 EXPECT_FALSE(tx.getDestinationTag().has_value());
331 EXPECT_FALSE(tx.hasDeliverMin());
332 EXPECT_FALSE(tx.getDeliverMin().has_value());
333 EXPECT_FALSE(tx.hasCredentialIDs());
334 EXPECT_FALSE(tx.getCredentialIDs().has_value());
335 EXPECT_FALSE(tx.hasDomainID());
336 EXPECT_FALSE(tx.getDomainID().has_value());