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 
21 #include <ripple/app/misc/AmendmentTable.h>
22 #include <ripple/basics/BasicConfig.h>
23 #include <ripple/basics/chrono.h>
24 #include <ripple/basics/Log.h>
25 #include <ripple/beast/unit_test.h>
26 #include <ripple/core/ConfigSections.h>
27 #include <ripple/protocol/Feature.h>
28 #include <ripple/protocol/PublicKey.h>
29 #include <ripple/protocol/SecretKey.h>
30 #include <ripple/protocol/digest.h>
31 #include <ripple/protocol/TxFlags.h>
32 #include <test/unit_test/SuiteJournal.h>
33 
34 namespace ripple
35 {
36 
37 class AmendmentTable_test final : public beast::unit_test::suite
38 {
39 private:
40  // 204/256 about 80% (we round down because the implementation rounds up)
41  static int const majorityFraction{204};
42 
43  static
44  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
58  createSet (int group, int count)
59  {
60  std::vector<std::string> amendments;
61  for (int i = 0; i < count; i++)
62  amendments.push_back (
63  "Amendment" + std::to_string ((1000000 * group) + i));
64  return amendments;
65  }
66 
67  static
68  Section
70  {
71  Section section ("Test");
72  for (auto const& a : amendments)
73  section.append (to_string(amendmentId (a)) + " " + a);
74  return section;
75  }
76 
77  static
78  Section
79  makeSection (uint256 const& amendment)
80  {
81  Section section ("Test");
82  section.append (to_string (amendment) + " " + to_string(amendment));
83  return section;
84  }
85 
91 
93 
95 
96 public:
98  : m_set1 (createSet (1, 12))
99  , m_set2 (createSet (2, 12))
100  , m_set3 (createSet (3, 12))
101  , m_set4 (createSet (4, 12))
102  , m_set5 (createSet (5, 12))
103  , journal ("AmendmentTable_test", *this)
104  {
105  }
106 
109  int w,
110  Section const supported,
111  Section const enabled,
112  Section const vetoed)
113  {
114  return make_AmendmentTable (
115  weeks (w),
117  supported,
118  enabled,
119  vetoed,
120  journal);
121  }
122 
124  makeTable (int w)
125  {
126  return makeTable (
127  w,
130  makeSection (m_set3));
131  }
132 
134  {
135  testcase ("Construction");
136 
137  auto table = makeTable(1);
138 
139  for (auto const& a : m_set1)
140  {
141  BEAST_EXPECT(table->isSupported (amendmentId (a)));
142  BEAST_EXPECT(!table->isEnabled (amendmentId (a)));
143  }
144 
145  for (auto const& a : m_set2)
146  {
147  BEAST_EXPECT(table->isSupported (amendmentId (a)));
148  BEAST_EXPECT(table->isEnabled (amendmentId (a)));
149  }
150 
151  for (auto const& a : m_set3)
152  {
153  BEAST_EXPECT(!table->isSupported (amendmentId (a)));
154  BEAST_EXPECT(!table->isEnabled (amendmentId (a)));
155  }
156  }
157 
158  void testGet ()
159  {
160  testcase ("Name to ID mapping");
161 
162  auto table = makeTable (1);
163 
164  for (auto const& a : m_set1)
165  BEAST_EXPECT(table->find (a) == amendmentId (a));
166  for (auto const& a : m_set2)
167  BEAST_EXPECT(table->find (a) == amendmentId (a));
168 
169  for (auto const& a : m_set3)
170  BEAST_EXPECT(!table->find (a));
171  for (auto const& a : m_set4)
172  BEAST_EXPECT(!table->find (a));
173  for (auto const& a : m_set5)
174  BEAST_EXPECT(!table->find (a));
175  }
176 
178  {
179  auto const section = makeSection (m_set1);
180  auto const id = to_string (amendmentId (m_set2[0]));
181 
182  testcase ("Bad Config");
183 
184  { // Two arguments are required - we pass one
185  Section test = section;
186  test.append (id);
187 
188  try
189  {
190  if (makeTable (2, test, emptySection, emptySection))
191  fail ("Accepted only amendment ID");
192  }
193  catch (...)
194  {
195  pass();
196  }
197  }
198 
199  { // Two arguments are required - we pass three
200  Section test = section;
201  test.append (id + " Test Name");
202 
203  try
204  {
205  if (makeTable (2, test, emptySection, emptySection))
206  fail ("Accepted extra arguments");
207  }
208  catch (...)
209  {
210  pass();
211  }
212  }
213 
214  {
215  auto sid = id;
216  sid.resize (sid.length() - 1);
217 
218  Section test = section;
219  test.append (sid + " Name");
220 
221  try
222  {
223  if (makeTable (2, test, emptySection, emptySection))
224  fail ("Accepted short amendment ID");
225  }
226  catch (...)
227  {
228  pass();
229  }
230  }
231 
232  {
233  auto sid = id;
234  sid.resize (sid.length() + 1, '0');
235 
236  Section test = section;
237  test.append (sid + " Name");
238 
239  try
240  {
241  if (makeTable (2, test, emptySection, emptySection))
242  fail ("Accepted long amendment ID");
243  }
244  catch (...)
245  {
246  pass();
247  }
248  }
249 
250  {
251  auto sid = id;
252  sid.resize (sid.length() - 1);
253  sid.push_back ('Q');
254 
255  Section test = section;
256  test.append (sid + " Name");
257 
258  try
259  {
260  if (makeTable (2, test, emptySection, emptySection))
261  fail ("Accepted non-hex amendment ID");
262  }
263  catch (...)
264  {
265  pass();
266  }
267  }
268  }
269 
272  AmendmentTable *table,
273  std::set<uint256> const& exclude)
274  {
276 
277  auto track = [&state,table](std::vector<std::string> const& v)
278  {
279  for (auto const& a : v)
280  {
281  auto const id = amendmentId(a);
282  state[id] = table->isEnabled (id);
283  }
284  };
285 
286  track (m_set1);
287  track (m_set2);
288  track (m_set3);
289  track (m_set4);
290  track (m_set5);
291 
292  for (auto const& a : exclude)
293  state.erase(a);
294 
295  return state;
296  }
297 
299  {
300  testcase ("enable & disable");
301 
302  auto const testAmendment = amendmentId("TestAmendment");
303  auto table = makeTable (2);
304 
305  // Subset of amendments to enable
306  std::set<uint256> enabled;
307  enabled.insert (testAmendment);
308  enabled.insert (amendmentId(m_set1[0]));
309  enabled.insert (amendmentId(m_set2[0]));
310  enabled.insert (amendmentId(m_set3[0]));
311  enabled.insert (amendmentId(m_set4[0]));
312  enabled.insert (amendmentId(m_set5[0]));
313 
314  // Get the state before, excluding the items we'll change:
315  auto const pre_state = getState (table.get(), enabled);
316 
317  // Enable the subset and verify
318  for (auto const& a : enabled)
319  table->enable (a);
320 
321  for (auto const& a : enabled)
322  BEAST_EXPECT(table->isEnabled (a));
323 
324  // Disable the subset and verify
325  for (auto const& a : enabled)
326  table->disable (a);
327 
328  for (auto const& a : enabled)
329  BEAST_EXPECT(!table->isEnabled (a));
330 
331  // Get the state after, excluding the items we changed:
332  auto const post_state = getState (table.get(), enabled);
333 
334  // Ensure the states are identical
335  auto ret = std::mismatch(
336  pre_state.begin(), pre_state.end(),
337  post_state.begin(), post_state.end());
338 
339  BEAST_EXPECT(ret.first == pre_state.end());
340  BEAST_EXPECT(ret.second == post_state.end());
341  }
342 
344  {
346  ret.reserve (num);
347  for (int i = 0; i < num; ++i)
348  {
350  }
351  return ret;
352  }
353 
355  {
356  return NetClock::time_point{w};
357  }
358 
359  // Execute a pretend consensus round for a flag ledger
360  void doRound(
361  AmendmentTable& table,
362  weeks week,
363  std::vector <std::pair<PublicKey, SecretKey>> const& validators,
364  std::vector <std::pair <uint256, int>> const& votes,
365  std::vector <uint256>& ourVotes,
366  std::set <uint256>& enabled,
367  majorityAmendments_t& majority)
368  {
369  // Do a round at the specified time
370  // Returns the amendments we voted for
371 
372  // Parameters:
373  // table: Our table of known and vetoed amendments
374  // validators: The addreses of validators we trust
375  // votes: Amendments and the number of validators who vote for them
376  // ourVotes: The amendments we vote for in our validation
377  // enabled: In/out enabled amendments
378  // majority: In/our majority amendments (and when they got a majority)
379 
380  auto const roundTime = weekTime (week);
381 
382  // Build validations
384  validations.reserve (validators.size ());
385 
386  int i = 0;
387  for (auto const& val : validators)
388  {
389  ++i;
390  std::vector<uint256> field;
391 
392  for (auto const& amendment : votes)
393  {
394  if ((256 * i) < (validators.size() * amendment.second))
395  {
396  // We vote yes on this amendment
397  field.push_back (amendment.first);
398  }
399  }
400 
401  auto v = std::make_shared<STValidation>(
402  uint256(),
403  i,
404  uint256(),
405  roundTime,
406  val.first,
407  val.second,
408  calcNodeID(val.first),
409  true,
411  field);
412 
413  validations.emplace_back(v);
414  }
415 
416  ourVotes = table.doValidation (enabled);
417 
418  auto actions = table.doVoting (
419  roundTime, enabled, majority, validations);
420  for (auto const& action : actions)
421  {
422  // This code assumes other validators do as we do
423 
424  auto const& hash = action.first;
425  switch (action.second)
426  {
427  case 0:
428  // amendment goes from majority to enabled
429  if (enabled.find (hash) != enabled.end ())
430  Throw<std::runtime_error> ("enabling already enabled");
431  if (majority.find (hash) == majority.end ())
432  Throw<std::runtime_error> ("enabling without majority");
433  enabled.insert (hash);
434  majority.erase (hash);
435  break;
436 
437  case tfGotMajority:
438  if (majority.find (hash) != majority.end ())
439  Throw<std::runtime_error> ("got majority while having majority");
440  majority[hash] = roundTime;
441  break;
442 
443  case tfLostMajority:
444  if (majority.find (hash) == majority.end ())
445  Throw<std::runtime_error> ("lost majority without majority");
446  majority.erase (hash);
447  break;
448 
449  default:
450  Throw<std::runtime_error> ("unknown action");
451  }
452  }
453  }
454 
455  // No vote on unknown amendment
457  {
458  testcase ("Vote NO on unknown");
459 
460  auto const testAmendment = amendmentId("TestAmendment");
461  auto const validators = makeValidators (10);
462 
463  auto table = makeTable (2,
464  emptySection,
465  emptySection,
466  emptySection);
467 
469  std::vector <uint256> ourVotes;
470  std::set <uint256> enabled;
471  majorityAmendments_t majority;
472 
473  doRound (*table, weeks{1},
474  validators,
475  votes,
476  ourVotes,
477  enabled,
478  majority);
479  BEAST_EXPECT(ourVotes.empty());
480  BEAST_EXPECT(enabled.empty());
481  BEAST_EXPECT(majority.empty());
482 
483  votes.emplace_back (testAmendment, 256);
484 
485  doRound (*table, weeks{2},
486  validators,
487  votes,
488  ourVotes,
489  enabled,
490  majority);
491  BEAST_EXPECT(ourVotes.empty());
492  BEAST_EXPECT(enabled.empty());
493 
494  majority[testAmendment] = weekTime(weeks{1});
495 
496  // Note that the simulation code assumes others behave as we do,
497  // so the amendment won't get enabled
498  doRound (*table, weeks{5},
499  validators,
500  votes,
501  ourVotes,
502  enabled,
503  majority);
504  BEAST_EXPECT(ourVotes.empty());
505  BEAST_EXPECT(enabled.empty());
506  }
507 
508  // No vote on vetoed amendment
510  {
511  testcase ("Vote NO on vetoed");
512 
513  auto const testAmendment = amendmentId ("vetoedAmendment");
514 
515  auto table = makeTable (2,
516  emptySection,
517  emptySection,
518  makeSection (testAmendment));
519 
520  auto const validators = makeValidators (10);
521 
523  std::vector <uint256> ourVotes;
524  std::set <uint256> enabled;
525  majorityAmendments_t majority;
526 
527  doRound (*table, weeks{1},
528  validators,
529  votes,
530  ourVotes,
531  enabled,
532  majority);
533  BEAST_EXPECT(ourVotes.empty());
534  BEAST_EXPECT(enabled.empty());
535  BEAST_EXPECT(majority.empty());
536 
537  votes.emplace_back (testAmendment, 256);
538 
539  doRound (*table, weeks{2},
540  validators,
541  votes,
542  ourVotes,
543  enabled,
544  majority);
545  BEAST_EXPECT(ourVotes.empty());
546  BEAST_EXPECT(enabled.empty());
547 
548  majority[testAmendment] = weekTime(weeks{1});
549 
550  doRound (*table, weeks{5},
551  validators,
552  votes,
553  ourVotes,
554  enabled,
555  majority);
556  BEAST_EXPECT(ourVotes.empty());
557  BEAST_EXPECT(enabled.empty());
558  }
559 
560  // Vote on and enable known, not-enabled amendment
562  {
563  testcase ("voteEnable");
564 
565  auto table = makeTable (
566  2,
568  emptySection,
569  emptySection);
570 
571  auto const validators = makeValidators (10);
573  std::vector <uint256> ourVotes;
574  std::set <uint256> enabled;
575  majorityAmendments_t majority;
576 
577  // Week 1: We should vote for all known amendments not enabled
578  doRound (*table, weeks{1},
579  validators,
580  votes,
581  ourVotes,
582  enabled,
583  majority);
584  BEAST_EXPECT(ourVotes.size() == m_set1.size());
585  BEAST_EXPECT(enabled.empty());
586  for (auto const& i : m_set1)
587  BEAST_EXPECT(majority.find(amendmentId (i)) == majority.end());
588 
589  // Now, everyone votes for this feature
590  for (auto const& i : m_set1)
591  votes.emplace_back (amendmentId(i), 256);
592 
593  // Week 2: We should recognize a majority
594  doRound (*table, weeks{2},
595  validators,
596  votes,
597  ourVotes,
598  enabled,
599  majority);
600  BEAST_EXPECT(ourVotes.size() == m_set1.size());
601  BEAST_EXPECT(enabled.empty());
602 
603  for (auto const& i : m_set1)
604  BEAST_EXPECT(majority[amendmentId (i)] == weekTime(weeks{2}));
605 
606  // Week 5: We should enable the amendment
607  doRound (*table, weeks{5},
608  validators,
609  votes,
610  ourVotes,
611  enabled,
612  majority);
613  BEAST_EXPECT(enabled.size() == m_set1.size());
614 
615  // Week 6: We should remove it from our votes and from having a majority
616  doRound (*table, weeks{6},
617  validators,
618  votes,
619  ourVotes,
620  enabled,
621  majority);
622  BEAST_EXPECT(enabled.size() == m_set1.size());
623  BEAST_EXPECT(ourVotes.empty());
624  for (auto const& i : m_set1)
625  BEAST_EXPECT(majority.find(amendmentId (i)) == majority.end());
626  }
627 
628  // Detect majority at 80%, enable later
630  {
631  testcase ("detectMajority");
632 
633  auto const testAmendment = amendmentId ("detectMajority");
634  auto table = makeTable (
635  2,
636  makeSection (testAmendment),
637  emptySection,
638  emptySection);
639 
640  auto const validators = makeValidators (16);
641 
642  std::set <uint256> enabled;
643  majorityAmendments_t majority;
644 
645  for (int i = 0; i <= 17; ++i)
646  {
648  std::vector <uint256> ourVotes;
649 
650  if ((i > 0) && (i < 17))
651  votes.emplace_back (testAmendment, i * 16);
652 
653  doRound (*table, weeks{i},
654  validators, votes, ourVotes, enabled, majority);
655 
656  if (i < 13)
657  {
658  // We are voting yes, not enabled, no majority
659  BEAST_EXPECT(!ourVotes.empty());
660  BEAST_EXPECT(enabled.empty());
661  BEAST_EXPECT(majority.empty());
662  }
663  else if (i < 15)
664  {
665  // We have a majority, not enabled, keep voting
666  BEAST_EXPECT(!ourVotes.empty());
667  BEAST_EXPECT(!majority.empty());
668  BEAST_EXPECT(enabled.empty());
669  }
670  else if (i == 15)
671  {
672  // enable, keep voting, remove from majority
673  BEAST_EXPECT(!ourVotes.empty());
674  BEAST_EXPECT(majority.empty());
675  BEAST_EXPECT(!enabled.empty());
676  }
677  else
678  {
679  // Done, we should be enabled and not voting
680  BEAST_EXPECT(ourVotes.empty());
681  BEAST_EXPECT(majority.empty());
682  BEAST_EXPECT(!enabled.empty());
683  }
684  }
685  }
686 
687  // Detect loss of majority
689  {
690  testcase ("lostMajority");
691 
692  auto const testAmendment = amendmentId ("lostMajority");
693  auto const validators = makeValidators (16);
694 
695  auto table = makeTable (
696  8,
697  makeSection (testAmendment),
698  emptySection,
699  emptySection);
700 
701  std::set <uint256> enabled;
702  majorityAmendments_t majority;
703 
704  {
705  // establish majority
707  std::vector <uint256> ourVotes;
708 
709  votes.emplace_back (testAmendment, 250);
710 
711  doRound (*table, weeks{1},
712  validators, votes, ourVotes, enabled, majority);
713 
714  BEAST_EXPECT(enabled.empty());
715  BEAST_EXPECT(!majority.empty());
716  }
717 
718  for (int i = 1; i < 16; ++i)
719  {
721  std::vector <uint256> ourVotes;
722 
723  // Gradually reduce support
724  votes.emplace_back (testAmendment, 256 - i * 8);
725 
726  doRound (*table, weeks{i + 1},
727  validators, votes, ourVotes, enabled, majority);
728 
729  if (i < 8)
730  {
731  // We are voting yes, not enabled, majority
732  BEAST_EXPECT(!ourVotes.empty());
733  BEAST_EXPECT(enabled.empty());
734  BEAST_EXPECT(!majority.empty());
735  }
736  else
737  {
738  // No majority, not enabled, keep voting
739  BEAST_EXPECT(!ourVotes.empty());
740  BEAST_EXPECT(majority.empty());
741  BEAST_EXPECT(enabled.empty());
742  }
743  }
744  }
745 
747  {
748  testcase ("hasUnsupportedEnabled");
749 
750  using namespace std::chrono_literals;
751 
752  int constexpr w = 1;
753  auto table = makeTable(w);
754  BEAST_EXPECT(! table->hasUnsupportedEnabled());
755  BEAST_EXPECT(! table->firstUnsupportedExpected());
756 
757  std::set <uint256> enabled;
758  majorityAmendments_t majority;
760  [&enabled](auto const &s){ enabled.insert(amendmentId(s)); });
761  table->doValidatedLedger(1, enabled, majority);
762  BEAST_EXPECT(table->hasUnsupportedEnabled());
763  BEAST_EXPECT(!table->firstUnsupportedExpected());
764  NetClock::duration t{1000s};
766  m_set5.begin(), m_set5.end(), [&majority, &t](auto const& s) {
767  majority[amendmentId(s)] = NetClock::time_point{--t};
768  });
769  table->doValidatedLedger(1, enabled, majority);
770  BEAST_EXPECT(table->hasUnsupportedEnabled());
771  BEAST_EXPECT(
772  table->firstUnsupportedExpected() &&
773  *table->firstUnsupportedExpected() ==
774  NetClock::time_point{t} + weeks{w});
775  }
776 
777  void run () override
778  {
779  testConstruct();
780  testGet ();
781  testBadConfig ();
783  testNoOnUnknown ();
784  testNoOnVetoed ();
785  testVoteEnable ();
787  testLostMajority ();
789  }
790 };
791 
792 BEAST_DEFINE_TESTSUITE (AmendmentTable, app, ripple);
793 
794 } // ripple
ripple::AmendmentTable_test::getState
std::map< uint256, bool > getState(AmendmentTable *table, std::set< uint256 > const &exclude)
Definition: AmendmentTable_test.cpp:271
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:94
ripple::openssl_sha256_hasher
SHA-256 digest.
Definition: digest.h:99
ripple::AmendmentTable_test::testNoOnUnknown
void testNoOnUnknown()
Definition: AmendmentTable_test.cpp:456
std::string
STL class.
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:236
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:307
ripple::AmendmentTable_test::makeSection
static Section makeSection(uint256 const &amendment)
Definition: AmendmentTable_test.cpp:79
ripple::AmendmentTable_test::makeTable
std::unique_ptr< AmendmentTable > makeTable(int w)
Definition: AmendmentTable_test.cpp:124
std::pair
std::vector::reserve
T reserve(T... args)
ripple::AmendmentTable_test::m_set5
const std::vector< std::string > m_set5
Definition: AmendmentTable_test.cpp:90
ripple::AmendmentTable_test::testDetectMajority
void testDetectMajority()
Definition: AmendmentTable_test.cpp:629
ripple::AmendmentTable_test::testConstruct
void testConstruct()
Definition: AmendmentTable_test.cpp:133
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:646
std::vector::size
T size(T... args)
ripple::AmendmentTable_test::testNoOnVetoed
void testNoOnVetoed()
Definition: AmendmentTable_test.cpp:509
ripple::AmendmentTable_test::createSet
static std::vector< std::string > createSet(int group, int count)
Definition: AmendmentTable_test.cpp:58
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< STValidation::pointer > const &valSet)=0
std::chrono::duration
ripple::AmendmentTable_test::testLostMajority
void testLostMajority()
Definition: AmendmentTable_test.cpp:688
ripple::QualityDirection::in
@ in
ripple::AmendmentTable_test::testHasUnsupported
void testHasUnsupported()
Definition: AmendmentTable_test.cpp:746
ripple::to_string
std::string to_string(ListDisposition disposition)
Definition: ValidatorList.cpp:41
ripple::AmendmentTable_test::m_set2
const std::vector< std::string > m_set2
Definition: AmendmentTable_test.cpp:87
ripple::tfLostMajority
const std::uint32_t tfLostMajority
Definition: TxFlags.h:99
ripple::tfGotMajority
const std::uint32_t tfGotMajority
Definition: TxFlags.h:98
ripple::base_uint::data
pointer data()
Definition: base_uint.h:102
ripple::AmendmentTable_test::weekTime
static NetClock::time_point weekTime(weeks w)
Definition: AmendmentTable_test.cpp:354
ripple::Section::append
void append(std::vector< std::string > const &lines)
Append a set of lines to this section.
Definition: BasicConfig.cpp:41
ripple::uint256
base_uint< 256 > uint256
Definition: base_uint.h:436
std::vector::push_back
T push_back(T... args)
std::mismatch
T mismatch(T... args)
ripple::base_uint< 256 >
std::to_string
T to_string(T... args)
std::array
STL class.
std::chrono::time_point
std::map::erase
T erase(T... args)
std::map
STL class.
ripple::AmendmentTable_test::emptySection
const Section emptySection
Definition: AmendmentTable_test.cpp:92
ripple::AmendmentTable_test::testVoteEnable
void testVoteEnable()
Definition: AmendmentTable_test.cpp:561
ripple::test::SuiteJournal
Definition: SuiteJournal.h:81
ripple::KeyType::secp256k1
@ secp256k1
ripple::randomKeyPair
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
Definition: SecretKey.cpp:286
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:41
ripple::AmendmentTable_test::testGet
void testGet()
Definition: AmendmentTable_test.cpp:158
std::vector::begin
T begin(T... args)
std::set::insert
T insert(T... args)
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:360
ripple::AmendmentTable_test::makeSection
static Section makeSection(std::vector< std::string > const &amendments)
Definition: AmendmentTable_test.cpp:69
ripple::hash_append
void hash_append(Hasher &h, Slice const &v)
Definition: Slice.h:151
ripple::AmendmentTable_test::m_set4
const std::vector< std::string > m_set4
Definition: AmendmentTable_test.cpp:89
ripple::AmendmentTable_test::m_set1
const std::vector< std::string > m_set1
Definition: AmendmentTable_test.cpp:86
std::map::empty
T empty(T... args)
std::memcpy
T memcpy(T... args)
std::set::end
T end(T... args)
ripple::AmendmentTable_test
Definition: AmendmentTable_test.cpp:37
ripple::AmendmentTable_test::m_set3
const std::vector< std::string > m_set3
Definition: AmendmentTable_test.cpp:88
ripple::AmendmentTable
The amendment table stores the list of enabled and potential amendments.
Definition: AmendmentTable.h:34
std::unique_ptr
STL class.
ripple::STValidation::FeeSettings
Fees to set when issuing a new validation.
Definition: STValidation.h:101
ripple::AmendmentTable_test::makeValidators
std::vector< std::pair< PublicKey, SecretKey > > makeValidators(int num)
Definition: AmendmentTable_test.cpp:343
ripple::AmendmentTable_test::AmendmentTable_test
AmendmentTable_test()
Definition: AmendmentTable_test.cpp:97
ripple::AmendmentTable_test::testBadConfig
void testBadConfig()
Definition: AmendmentTable_test.cpp:177
std::set
STL class.
ripple::AmendmentTable_test::run
void run() override
Definition: AmendmentTable_test.cpp:777
ripple::AmendmentTable_test::amendmentId
static uint256 amendmentId(std::string in)
Definition: AmendmentTable_test.cpp:45
ripple::AmendmentTable::doValidation
virtual std::vector< uint256 > doValidation(std::set< uint256 > const &enabled)=0
ripple::AmendmentTable::isEnabled
virtual bool isEnabled(uint256 const &amendment)=0
ripple::AmendmentTable_test::makeTable
std::unique_ptr< AmendmentTable > makeTable(int w, Section const supported, Section const enabled, Section const vetoed)
Definition: AmendmentTable_test.cpp:108
ripple::AmendmentTable_test::testEnableDisable
void testEnableDisable()
Definition: AmendmentTable_test.cpp:298