20TEST(TransactionsCheckCreateTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
47 builder.setExpiration(expirationValue);
48 builder.setDestinationTag(destinationTagValue);
49 builder.setInvoiceID(invoiceIDValue);
51 auto tx = builder.build(publicKey, secretKey);
54 EXPECT_TRUE(tx.validate(reason)) << reason;
57 EXPECT_FALSE(tx.getSigningPubKey().empty());
58 EXPECT_TRUE(tx.hasTxnSignature());
61 EXPECT_EQ(tx.getAccount(), accountValue);
62 EXPECT_EQ(tx.getSequence(), sequenceValue);
63 EXPECT_EQ(tx.getFee(), feeValue);
67 auto const& expected = destinationValue;
68 auto const actual = tx.getDestination();
73 auto const& expected = sendMaxValue;
74 auto const actual = tx.getSendMax();
80 auto const& expected = expirationValue;
81 auto const actualOpt = tx.getExpiration();
82 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfExpiration should be present";
84 EXPECT_TRUE(tx.hasExpiration());
88 auto const& expected = destinationTagValue;
89 auto const actualOpt = tx.getDestinationTag();
90 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDestinationTag should be present";
92 EXPECT_TRUE(tx.hasDestinationTag());
96 auto const& expected = invoiceIDValue;
97 auto const actualOpt = tx.getInvoiceID();
98 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfInvoiceID should be present";
100 EXPECT_TRUE(tx.hasInvoiceID());
107TEST(TransactionsCheckCreateTests, BuilderFromStTxRoundTrip)
110 auto const [publicKey, secretKey] =
134 initialBuilder.setExpiration(expirationValue);
135 initialBuilder.setDestinationTag(destinationTagValue);
136 initialBuilder.setInvoiceID(invoiceIDValue);
138 auto initialTx = initialBuilder.build(publicKey, secretKey);
143 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
146 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
149 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
150 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
151 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
155 auto const& expected = destinationValue;
156 auto const actual = rebuiltTx.getDestination();
161 auto const& expected = sendMaxValue;
162 auto const actual = rebuiltTx.getSendMax();
168 auto const& expected = expirationValue;
169 auto const actualOpt = rebuiltTx.getExpiration();
170 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfExpiration should be present";
175 auto const& expected = destinationTagValue;
176 auto const actualOpt = rebuiltTx.getDestinationTag();
177 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDestinationTag should be present";
182 auto const& expected = invoiceIDValue;
183 auto const actualOpt = rebuiltTx.getInvoiceID();
184 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfInvoiceID should be present";
219TEST(TransactionsCheckCreateTests, OptionalFieldsReturnNullopt)
222 auto const [publicKey, secretKey] =
244 auto tx = builder.build(publicKey, secretKey);
247 EXPECT_FALSE(tx.hasExpiration());
248 EXPECT_FALSE(tx.getExpiration().has_value());
249 EXPECT_FALSE(tx.hasDestinationTag());
250 EXPECT_FALSE(tx.getDestinationTag().has_value());
251 EXPECT_FALSE(tx.hasInvoiceID());
252 EXPECT_FALSE(tx.getInvoiceID().has_value());