20TEST(TransactionsAMMDepositTests, BuilderSettersRoundTrip)
23 auto const [publicKey, secretKey] =
49 builder.setAmount(amountValue);
50 builder.setAmount2(amount2Value);
51 builder.setEPrice(ePriceValue);
52 builder.setLPTokenOut(lPTokenOutValue);
53 builder.setTradingFee(tradingFeeValue);
55 auto tx = builder.build(publicKey, secretKey);
58 EXPECT_TRUE(tx.validate(reason)) << reason;
61 EXPECT_FALSE(tx.getSigningPubKey().empty());
62 EXPECT_TRUE(tx.hasTxnSignature());
65 EXPECT_EQ(tx.getAccount(), accountValue);
66 EXPECT_EQ(tx.getSequence(), sequenceValue);
67 EXPECT_EQ(tx.getFee(), feeValue);
71 auto const& expected = assetValue;
72 auto const actual = tx.getAsset();
77 auto const& expected = asset2Value;
78 auto const actual = tx.getAsset2();
84 auto const& expected = amountValue;
85 auto const actualOpt = tx.getAmount();
86 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
88 EXPECT_TRUE(tx.hasAmount());
92 auto const& expected = amount2Value;
93 auto const actualOpt = tx.getAmount2();
94 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount2 should be present";
96 EXPECT_TRUE(tx.hasAmount2());
100 auto const& expected = ePriceValue;
101 auto const actualOpt = tx.getEPrice();
102 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfEPrice should be present";
104 EXPECT_TRUE(tx.hasEPrice());
108 auto const& expected = lPTokenOutValue;
109 auto const actualOpt = tx.getLPTokenOut();
110 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLPTokenOut should be present";
112 EXPECT_TRUE(tx.hasLPTokenOut());
116 auto const& expected = tradingFeeValue;
117 auto const actualOpt = tx.getTradingFee();
118 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfTradingFee should be present";
120 EXPECT_TRUE(tx.hasTradingFee());
127TEST(TransactionsAMMDepositTests, BuilderFromStTxRoundTrip)
130 auto const [publicKey, secretKey] =
156 initialBuilder.setAmount(amountValue);
157 initialBuilder.setAmount2(amount2Value);
158 initialBuilder.setEPrice(ePriceValue);
159 initialBuilder.setLPTokenOut(lPTokenOutValue);
160 initialBuilder.setTradingFee(tradingFeeValue);
162 auto initialTx = initialBuilder.build(publicKey, secretKey);
167 auto rebuiltTx = builderFromTx.
build(publicKey, secretKey);
170 EXPECT_TRUE(rebuiltTx.validate(reason)) << reason;
173 EXPECT_EQ(rebuiltTx.getAccount(), accountValue);
174 EXPECT_EQ(rebuiltTx.getSequence(), sequenceValue);
175 EXPECT_EQ(rebuiltTx.getFee(), feeValue);
179 auto const& expected = assetValue;
180 auto const actual = rebuiltTx.getAsset();
185 auto const& expected = asset2Value;
186 auto const actual = rebuiltTx.getAsset2();
192 auto const& expected = amountValue;
193 auto const actualOpt = rebuiltTx.getAmount();
194 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount should be present";
199 auto const& expected = amount2Value;
200 auto const actualOpt = rebuiltTx.getAmount2();
201 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfAmount2 should be present";
206 auto const& expected = ePriceValue;
207 auto const actualOpt = rebuiltTx.getEPrice();
208 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfEPrice should be present";
213 auto const& expected = lPTokenOutValue;
214 auto const actualOpt = rebuiltTx.getLPTokenOut();
215 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfLPTokenOut should be present";
220 auto const& expected = tradingFeeValue;
221 auto const actualOpt = rebuiltTx.getTradingFee();
222 ASSERT_TRUE(actualOpt.has_value()) <<
"Optional field sfTradingFee should be present";
257TEST(TransactionsAMMDepositTests, OptionalFieldsReturnNullopt)
260 auto const [publicKey, secretKey] =
282 auto tx = builder.build(publicKey, secretKey);
285 EXPECT_FALSE(tx.hasAmount());
286 EXPECT_FALSE(tx.getAmount().has_value());
287 EXPECT_FALSE(tx.hasAmount2());
288 EXPECT_FALSE(tx.getAmount2().has_value());
289 EXPECT_FALSE(tx.hasEPrice());
290 EXPECT_FALSE(tx.getEPrice().has_value());
291 EXPECT_FALSE(tx.hasLPTokenOut());
292 EXPECT_FALSE(tx.getLPTokenOut().has_value());
293 EXPECT_FALSE(tx.hasTradingFee());
294 EXPECT_FALSE(tx.getTradingFee().has_value());