20TEST(TransactionsCheckCashTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
44 builder.setAmount(amountValue);
45 builder.setDeliverMin(deliverMinValue);
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 = checkIDValue;
64 auto const actual = tx.getCheckID();
70 auto const& expected = amountValue;
71 auto const actualOpt = tx.getAmount();
72 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
74 EXPECT_TRUE(tx.hasAmount());
78 auto const& expected = deliverMinValue;
79 auto const actualOpt = tx.getDeliverMin();
80 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDeliverMin should be present";
82 EXPECT_TRUE(tx.hasDeliverMin());
89TEST(TransactionsCheckCashTests, BuilderFromStTxRoundTrip)
92 auto const [publicKey, secretKey] =
113 initialBuilder.setAmount(amountValue);
114 initialBuilder.setDeliverMin(deliverMinValue);
116 auto initialTx = initialBuilder.build(publicKey, secretKey);
121 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
124 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
127 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
128 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
129 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
133 auto const& expected = checkIDValue;
134 auto const actual = rebuiltTx.getCheckID();
140 auto const& expected = amountValue;
141 auto const actualOpt = rebuiltTx.getAmount();
142 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
147 auto const& expected = deliverMinValue;
148 auto const actualOpt = rebuiltTx.getDeliverMin();
149 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfDeliverMin should be present";
184TEST(TransactionsCheckCashTests, OptionalFieldsReturnNullopt)
187 auto const [publicKey, secretKey] =
207 auto tx = builder.build(publicKey, secretKey);
210 EXPECT_FALSE(tx.hasAmount());
211 EXPECT_FALSE(tx.getAmount().has_value());
212 EXPECT_FALSE(tx.hasDeliverMin());
213 EXPECT_FALSE(tx.getDeliverMin().has_value());