rippled
AmendmentTable_test.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/app/misc/AmendmentTable.h>
21 #include <ripple/basics/BasicConfig.h>
22 #include <ripple/basics/Log.h>
23 #include <ripple/basics/chrono.h>
24 #include <ripple/beast/unit_test.h>
25 #include <ripple/core/ConfigSections.h>
26 #include <ripple/protocol/Feature.h>
27 #include <ripple/protocol/PublicKey.h>
28 #include <ripple/protocol/STValidation.h>
29 #include <ripple/protocol/SecretKey.h>
30 #include <ripple/protocol/TxFlags.h>
31 #include <ripple/protocol/digest.h>
32 #include <ripple/protocol/jss.h>
33 #include <test/jtx/Env.h>
34 #include <test/unit_test/SuiteJournal.h>
35 
36 namespace ripple {
37 
38 class AmendmentTable_test final : public beast::unit_test::suite
39 {
40 private:
41  // 204/256 about 80% (we round down because the implementation rounds up)
42  static int const majorityFraction{204};
43 
44  static uint256
46  {
47  sha256_hasher h;
48  using beast::hash_append;
49  hash_append(h, in);
50  auto const d = static_cast<sha256_hasher::result_type>(h);
51  uint256 result;
52  std::memcpy(result.data(), d.data(), d.size());
53  return result;
54  }
55 
56  static Section
58  {
59  Section section("Test");
60  for (auto const& a : amendments)
61  section.append(to_string(amendmentId(a)) + " " + a);
62  return section;
63  }
64 
65  static Section
66  makeSection(uint256 const& amendment)
67  {
68  Section section("Test");
69  section.append(to_string(amendment) + " " + to_string(amendment));
70  return section;
71  }
72 
73  // All useful amendments are supported amendments.
74  // Enabled amendments are typically a subset of supported amendments.
75  // Vetoed amendments should be supported but not enabled.
76  // Unsupported amendments may be added to the AmendmentTable.
78  "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
79  "l", "m", "n", "o", "p", "q", "r", "s", "t", "u"};
81  enabled_{"b", "d", "f", "h", "j", "l", "n", "p"};
82  std::vector<std::string> const vetoed_{"a", "c", "e"};
83  std::vector<std::string> const unsupported_{"v", "w", "x"};
85 
87 
89 
90 public:
91  AmendmentTable_test() : journal("AmendmentTable_test", *this)
92  {
93  }
94 
97  std::chrono::seconds majorityTime,
98  Section const supported,
99  Section const enabled,
100  Section const vetoed)
101  {
102  return make_AmendmentTable(
103  majorityTime,
105  supported,
106  enabled,
107  vetoed,
108  journal);
109  }
110 
113  {
114  return makeTable(
115  majorityTime,
119  }
120 
121  void
123  {
124  testcase("Construction");
125 
126  auto table = makeTable(weeks(1));
127 
128  for (auto const& a : supported_)
129  {
130  BEAST_EXPECT(table->isSupported(amendmentId(a)));
131  }
132 
133  for (auto const& a : enabled_)
134  {
135  BEAST_EXPECT(table->isSupported(amendmentId(a)));
136  BEAST_EXPECT(table->isEnabled(amendmentId(a)));
137  }
138 
139  for (auto const& a : vetoed_)
140  {
141  BEAST_EXPECT(table->isSupported(amendmentId(a)));
142  BEAST_EXPECT(!table->isEnabled(amendmentId(a)));
143  }
144  }
145 
146  void
148  {
149  testcase("Name to ID mapping");
150 
151  auto table = makeTable(weeks(1));
152 
153  for (auto const& a : supported_)
154  BEAST_EXPECT(table->find(a) == amendmentId(a));
155  for (auto const& a : enabled_)
156  BEAST_EXPECT(table->find(a) == amendmentId(a));
157 
158  for (auto const& a : vetoed_)
159  BEAST_EXPECT(table->find(a) == amendmentId(a));
160  for (auto const& a : unsupported_)
161  BEAST_EXPECT(!table->find(a));
162  for (auto const& a : unsupportedMajority_)
163  BEAST_EXPECT(!table->find(a));
164 
165  // Vetoing an unsupported amendment should add the amendment to table.
166  // Verify that unsupportedID is not in table.
167  uint256 const unsupportedID = amendmentId(unsupported_[0]);
168  {
169  Json::Value const unsupp =
170  table->getJson(unsupportedID)[to_string(unsupportedID)];
171  BEAST_EXPECT(unsupp.size() == 0);
172  }
173 
174  // After vetoing unsupportedID verify that it is in table.
175  table->veto(unsupportedID);
176  {
177  Json::Value const unsupp =
178  table->getJson(unsupportedID)[to_string(unsupportedID)];
179  BEAST_EXPECT(unsupp[jss::vetoed].asBool());
180  }
181  }
182 
183  void
185  {
186  auto const section = makeSection(supported_);
187  auto const id = to_string(amendmentId(enabled_[0]));
188 
189  testcase("Bad Config");
190 
191  { // Two arguments are required - we pass one
192  Section test = section;
193  test.append(id);
194 
195  try
196  {
197  if (makeTable(weeks(2), test, emptySection, emptySection))
198  fail("Accepted only amendment ID");
199  }
200  catch (...)
201  {
202  pass();
203  }
204  }
205 
206  { // Two arguments are required - we pass three
207  Section test = section;
208  test.append(id + " Test Name");
209 
210  try
211  {
212  if (makeTable(weeks(2), test, emptySection, emptySection))
213  fail("Accepted extra arguments");
214  }
215  catch (...)
216  {
217  pass();
218  }
219  }
220 
221  {
222  auto sid = id;
223  sid.resize(sid.length() - 1);
224 
225  Section test = section;
226  test.append(sid + " Name");
227 
228  try
229  {
230  if (makeTable(weeks(2), test, emptySection, emptySection))
231  fail("Accepted short amendment ID");
232  }
233  catch (...)
234  {
235  pass();
236  }
237  }
238 
239  {
240  auto sid = id;
241  sid.resize(sid.length() + 1, '0');
242 
243  Section test = section;
244  test.append(sid + " Name");
245 
246  try
247  {
248  if (makeTable(weeks(2), test, emptySection, emptySection))
249  fail("Accepted long amendment ID");
250  }
251  catch (...)
252  {
253  pass();
254  }
255  }
256 
257  {
258  auto sid = id;
259  sid.resize(sid.length() - 1);
260  sid.push_back('Q');
261 
262  Section test = section;
263  test.append(sid + " Name");
264 
265  try
266  {
267  if (makeTable(weeks(2), test, emptySection, emptySection))
268  fail("Accepted non-hex amendment ID");
269  }
270  catch (...)
271  {
272  pass();
273  }
274  }
275  }
276 
277  void
279  {
280  testcase("enable and veto");
281 
283 
284  // Note which entries are pre-enabled.
285  std::set<uint256> allEnabled;
286  for (std::string const& a : enabled_)
287  allEnabled.insert(amendmentId(a));
288 
289  // Subset of amendments to late-enable
290  std::set<uint256> lateEnabled;
291  lateEnabled.insert(amendmentId(supported_[0]));
292  lateEnabled.insert(amendmentId(enabled_[0]));
293  lateEnabled.insert(amendmentId(vetoed_[0]));
294 
295  // Do the late enabling.
296  for (uint256 const& a : lateEnabled)
297  table->enable(a);
298 
299  // So far all enabled amendments are supported.
300  BEAST_EXPECT(!table->hasUnsupportedEnabled());
301 
302  // Verify all pre- and late-enables are enabled and nothing else.
303  allEnabled.insert(lateEnabled.begin(), lateEnabled.end());
304  for (std::string const& a : supported_)
305  {
306  uint256 const supportedID = amendmentId(a);
307  BEAST_EXPECT(
308  table->isEnabled(supportedID) ==
309  (allEnabled.find(supportedID) != allEnabled.end()));
310  }
311 
312  // All supported and unVetoed amendments should be returned as desired.
313  {
314  std::set<uint256> vetoed;
315  for (std::string const& a : vetoed_)
316  vetoed.insert(amendmentId(a));
317 
318  std::vector<uint256> const desired = table->getDesired();
319  for (uint256 const& a : desired)
320  BEAST_EXPECT(vetoed.count(a) == 0);
321 
322  // Unveto an amendment that is already not vetoed. Shouldn't
323  // hurt anything, but the values returned by getDesired()
324  // shouldn't change.
325  table->unVeto(amendmentId(supported_[1]));
326  BEAST_EXPECT(desired == table->getDesired());
327  }
328 
329  // UnVeto one of the vetoed amendments. It should now be desired.
330  {
331  uint256 const unvetoedID = amendmentId(vetoed_[0]);
332  table->unVeto(unvetoedID);
333 
334  std::vector<uint256> const desired = table->getDesired();
335  BEAST_EXPECT(
336  std::find(desired.begin(), desired.end(), unvetoedID) !=
337  desired.end());
338  }
339 
340  // Veto all supported amendments. Now desired should be empty.
341  for (std::string const& a : supported_)
342  {
343  table->veto(amendmentId(a));
344  }
345  BEAST_EXPECT(table->getDesired().empty());
346 
347  // Enable an unsupported amendment.
348  {
349  BEAST_EXPECT(!table->hasUnsupportedEnabled());
350  table->enable(amendmentId(unsupported_[0]));
351  BEAST_EXPECT(table->hasUnsupportedEnabled());
352  }
353  }
354 
356  makeValidators(int num)
357  {
359  ret.reserve(num);
360  for (int i = 0; i < num; ++i)
361  {
363  }
364  return ret;
365  }
366 
367  static NetClock::time_point
369  {
370  return NetClock::time_point{w};
371  }
372 
373  // Execute a pretend consensus round for a flag ledger
374  void
376  AmendmentTable& table,
377  weeks week,
378  std::vector<std::pair<PublicKey, SecretKey>> const& validators,
379  std::vector<std::pair<uint256, int>> const& votes,
380  std::vector<uint256>& ourVotes,
381  std::set<uint256>& enabled,
382  majorityAmendments_t& majority)
383  {
384  // Do a round at the specified time
385  // Returns the amendments we voted for
386 
387  // Parameters:
388  // table: Our table of known and vetoed amendments
389  // validators: The addreses of validators we trust
390  // votes: Amendments and the number of validators who vote for them
391  // ourVotes: The amendments we vote for in our validation
392  // enabled: In/out enabled amendments
393  // majority: In/our majority amendments (and when they got a majority)
394 
395  auto const roundTime = weekTime(week);
396 
397  // Build validations
399  validations.reserve(validators.size());
400 
401  int i = 0;
402  for (auto const& val : validators)
403  {
404  ++i;
405  std::vector<uint256> field;
406 
407  for (auto const& amendment : votes)
408  {
409  if ((256 * i) < (validators.size() * amendment.second))
410  {
411  // We vote yes on this amendment
412  field.push_back(amendment.first);
413  }
414  }
415 
416  auto v = std::make_shared<STValidation>(
418  val.first,
419  val.second,
420  calcNodeID(val.first),
421  [&field](STValidation& v) {
422  if (!field.empty())
423  v.setFieldV256(
425  v.setFieldU32(sfLedgerSequence, 6180339);
426  });
427 
428  validations.emplace_back(v);
429  }
430 
431  ourVotes = table.doValidation(enabled);
432 
433  auto actions =
434  table.doVoting(roundTime, enabled, majority, validations);
435  for (auto const& action : actions)
436  {
437  // This code assumes other validators do as we do
438 
439  auto const& hash = action.first;
440  switch (action.second)
441  {
442  case 0:
443  // amendment goes from majority to enabled
444  if (enabled.find(hash) != enabled.end())
445  Throw<std::runtime_error>("enabling already enabled");
446  if (majority.find(hash) == majority.end())
447  Throw<std::runtime_error>("enabling without majority");
448  enabled.insert(hash);
449  majority.erase(hash);
450  break;
451 
452  case tfGotMajority:
453  if (majority.find(hash) != majority.end())
454  Throw<std::runtime_error>(
455  "got majority while having majority");
456  majority[hash] = roundTime;
457  break;
458 
459  case tfLostMajority:
460  if (majority.find(hash) == majority.end())
461  Throw<std::runtime_error>(
462  "lost majority without majority");
463  majority.erase(hash);
464  break;
465 
466  default:
467  Throw<std::runtime_error>("unknown action");
468  }
469  }
470  }
471 
472  // No vote on unknown amendment
473  void
475  {
476  testcase("Vote NO on unknown");
477 
478  auto const testAmendment = amendmentId("TestAmendment");
479  auto const validators = makeValidators(10);
480 
481  auto table =
483 
485  std::vector<uint256> ourVotes;
486  std::set<uint256> enabled;
487  majorityAmendments_t majority;
488 
489  doRound(
490  *table, weeks{1}, validators, votes, ourVotes, enabled, majority);
491  BEAST_EXPECT(ourVotes.empty());
492  BEAST_EXPECT(enabled.empty());
493  BEAST_EXPECT(majority.empty());
494 
495  votes.emplace_back(testAmendment, 256);
496 
497  doRound(
498  *table, weeks{2}, validators, votes, ourVotes, enabled, majority);
499  BEAST_EXPECT(ourVotes.empty());
500  BEAST_EXPECT(enabled.empty());
501 
502  majority[testAmendment] = weekTime(weeks{1});
503 
504  // Note that the simulation code assumes others behave as we do,
505  // so the amendment won't get enabled
506  doRound(
507  *table, weeks{5}, validators, votes, ourVotes, enabled, majority);
508  BEAST_EXPECT(ourVotes.empty());
509  BEAST_EXPECT(enabled.empty());
510  }
511 
512  // No vote on vetoed amendment
513  void
515  {
516  testcase("Vote NO on vetoed");
517 
518  auto const testAmendment = amendmentId("vetoedAmendment");
519 
520  auto table = makeTable(
521  weeks(2), emptySection, emptySection, makeSection(testAmendment));
522 
523  auto const validators = makeValidators(10);
524 
526  std::vector<uint256> ourVotes;
527  std::set<uint256> enabled;
528  majorityAmendments_t majority;
529 
530  doRound(
531  *table, weeks{1}, validators, votes, ourVotes, enabled, majority);
532  BEAST_EXPECT(ourVotes.empty());
533  BEAST_EXPECT(enabled.empty());
534  BEAST_EXPECT(majority.empty());
535 
536  votes.emplace_back(testAmendment, 256);
537 
538  doRound(
539  *table, weeks{2}, validators, votes, ourVotes, enabled, majority);
540  BEAST_EXPECT(ourVotes.empty());
541  BEAST_EXPECT(enabled.empty());
542 
543  majority[testAmendment] = weekTime(weeks{1});
544 
545  doRound(
546  *table, weeks{5}, validators, votes, ourVotes, enabled, majority);
547  BEAST_EXPECT(ourVotes.empty());
548  BEAST_EXPECT(enabled.empty());
549  }
550 
551  // Vote on and enable known, not-enabled amendment
552  void
554  {
555  testcase("voteEnable");
556 
557  auto table = makeTable(
559 
560  auto const validators = makeValidators(10);
562  std::vector<uint256> ourVotes;
563  std::set<uint256> enabled;
564  majorityAmendments_t majority;
565 
566  // Week 1: We should vote for all known amendments not enabled
567  doRound(
568  *table, weeks{1}, validators, votes, ourVotes, enabled, majority);
569  BEAST_EXPECT(ourVotes.size() == supported_.size());
570  BEAST_EXPECT(enabled.empty());
571  for (auto const& i : supported_)
572  BEAST_EXPECT(majority.find(amendmentId(i)) == majority.end());
573 
574  // Now, everyone votes for this feature
575  for (auto const& i : supported_)
576  votes.emplace_back(amendmentId(i), 256);
577 
578  // Week 2: We should recognize a majority
579  doRound(
580  *table, weeks{2}, validators, votes, ourVotes, enabled, majority);
581  BEAST_EXPECT(ourVotes.size() == supported_.size());
582  BEAST_EXPECT(enabled.empty());
583 
584  for (auto const& i : supported_)
585  BEAST_EXPECT(majority[amendmentId(i)] == weekTime(weeks{2}));
586 
587  // Week 5: We should enable the amendment
588  doRound(
589  *table, weeks{5}, validators, votes, ourVotes, enabled, majority);
590  BEAST_EXPECT(enabled.size() == supported_.size());
591 
592  // Week 6: We should remove it from our votes and from having a majority
593  doRound(
594  *table, weeks{6}, validators, votes, ourVotes, enabled, majority);
595  BEAST_EXPECT(enabled.size() == supported_.size());
596  BEAST_EXPECT(ourVotes.empty());
597  for (auto const& i : supported_)
598  BEAST_EXPECT(majority.find(amendmentId(i)) == majority.end());
599  }
600 
601  // Detect majority at 80%, enable later
602  void
604  {
605  testcase("detectMajority");
606 
607  auto const testAmendment = amendmentId("detectMajority");
608  auto table = makeTable(
609  weeks(2), makeSection(testAmendment), emptySection, emptySection);
610 
611  auto const validators = makeValidators(16);
612 
613  std::set<uint256> enabled;
614  majorityAmendments_t majority;
615 
616  for (int i = 0; i <= 17; ++i)
617  {
619  std::vector<uint256> ourVotes;
620 
621  if ((i > 0) && (i < 17))
622  votes.emplace_back(testAmendment, i * 16);
623 
624  doRound(
625  *table,
626  weeks{i},
627  validators,
628  votes,
629  ourVotes,
630  enabled,
631  majority);
632 
633  if (i < 13)
634  {
635  // We are voting yes, not enabled, no majority
636  BEAST_EXPECT(!ourVotes.empty());
637  BEAST_EXPECT(enabled.empty());
638  BEAST_EXPECT(majority.empty());
639  }
640  else if (i < 15)
641  {
642  // We have a majority, not enabled, keep voting
643  BEAST_EXPECT(!ourVotes.empty());
644  BEAST_EXPECT(!majority.empty());
645  BEAST_EXPECT(enabled.empty());
646  }
647  else if (i == 15)
648  {
649  // enable, keep voting, remove from majority
650  BEAST_EXPECT(!ourVotes.empty());
651  BEAST_EXPECT(majority.empty());
652  BEAST_EXPECT(!enabled.empty());
653  }
654  else
655  {
656  // Done, we should be enabled and not voting
657  BEAST_EXPECT(ourVotes.empty());
658  BEAST_EXPECT(majority.empty());
659  BEAST_EXPECT(!enabled.empty());
660  }
661  }
662  }
663 
664  // Detect loss of majority
665  void
667  {
668  testcase("lostMajority");
669 
670  auto const testAmendment = amendmentId("lostMajority");
671  auto const validators = makeValidators(16);
672 
673  auto table = makeTable(
674  weeks(8), makeSection(testAmendment), emptySection, emptySection);
675 
676  std::set<uint256> enabled;
677  majorityAmendments_t majority;
678 
679  {
680  // establish majority
682  std::vector<uint256> ourVotes;
683 
684  votes.emplace_back(testAmendment, 250);
685 
686  doRound(
687  *table,
688  weeks{1},
689  validators,
690  votes,
691  ourVotes,
692  enabled,
693  majority);
694 
695  BEAST_EXPECT(enabled.empty());
696  BEAST_EXPECT(!majority.empty());
697  }
698 
699  for (int i = 1; i < 16; ++i)
700  {
702  std::vector<uint256> ourVotes;
703 
704  // Gradually reduce support
705  votes.emplace_back(testAmendment, 256 - i * 8);
706 
707  doRound(
708  *table,
709  weeks{i + 1},
710  validators,
711  votes,
712  ourVotes,
713  enabled,
714  majority);
715 
716  if (i < 8)
717  {
718  // We are voting yes, not enabled, majority
719  BEAST_EXPECT(!ourVotes.empty());
720  BEAST_EXPECT(enabled.empty());
721  BEAST_EXPECT(!majority.empty());
722  }
723  else
724  {
725  // No majority, not enabled, keep voting
726  BEAST_EXPECT(!ourVotes.empty());
727  BEAST_EXPECT(majority.empty());
728  BEAST_EXPECT(enabled.empty());
729  }
730  }
731  }
732 
733  void
735  {
736  testcase("hasUnsupportedEnabled");
737 
738  test::jtx::Env env(*this); // Used only for its Rules
739  env.close();
740 
741  using namespace std::chrono_literals;
742  weeks constexpr w(1);
743  auto table = makeTable(w);
744  BEAST_EXPECT(!table->hasUnsupportedEnabled());
745  BEAST_EXPECT(!table->firstUnsupportedExpected());
746  BEAST_EXPECT(table->needValidatedLedger(1));
747 
748  std::set<uint256> enabled;
751  unsupported_.end(),
752  [&enabled](auto const& s) { enabled.insert(amendmentId(s)); });
753 
754  majorityAmendments_t majority;
755  table->doValidatedLedger(1, enabled, majority);
756  BEAST_EXPECT(table->hasUnsupportedEnabled());
757  BEAST_EXPECT(!table->firstUnsupportedExpected());
758 
759  NetClock::duration t{1000s};
763  [&majority, &t](auto const& s) {
764  majority[amendmentId(s)] = NetClock::time_point{--t};
765  });
766 
767  table->doValidatedLedger(1, enabled, majority);
768  BEAST_EXPECT(table->hasUnsupportedEnabled());
769  BEAST_EXPECT(
770  table->firstUnsupportedExpected() &&
771  *table->firstUnsupportedExpected() == NetClock::time_point{t} + w);
772 
773  // Make sure the table knows when it needs an update.
774  BEAST_EXPECT(!table->needValidatedLedger(256));
775  BEAST_EXPECT(table->needValidatedLedger(257));
776  }
777 
778  void
779  run() override
780  {
781  testConstruct();
782  testGet();
783  testBadConfig();
784  testEnableVeto();
785  testNoOnUnknown();
786  testNoOnVetoed();
787  testVoteEnable();
791  }
792 };
793 
794 BEAST_DEFINE_TESTSUITE(AmendmentTable, app, ripple);
795 
796 } // namespace ripple
ripple::Section
Holds a collection of configuration values.
Definition: BasicConfig.h:43
std::for_each
T for_each(T... args)
ripple::AmendmentTable_test::journal
test::SuiteJournal journal
Definition: AmendmentTable_test.cpp:88
ripple::AmendmentTable_test::unsupported_
const std::vector< std::string > unsupported_
Definition: AmendmentTable_test.cpp:83
ripple::openssl_sha256_hasher
SHA-256 digest.
Definition: digest.h:91
ripple::AmendmentTable_test::testNoOnUnknown
void testNoOnUnknown()
Definition: AmendmentTable_test.cpp:474
std::string
STL class.
ripple::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AccountTxPaging, app, ripple)
ripple::calcNodeID
NodeID calcNodeID(PublicKey const &pk)
Calculate the 160-bit node ID from a node public key.
Definition: PublicKey.cpp:299
ripple::AmendmentTable_test::makeValidators
std::vector< std::pair< PublicKey, SecretKey > > makeValidators(int num)
Definition: AmendmentTable_test.cpp:356
ripple::AmendmentTable_test::makeSection
static Section makeSection(uint256 const &amendment)
Definition: AmendmentTable_test.cpp:66
std::pair
std::vector::reserve
T reserve(T... args)
ripple::AmendmentTable_test::testDetectMajority
void testDetectMajority()
Definition: AmendmentTable_test.cpp:603
ripple::AmendmentTable_test::testConstruct
void testConstruct()
Definition: AmendmentTable_test.cpp:122
std::vector< std::string >
std::set::find
T find(T... args)
ripple::make_AmendmentTable
std::unique_ptr< AmendmentTable > make_AmendmentTable(std::chrono::seconds majorityTime, int majorityFraction, Section const &supported, Section const &enabled, Section const &vetoed, beast::Journal journal)
Definition: AmendmentTable.cpp:667
std::vector::size
T size(T... args)
ripple::AmendmentTable_test::testNoOnVetoed
void testNoOnVetoed()
Definition: AmendmentTable_test.cpp:514
std::chrono::seconds
ripple::AmendmentTable_test::makeTable
std::unique_ptr< AmendmentTable > makeTable(std::chrono::seconds majorityTime, Section const supported, Section const enabled, Section const vetoed)
Definition: AmendmentTable_test.cpp:96
ripple::AmendmentTable_test::testLostMajority
void testLostMajority()
Definition: AmendmentTable_test.cpp:666
ripple::QualityDirection::in
@ in
ripple::AmendmentTable_test::testHasUnsupported
void testHasUnsupported()
Definition: AmendmentTable_test.cpp:734
ripple::to_string
std::string to_string(ListDisposition disposition)
Definition: ValidatorList.cpp:41
ripple::tfLostMajority
const std::uint32_t tfLostMajority
Definition: TxFlags.h:102
ripple::tfGotMajority
const std::uint32_t tfGotMajority
Definition: TxFlags.h:101
ripple::base_uint::data
pointer data()
Definition: base_uint.h:103
ripple::AmendmentTable_test::weekTime
static NetClock::time_point weekTime(weeks w)
Definition: AmendmentTable_test.cpp:368
ripple::STValidation
Definition: STValidation.h:43
ripple::Section::append
void append(std::vector< std::string > const &lines)
Append a set of lines to this section.
Definition: BasicConfig.cpp:40
ripple::AmendmentTable_test::unsupportedMajority_
const std::vector< std::string > unsupportedMajority_
Definition: AmendmentTable_test.cpp:84
ripple::base_uint< 256 >
ripple::AmendmentTable::doValidation
virtual std::vector< uint256 > doValidation(std::set< uint256 > const &enabled) const =0
ripple::AmendmentTable_test::testEnableVeto
void testEnableVeto()
Definition: AmendmentTable_test.cpp:278
ripple::weeks
std::chrono::duration< int, std::ratio_multiply< days::period, std::ratio< 7 > >> weeks
Definition: chrono.h:39
std::array
STL class.
ripple::AmendmentTable_test::supported_
const std::vector< std::string > supported_
Definition: AmendmentTable_test.cpp:77
ripple::sfLedgerSequence
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
Definition: SField.h:357
std::chrono::time_point
Json::Value::size
UInt size() const
Number of values in array or object.
Definition: json_value.cpp:706
std::map::erase
T erase(T... args)
std::map
STL class.
ripple::AmendmentTable_test::vetoed_
const std::vector< std::string > vetoed_
Definition: AmendmentTable_test.cpp:82
ripple::AmendmentTable::doVoting
virtual std::map< uint256, std::uint32_t > doVoting(NetClock::time_point closeTime, std::set< uint256 > const &enabledAmendments, majorityAmendments_t const &majorityAmendments, std::vector< std::shared_ptr< STValidation >> const &valSet)=0
ripple::AmendmentTable_test::emptySection
const Section emptySection
Definition: AmendmentTable_test.cpp:86
ripple::AmendmentTable_test::testVoteEnable
void testVoteEnable()
Definition: AmendmentTable_test.cpp:553
ripple::test::SuiteJournal
Definition: SuiteJournal.h:88
ripple::KeyType::secp256k1
@ secp256k1
ripple::randomKeyPair
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
Definition: SecretKey.cpp:260
ripple::AmendmentTable_test::makeTable
std::unique_ptr< AmendmentTable > makeTable(std::chrono::seconds majorityTime)
Definition: AmendmentTable_test.cpp:112
std::vector::emplace_back
T emplace_back(T... args)
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::AmendmentTable_test::majorityFraction
static const int majorityFraction
Definition: AmendmentTable_test.cpp:42
ripple::AmendmentTable_test::testGet
void testGet()
Definition: AmendmentTable_test.cpp:147
ripple::test::jtx::Env::close
bool close(NetClock::time_point closeTime, boost::optional< std::chrono::milliseconds > consensusDelay=boost::none)
Close and advance the ledger.
Definition: Env.cpp:111
std::vector::begin
T begin(T... args)
std::set::insert
T insert(T... args)
beast::hash_append
std::enable_if_t< is_contiguously_hashable< T, Hasher >::value > hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
Definition: hash_append.h:232
ripple::AmendmentTable_test::doRound
void doRound(AmendmentTable &table, weeks week, std::vector< std::pair< PublicKey, SecretKey >> const &validators, std::vector< std::pair< uint256, int >> const &votes, std::vector< uint256 > &ourVotes, std::set< uint256 > &enabled, majorityAmendments_t &majority)
Definition: AmendmentTable_test.cpp:375
ripple::AmendmentTable_test::makeSection
static Section makeSection(std::vector< std::string > const &amendments)
Definition: AmendmentTable_test.cpp:57
ripple::hash_append
void hash_append(Hasher &h, Slice const &v)
Definition: Slice.h:149
std::set::count
T count(T... args)
ripple::STVector256
Definition: STVector256.h:29
std::map::empty
T empty(T... args)
std::memcpy
T memcpy(T... args)
std::set::end
T end(T... args)
ripple::sfAmendments
const SF_Vec256 sfAmendments(access, STI_VECTOR256, 3, "Amendments")
Definition: SField.h:491
ripple::AmendmentTable_test
Definition: AmendmentTable_test.cpp:38
ripple::AmendmentTable
The amendment table stores the list of enabled and potential amendments.
Definition: AmendmentTable.h:34
std::unique_ptr
STL class.
ripple::AmendmentTable_test::AmendmentTable_test
AmendmentTable_test()
Definition: AmendmentTable_test.cpp:91
ripple::AmendmentTable_test::testBadConfig
void testBadConfig()
Definition: AmendmentTable_test.cpp:184
std::set
STL class.
ripple::AmendmentTable_test::run
void run() override
Definition: AmendmentTable_test.cpp:779
ripple::AmendmentTable_test::amendmentId
static uint256 amendmentId(std::string in)
Definition: AmendmentTable_test.cpp:45
ripple::AmendmentTable_test::enabled_
const std::vector< std::string > enabled_
Definition: AmendmentTable_test.cpp:81
ripple::test::jtx::Env
A transaction testing environment.
Definition: Env.h:114
Json::Value
Represents a JSON value.
Definition: json_value.h:145