19TEST(RippleStateTests, BuilderSettersRoundTrip)
42 previousTxnLgrSeqValue
59 auto const entry = builder.
build(index);
61 EXPECT_TRUE(entry.validate());
64 auto const& expected = balanceValue;
65 auto const actual = entry.getBalance();
70 auto const& expected = lowLimitValue;
71 auto const actual = entry.getLowLimit();
76 auto const& expected = highLimitValue;
77 auto const actual = entry.getHighLimit();
82 auto const& expected = previousTxnIDValue;
83 auto const actual = entry.getPreviousTxnID();
88 auto const& expected = previousTxnLgrSeqValue;
89 auto const actual = entry.getPreviousTxnLgrSeq();
94 auto const& expected = lowNodeValue;
95 auto const actualOpt = entry.getLowNode();
96 ASSERT_TRUE(actualOpt.has_value());
98 EXPECT_TRUE(entry.hasLowNode());
102 auto const& expected = lowQualityInValue;
103 auto const actualOpt = entry.getLowQualityIn();
104 ASSERT_TRUE(actualOpt.has_value());
106 EXPECT_TRUE(entry.hasLowQualityIn());
110 auto const& expected = lowQualityOutValue;
111 auto const actualOpt = entry.getLowQualityOut();
112 ASSERT_TRUE(actualOpt.has_value());
114 EXPECT_TRUE(entry.hasLowQualityOut());
118 auto const& expected = highNodeValue;
119 auto const actualOpt = entry.getHighNode();
120 ASSERT_TRUE(actualOpt.has_value());
122 EXPECT_TRUE(entry.hasHighNode());
126 auto const& expected = highQualityInValue;
127 auto const actualOpt = entry.getHighQualityIn();
128 ASSERT_TRUE(actualOpt.has_value());
130 EXPECT_TRUE(entry.hasHighQualityIn());
134 auto const& expected = highQualityOutValue;
135 auto const actualOpt = entry.getHighQualityOut();
136 ASSERT_TRUE(actualOpt.has_value());
138 EXPECT_TRUE(entry.hasHighQualityOut());
142 auto const& expected = highSponsorValue;
143 auto const actualOpt = entry.getHighSponsor();
144 ASSERT_TRUE(actualOpt.has_value());
146 EXPECT_TRUE(entry.hasHighSponsor());
150 auto const& expected = lowSponsorValue;
151 auto const actualOpt = entry.getLowSponsor();
152 ASSERT_TRUE(actualOpt.has_value());
154 EXPECT_TRUE(entry.hasLowSponsor());
157 EXPECT_TRUE(entry.hasLedgerIndex());
158 auto const ledgerIndex = entry.getLedgerIndex();
159 ASSERT_TRUE(ledgerIndex.has_value());
160 EXPECT_EQ(*ledgerIndex, index);
161 EXPECT_EQ(entry.getKey(), index);
166TEST(RippleStateTests, BuilderFromSleRoundTrip)
186 sle->at(sfBalance) = balanceValue;
187 sle->at(sfLowLimit) = lowLimitValue;
188 sle->at(sfHighLimit) = highLimitValue;
189 sle->at(sfPreviousTxnID) = previousTxnIDValue;
190 sle->at(sfPreviousTxnLgrSeq) = previousTxnLgrSeqValue;
191 sle->at(sfLowNode) = lowNodeValue;
192 sle->at(sfLowQualityIn) = lowQualityInValue;
193 sle->at(sfLowQualityOut) = lowQualityOutValue;
194 sle->at(sfHighNode) = highNodeValue;
195 sle->at(sfHighQualityIn) = highQualityInValue;
196 sle->at(sfHighQualityOut) = highQualityOutValue;
197 sle->at(sfHighSponsor) = highSponsorValue;
198 sle->at(sfLowSponsor) = lowSponsorValue;
201 EXPECT_TRUE(builderFromSle.
validate());
203 auto const entryFromBuilder = builderFromSle.
build(index);
206 EXPECT_TRUE(entryFromBuilder.validate());
207 EXPECT_TRUE(entryFromSle.
validate());
210 auto const& expected = balanceValue;
212 auto const fromSle = entryFromSle.
getBalance();
213 auto const fromBuilder = entryFromBuilder.getBalance();
220 auto const& expected = lowLimitValue;
223 auto const fromBuilder = entryFromBuilder.getLowLimit();
230 auto const& expected = highLimitValue;
233 auto const fromBuilder = entryFromBuilder.getHighLimit();
240 auto const& expected = previousTxnIDValue;
243 auto const fromBuilder = entryFromBuilder.getPreviousTxnID();
250 auto const& expected = previousTxnLgrSeqValue;
253 auto const fromBuilder = entryFromBuilder.getPreviousTxnLgrSeq();
260 auto const& expected = lowNodeValue;
262 auto const fromSleOpt = entryFromSle.
getLowNode();
263 auto const fromBuilderOpt = entryFromBuilder.getLowNode();
265 ASSERT_TRUE(fromSleOpt.has_value());
266 ASSERT_TRUE(fromBuilderOpt.has_value());
273 auto const& expected = lowQualityInValue;
276 auto const fromBuilderOpt = entryFromBuilder.getLowQualityIn();
278 ASSERT_TRUE(fromSleOpt.has_value());
279 ASSERT_TRUE(fromBuilderOpt.has_value());
286 auto const& expected = lowQualityOutValue;
289 auto const fromBuilderOpt = entryFromBuilder.getLowQualityOut();
291 ASSERT_TRUE(fromSleOpt.has_value());
292 ASSERT_TRUE(fromBuilderOpt.has_value());
299 auto const& expected = highNodeValue;
301 auto const fromSleOpt = entryFromSle.
getHighNode();
302 auto const fromBuilderOpt = entryFromBuilder.getHighNode();
304 ASSERT_TRUE(fromSleOpt.has_value());
305 ASSERT_TRUE(fromBuilderOpt.has_value());
312 auto const& expected = highQualityInValue;
315 auto const fromBuilderOpt = entryFromBuilder.getHighQualityIn();
317 ASSERT_TRUE(fromSleOpt.has_value());
318 ASSERT_TRUE(fromBuilderOpt.has_value());
325 auto const& expected = highQualityOutValue;
328 auto const fromBuilderOpt = entryFromBuilder.getHighQualityOut();
330 ASSERT_TRUE(fromSleOpt.has_value());
331 ASSERT_TRUE(fromBuilderOpt.has_value());
338 auto const& expected = highSponsorValue;
341 auto const fromBuilderOpt = entryFromBuilder.getHighSponsor();
343 ASSERT_TRUE(fromSleOpt.has_value());
344 ASSERT_TRUE(fromBuilderOpt.has_value());
351 auto const& expected = lowSponsorValue;
354 auto const fromBuilderOpt = entryFromBuilder.getLowSponsor();
356 ASSERT_TRUE(fromSleOpt.has_value());
357 ASSERT_TRUE(fromBuilderOpt.has_value());
363 EXPECT_EQ(entryFromSle.
getKey(), index);
364 EXPECT_EQ(entryFromBuilder.getKey(), index);
404TEST(RippleStateTests, OptionalFieldsReturnNullopt)
419 previousTxnLgrSeqValue
422 auto const entry = builder.
build(index);
425 EXPECT_FALSE(entry.hasLowNode());
426 EXPECT_FALSE(entry.getLowNode().has_value());
427 EXPECT_FALSE(entry.hasLowQualityIn());
428 EXPECT_FALSE(entry.getLowQualityIn().has_value());
429 EXPECT_FALSE(entry.hasLowQualityOut());
430 EXPECT_FALSE(entry.getLowQualityOut().has_value());
431 EXPECT_FALSE(entry.hasHighNode());
432 EXPECT_FALSE(entry.getHighNode().has_value());
433 EXPECT_FALSE(entry.hasHighQualityIn());
434 EXPECT_FALSE(entry.getHighQualityIn().has_value());
435 EXPECT_FALSE(entry.hasHighQualityOut());
436 EXPECT_FALSE(entry.getHighQualityOut().has_value());
437 EXPECT_FALSE(entry.hasHighSponsor());
438 EXPECT_FALSE(entry.getHighSponsor().has_value());
439 EXPECT_FALSE(entry.hasLowSponsor());
440 EXPECT_FALSE(entry.getLowSponsor().has_value());
uint256 const & getKey() const
Get the key (index) of this ledger entry.