19TEST(AMMTests, BuilderSettersRoundTrip)
51 EXPECT_TRUE(builder.validate());
53 auto const entry = builder.build(index);
55 EXPECT_TRUE(entry.validate());
58 auto const& expected = accountValue;
59 auto const actual = entry.getAccount();
64 auto const& expected = lPTokenBalanceValue;
65 auto const actual = entry.getLPTokenBalance();
70 auto const& expected = assetValue;
71 auto const actual = entry.getAsset();
76 auto const& expected = asset2Value;
77 auto const actual = entry.getAsset2();
82 auto const& expected = ownerNodeValue;
83 auto const actual = entry.getOwnerNode();
88 auto const& expected = tradingFeeValue;
89 auto const actualOpt = entry.getTradingFee();
90 ASSERT_TRUE(actualOpt.has_value());
92 EXPECT_TRUE(entry.hasTradingFee());
96 auto const& expected = voteSlotsValue;
97 auto const actualOpt = entry.getVoteSlots();
98 ASSERT_TRUE(actualOpt.has_value());
100 EXPECT_TRUE(entry.hasVoteSlots());
104 auto const& expected = auctionSlotValue;
105 auto const actualOpt = entry.getAuctionSlot();
106 ASSERT_TRUE(actualOpt.has_value());
108 EXPECT_TRUE(entry.hasAuctionSlot());
112 auto const& expected = previousTxnIDValue;
113 auto const actualOpt = entry.getPreviousTxnID();
114 ASSERT_TRUE(actualOpt.has_value());
116 EXPECT_TRUE(entry.hasPreviousTxnID());
120 auto const& expected = previousTxnLgrSeqValue;
121 auto const actualOpt = entry.getPreviousTxnLgrSeq();
122 ASSERT_TRUE(actualOpt.has_value());
124 EXPECT_TRUE(entry.hasPreviousTxnLgrSeq());
127 EXPECT_TRUE(entry.hasLedgerIndex());
128 auto const ledgerIndex = entry.getLedgerIndex();
129 ASSERT_TRUE(ledgerIndex.has_value());
130 EXPECT_EQ(*ledgerIndex, index);
131 EXPECT_EQ(entry.getKey(), index);
136TEST(AMMTests, BuilderFromSleRoundTrip)
153 sle->at(sfAccount) = accountValue;
154 sle->at(sfTradingFee) = tradingFeeValue;
155 sle->setFieldArray(sfVoteSlots, voteSlotsValue);
156 sle->setFieldObject(sfAuctionSlot, auctionSlotValue);
157 sle->at(sfLPTokenBalance) = lPTokenBalanceValue;
158 sle->at(sfAsset) =
STIssue(sfAsset, assetValue);
159 sle->at(sfAsset2) =
STIssue(sfAsset2, asset2Value);
160 sle->at(sfOwnerNode) = ownerNodeValue;
161 sle->at(sfPreviousTxnID) = previousTxnIDValue;
162 sle->at(sfPreviousTxnLgrSeq) = previousTxnLgrSeqValue;
165 EXPECT_TRUE(builderFromSle.validate());
167 auto const entryFromBuilder = builderFromSle.build(index);
169 AMM entryFromSle{sle};
170 EXPECT_TRUE(entryFromBuilder.validate());
171 EXPECT_TRUE(entryFromSle.validate());
174 auto const& expected = accountValue;
176 auto const fromSle = entryFromSle.getAccount();
177 auto const fromBuilder = entryFromBuilder.getAccount();
184 auto const& expected = lPTokenBalanceValue;
186 auto const fromSle = entryFromSle.getLPTokenBalance();
187 auto const fromBuilder = entryFromBuilder.getLPTokenBalance();
194 auto const& expected = assetValue;
196 auto const fromSle = entryFromSle.getAsset();
197 auto const fromBuilder = entryFromBuilder.getAsset();
204 auto const& expected = asset2Value;
206 auto const fromSle = entryFromSle.getAsset2();
207 auto const fromBuilder = entryFromBuilder.getAsset2();
214 auto const& expected = ownerNodeValue;
216 auto const fromSle = entryFromSle.getOwnerNode();
217 auto const fromBuilder = entryFromBuilder.getOwnerNode();
224 auto const& expected = tradingFeeValue;
226 auto const fromSleOpt = entryFromSle.getTradingFee();
227 auto const fromBuilderOpt = entryFromBuilder.getTradingFee();
229 ASSERT_TRUE(fromSleOpt.has_value());
230 ASSERT_TRUE(fromBuilderOpt.has_value());
237 auto const& expected = voteSlotsValue;
239 auto const fromSleOpt = entryFromSle.getVoteSlots();
240 auto const fromBuilderOpt = entryFromBuilder.getVoteSlots();
242 ASSERT_TRUE(fromSleOpt.has_value());
243 ASSERT_TRUE(fromBuilderOpt.has_value());
250 auto const& expected = auctionSlotValue;
252 auto const fromSleOpt = entryFromSle.getAuctionSlot();
253 auto const fromBuilderOpt = entryFromBuilder.getAuctionSlot();
255 ASSERT_TRUE(fromSleOpt.has_value());
256 ASSERT_TRUE(fromBuilderOpt.has_value());
263 auto const& expected = previousTxnIDValue;
265 auto const fromSleOpt = entryFromSle.getPreviousTxnID();
266 auto const fromBuilderOpt = entryFromBuilder.getPreviousTxnID();
268 ASSERT_TRUE(fromSleOpt.has_value());
269 ASSERT_TRUE(fromBuilderOpt.has_value());
276 auto const& expected = previousTxnLgrSeqValue;
278 auto const fromSleOpt = entryFromSle.getPreviousTxnLgrSeq();
279 auto const fromBuilderOpt = entryFromBuilder.getPreviousTxnLgrSeq();
281 ASSERT_TRUE(fromSleOpt.has_value());
282 ASSERT_TRUE(fromBuilderOpt.has_value());
288 EXPECT_EQ(entryFromSle.getKey(), index);
289 EXPECT_EQ(entryFromBuilder.getKey(), index);
329TEST(AMMTests, OptionalFieldsReturnNullopt)
347 auto const entry = builder.build(index);
350 EXPECT_FALSE(entry.hasTradingFee());
351 EXPECT_FALSE(entry.getTradingFee().has_value());
352 EXPECT_FALSE(entry.hasVoteSlots());
353 EXPECT_FALSE(entry.getVoteSlots().has_value());
354 EXPECT_FALSE(entry.hasAuctionSlot());
355 EXPECT_FALSE(entry.getAuctionSlot().has_value());
356 EXPECT_FALSE(entry.hasPreviousTxnID());
357 EXPECT_FALSE(entry.getPreviousTxnID().has_value());
358 EXPECT_FALSE(entry.hasPreviousTxnLgrSeq());
359 EXPECT_FALSE(entry.getPreviousTxnLgrSeq().has_value());
std::shared_ptr< SLE const > getSle() const
Get the underlying SLE object.
Derived & setLedgerIndex(uint256 const &value)
Set the ledger index.