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