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  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 
53  static Section
55  {
56  Section section("Test");
57  for (auto const& a : amendments)
58  section.append(to_string(amendmentId(a)) + " " + a);
59  return section;
60  }
61 
62  static Section
63  makeSection(uint256 const& amendment)
64  {
65  Section section("Test");
66  section.append(to_string(amendment) + " " + to_string(amendment));
67  return section;
68  }
69 
70  // All useful amendments are supported amendments.
71  // Enabled amendments are typically a subset of supported amendments.
72  // Vetoed amendments should be supported but not enabled.
73  // Unsupported amendments may be added to the AmendmentTable.
75  "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
76  "l", "m", "n", "o", "p", "q", "r", "s", "t", "u"};
78  enabled_{"b", "d", "f", "h", "j", "l", "n", "p"};
79  std::vector<std::string> const vetoed_{"a", "c", "e"};
80  std::vector<std::string> const unsupported_{"v", "w", "x"};
82 
84 
86 
87 public:
88  AmendmentTable_test() : journal("AmendmentTable_test", *this)
89  {
90  }
91 
94  std::chrono::seconds majorityTime,
95  Section const supported,
96  Section const enabled,
97  Section const vetoed)
98  {
99  return make_AmendmentTable(
100  majorityTime, supported, enabled, vetoed, journal);
101  }
102 
105  {
106  return makeTable(
107  majorityTime,
111  }
112 
113  void
115  {
116  testcase("Construction");
117 
118  auto table = makeTable(weeks(1));
119 
120  for (auto const& a : supported_)
121  {
122  BEAST_EXPECT(table->isSupported(amendmentId(a)));
123  }
124 
125  for (auto const& a : enabled_)
126  {
127  BEAST_EXPECT(table->isSupported(amendmentId(a)));
128  BEAST_EXPECT(table->isEnabled(amendmentId(a)));
129  }
130 
131  for (auto const& a : vetoed_)
132  {
133  BEAST_EXPECT(table->isSupported(amendmentId(a)));
134  BEAST_EXPECT(!table->isEnabled(amendmentId(a)));
135  }
136  }
137 
138  void
140  {
141  testcase("Name to ID mapping");
142 
143  auto table = makeTable(weeks(1));
144 
145  for (auto const& a : supported_)
146  BEAST_EXPECT(table->find(a) == amendmentId(a));
147  for (auto const& a : enabled_)
148  BEAST_EXPECT(table->find(a) == amendmentId(a));
149 
150  for (auto const& a : vetoed_)
151  BEAST_EXPECT(table->find(a) == amendmentId(a));
152  for (auto const& a : unsupported_)
153  BEAST_EXPECT(!table->find(a));
154  for (auto const& a : unsupportedMajority_)
155  BEAST_EXPECT(!table->find(a));
156 
157  // Vetoing an unsupported amendment should add the amendment to table.
158  // Verify that unsupportedID is not in table.
159  uint256 const unsupportedID = amendmentId(unsupported_[0]);
160  {
161  Json::Value const unsupp =
162  table->getJson(unsupportedID)[to_string(unsupportedID)];
163  BEAST_EXPECT(unsupp.size() == 0);
164  }
165 
166  // After vetoing unsupportedID verify that it is in table.
167  table->veto(unsupportedID);
168  {
169  Json::Value const unsupp =
170  table->getJson(unsupportedID)[to_string(unsupportedID)];
171  BEAST_EXPECT(unsupp[jss::vetoed].asBool());
172  }
173  }
174 
175  void
177  {
178  auto const section = makeSection(supported_);
179  auto const id = to_string(amendmentId(enabled_[0]));
180 
181  testcase("Bad Config");
182 
183  { // Two arguments are required - we pass one
184  Section test = section;
185  test.append(id);
186 
187  try
188  {
189  if (makeTable(weeks(2), test, emptySection, emptySection))
190  fail("Accepted only amendment ID");
191  }
192  catch (...)
193  {
194  pass();
195  }
196  }
197 
198  { // Two arguments are required - we pass three
199  Section test = section;
200  test.append(id + " Test Name");
201 
202  try
203  {
204  if (makeTable(weeks(2), test, emptySection, emptySection))
205  fail("Accepted extra arguments");
206  }
207  catch (...)
208  {
209  pass();
210  }
211  }
212 
213  {
214  auto sid = id;
215  sid.resize(sid.length() - 1);
216 
217  Section test = section;
218  test.append(sid + " Name");
219 
220  try
221  {
222  if (makeTable(weeks(2), test, emptySection, emptySection))
223  fail("Accepted short amendment ID");
224  }
225  catch (...)
226  {
227  pass();
228  }
229  }
230 
231  {
232  auto sid = id;
233  sid.resize(sid.length() + 1, '0');
234 
235  Section test = section;
236  test.append(sid + " Name");
237 
238  try
239  {
240  if (makeTable(weeks(2), test, emptySection, emptySection))
241  fail("Accepted long amendment ID");
242  }
243  catch (...)
244  {
245  pass();
246  }
247  }
248 
249  {
250  auto sid = id;
251  sid.resize(sid.length() - 1);
252  sid.push_back('Q');
253 
254  Section test = section;
255  test.append(sid + " Name");
256 
257  try
258  {
259  if (makeTable(weeks(2), test, emptySection, emptySection))
260  fail("Accepted non-hex amendment ID");
261  }
262  catch (...)
263  {
264  pass();
265  }
266  }
267  }
268 
269  void
271  {
272  testcase("enable and veto");
273 
275 
276  // Note which entries are pre-enabled.
277  std::set<uint256> allEnabled;
278  for (std::string const& a : enabled_)
279  allEnabled.insert(amendmentId(a));
280 
281  // Subset of amendments to late-enable
282  std::set<uint256> lateEnabled;
283  lateEnabled.insert(amendmentId(supported_[0]));
284  lateEnabled.insert(amendmentId(enabled_[0]));
285  lateEnabled.insert(amendmentId(vetoed_[0]));
286 
287  // Do the late enabling.
288  for (uint256 const& a : lateEnabled)
289  table->enable(a);
290 
291  // So far all enabled amendments are supported.
292  BEAST_EXPECT(!table->hasUnsupportedEnabled());
293 
294  // Verify all pre- and late-enables are enabled and nothing else.
295  allEnabled.insert(lateEnabled.begin(), lateEnabled.end());
296  for (std::string const& a : supported_)
297  {
298  uint256 const supportedID = amendmentId(a);
299  BEAST_EXPECT(
300  table->isEnabled(supportedID) ==
301  (allEnabled.find(supportedID) != allEnabled.end()));
302  }
303 
304  // All supported and unVetoed amendments should be returned as desired.
305  {
306  std::set<uint256> vetoed;
307  for (std::string const& a : vetoed_)
308  vetoed.insert(amendmentId(a));
309 
310  std::vector<uint256> const desired = table->getDesired();
311  for (uint256 const& a : desired)
312  BEAST_EXPECT(vetoed.count(a) == 0);
313 
314  // Unveto an amendment that is already not vetoed. Shouldn't
315  // hurt anything, but the values returned by getDesired()
316  // shouldn't change.
317  table->unVeto(amendmentId(supported_[1]));
318  BEAST_EXPECT(desired == table->getDesired());
319  }
320 
321  // UnVeto one of the vetoed amendments. It should now be desired.
322  {
323  uint256 const unvetoedID = amendmentId(vetoed_[0]);
324  table->unVeto(unvetoedID);
325 
326  std::vector<uint256> const desired = table->getDesired();
327  BEAST_EXPECT(
328  std::find(desired.begin(), desired.end(), unvetoedID) !=
329  desired.end());
330  }
331 
332  // Veto all supported amendments. Now desired should be empty.
333  for (std::string const& a : supported_)
334  {
335  table->veto(amendmentId(a));
336  }
337  BEAST_EXPECT(table->getDesired().empty());
338 
339  // Enable an unsupported amendment.
340  {
341  BEAST_EXPECT(!table->hasUnsupportedEnabled());
342  table->enable(amendmentId(unsupported_[0]));
343  BEAST_EXPECT(table->hasUnsupportedEnabled());
344  }
345  }
346 
348  makeValidators(int num)
349  {
351  ret.reserve(num);
352  for (int i = 0; i < num; ++i)
353  {
355  }
356  return ret;
357  }
358 
359  static NetClock::time_point
361  {
362  return NetClock::time_point{w};
363  }
364 
365  // Execute a pretend consensus round for a flag ledger
366  void
368  uint256 const& feat,
369  AmendmentTable& table,
370  weeks week,
371  std::vector<std::pair<PublicKey, SecretKey>> const& validators,
372  std::vector<std::pair<uint256, int>> const& votes,
373  std::vector<uint256>& ourVotes,
374  std::set<uint256>& enabled,
375  majorityAmendments_t& majority)
376  {
377  // Do a round at the specified time
378  // Returns the amendments we voted for
379 
380  // Parameters:
381  // table: Our table of known and vetoed amendments
382  // validators: The addreses of validators we trust
383  // votes: Amendments and the number of validators who vote for them
384  // ourVotes: The amendments we vote for in our validation
385  // enabled: In/out enabled amendments
386  // majority: In/our majority amendments (and when they got a majority)
387 
388  auto const roundTime = weekTime(week);
389 
390  // Build validations
392  validations.reserve(validators.size());
393 
394  int i = 0;
395  for (auto const& [pub, sec] : validators)
396  {
397  ++i;
398  std::vector<uint256> field;
399 
400  for (auto const& [hash, nVotes] : votes)
401  {
402  if (feat == fixAmendmentMajorityCalc ? nVotes >= i : nVotes > i)
403  {
404  // We vote yes on this amendment
405  field.push_back(hash);
406  }
407  }
408 
409  auto v = std::make_shared<STValidation>(
411  pub,
412  sec,
413  calcNodeID(pub),
414  [&field](STValidation& v) {
415  if (!field.empty())
416  v.setFieldV256(
418  v.setFieldU32(sfLedgerSequence, 6180339);
419  });
420 
421  validations.emplace_back(v);
422  }
423 
424  ourVotes = table.doValidation(enabled);
425 
426  auto actions = table.doVoting(
427  Rules({feat}), roundTime, enabled, majority, validations);
428  for (auto const& [hash, action] : actions)
429  {
430  // This code assumes other validators do as we do
431 
432  switch (action)
433  {
434  case 0:
435  // amendment goes from majority to enabled
436  if (enabled.find(hash) != enabled.end())
437  Throw<std::runtime_error>("enabling already enabled");
438  if (majority.find(hash) == majority.end())
439  Throw<std::runtime_error>("enabling without majority");
440  enabled.insert(hash);
441  majority.erase(hash);
442  break;
443 
444  case tfGotMajority:
445  if (majority.find(hash) != majority.end())
446  Throw<std::runtime_error>(
447  "got majority while having majority");
448  majority[hash] = roundTime;
449  break;
450 
451  case tfLostMajority:
452  if (majority.find(hash) == majority.end())
453  Throw<std::runtime_error>(
454  "lost majority without majority");
455  majority.erase(hash);
456  break;
457 
458  default:
459  Throw<std::runtime_error>("unknown action");
460  }
461  }
462  }
463 
464  // No vote on unknown amendment
465  void
467  {
468  testcase("Vote NO on unknown");
469 
470  auto const testAmendment = amendmentId("TestAmendment");
471  auto const validators = makeValidators(10);
472 
473  auto table =
475 
477  std::vector<uint256> ourVotes;
478  std::set<uint256> enabled;
479  majorityAmendments_t majority;
480 
481  doRound(
482  feat,
483  *table,
484  weeks{1},
485  validators,
486  votes,
487  ourVotes,
488  enabled,
489  majority);
490  BEAST_EXPECT(ourVotes.empty());
491  BEAST_EXPECT(enabled.empty());
492  BEAST_EXPECT(majority.empty());
493 
494  votes.emplace_back(testAmendment, validators.size());
495 
496  doRound(
497  feat,
498  *table,
499  weeks{2},
500  validators,
501  votes,
502  ourVotes,
503  enabled,
504  majority);
505  BEAST_EXPECT(ourVotes.empty());
506  BEAST_EXPECT(enabled.empty());
507 
508  majority[testAmendment] = weekTime(weeks{1});
509 
510  // Note that the simulation code assumes others behave as we do,
511  // so the amendment won't get enabled
512  doRound(
513  feat,
514  *table,
515  weeks{5},
516  validators,
517  votes,
518  ourVotes,
519  enabled,
520  majority);
521  BEAST_EXPECT(ourVotes.empty());
522  BEAST_EXPECT(enabled.empty());
523  }
524 
525  // No vote on vetoed amendment
526  void
527  testNoOnVetoed(uint256 const& feat)
528  {
529  testcase("Vote NO on vetoed");
530 
531  auto const testAmendment = amendmentId("vetoedAmendment");
532 
533  auto table = makeTable(
534  weeks(2), emptySection, emptySection, makeSection(testAmendment));
535 
536  auto const validators = makeValidators(10);
537 
539  std::vector<uint256> ourVotes;
540  std::set<uint256> enabled;
541  majorityAmendments_t majority;
542 
543  doRound(
544  feat,
545  *table,
546  weeks{1},
547  validators,
548  votes,
549  ourVotes,
550  enabled,
551  majority);
552  BEAST_EXPECT(ourVotes.empty());
553  BEAST_EXPECT(enabled.empty());
554  BEAST_EXPECT(majority.empty());
555 
556  votes.emplace_back(testAmendment, validators.size());
557 
558  doRound(
559  feat,
560  *table,
561  weeks{2},
562  validators,
563  votes,
564  ourVotes,
565  enabled,
566  majority);
567  BEAST_EXPECT(ourVotes.empty());
568  BEAST_EXPECT(enabled.empty());
569 
570  majority[testAmendment] = weekTime(weeks{1});
571 
572  doRound(
573  feat,
574  *table,
575  weeks{5},
576  validators,
577  votes,
578  ourVotes,
579  enabled,
580  majority);
581  BEAST_EXPECT(ourVotes.empty());
582  BEAST_EXPECT(enabled.empty());
583  }
584 
585  // Vote on and enable known, not-enabled amendment
586  void
587  testVoteEnable(uint256 const& feat)
588  {
589  testcase("voteEnable");
590 
591  auto table = makeTable(
593 
594  auto const validators = makeValidators(10);
596  std::vector<uint256> ourVotes;
597  std::set<uint256> enabled;
598  majorityAmendments_t majority;
599 
600  // Week 1: We should vote for all known amendments not enabled
601  doRound(
602  feat,
603  *table,
604  weeks{1},
605  validators,
606  votes,
607  ourVotes,
608  enabled,
609  majority);
610  BEAST_EXPECT(ourVotes.size() == supported_.size());
611  BEAST_EXPECT(enabled.empty());
612  for (auto const& i : supported_)
613  BEAST_EXPECT(majority.find(amendmentId(i)) == majority.end());
614 
615  // Now, everyone votes for this feature
616  for (auto const& i : supported_)
617  votes.emplace_back(amendmentId(i), validators.size());
618 
619  // Week 2: We should recognize a majority
620  doRound(
621  feat,
622  *table,
623  weeks{2},
624  validators,
625  votes,
626  ourVotes,
627  enabled,
628  majority);
629  BEAST_EXPECT(ourVotes.size() == supported_.size());
630  BEAST_EXPECT(enabled.empty());
631 
632  for (auto const& i : supported_)
633  BEAST_EXPECT(majority[amendmentId(i)] == weekTime(weeks{2}));
634 
635  // Week 5: We should enable the amendment
636  doRound(
637  feat,
638  *table,
639  weeks{5},
640  validators,
641  votes,
642  ourVotes,
643  enabled,
644  majority);
645  BEAST_EXPECT(enabled.size() == supported_.size());
646 
647  // Week 6: We should remove it from our votes and from having a majority
648  doRound(
649  feat,
650  *table,
651  weeks{6},
652  validators,
653  votes,
654  ourVotes,
655  enabled,
656  majority);
657  BEAST_EXPECT(enabled.size() == supported_.size());
658  BEAST_EXPECT(ourVotes.empty());
659  for (auto const& i : supported_)
660  BEAST_EXPECT(majority.find(amendmentId(i)) == majority.end());
661  }
662 
663  // Detect majority at 80%, enable later
664  void
666  {
667  testcase("detectMajority");
668 
669  auto const testAmendment = amendmentId("detectMajority");
670  auto table = makeTable(
671  weeks(2), makeSection(testAmendment), emptySection, emptySection);
672 
673  auto const validators = makeValidators(16);
674 
675  std::set<uint256> enabled;
676  majorityAmendments_t majority;
677 
678  for (int i = 0; i <= 17; ++i)
679  {
681  std::vector<uint256> ourVotes;
682 
683  if ((i > 0) && (i < 17))
684  votes.emplace_back(testAmendment, i);
685 
686  doRound(
687  feat,
688  *table,
689  weeks{i},
690  validators,
691  votes,
692  ourVotes,
693  enabled,
694  majority);
695 
696  if (i < 13) // 13 => 13/16 = 0.8125 => > 80%
697  {
698  // We are voting yes, not enabled, no majority
699  BEAST_EXPECT(!ourVotes.empty());
700  BEAST_EXPECT(enabled.empty());
701  BEAST_EXPECT(majority.empty());
702  }
703  else if (i < 15)
704  {
705  // We have a majority, not enabled, keep voting
706  BEAST_EXPECT(!ourVotes.empty());
707  BEAST_EXPECT(!majority.empty());
708  BEAST_EXPECT(enabled.empty());
709  }
710  else if (i == 15)
711  {
712  // enable, keep voting, remove from majority
713  BEAST_EXPECT(!ourVotes.empty());
714  BEAST_EXPECT(majority.empty());
715  BEAST_EXPECT(!enabled.empty());
716  }
717  else
718  {
719  // Done, we should be enabled and not voting
720  BEAST_EXPECT(ourVotes.empty());
721  BEAST_EXPECT(majority.empty());
722  BEAST_EXPECT(!enabled.empty());
723  }
724  }
725  }
726 
727  // Detect loss of majority
728  void
730  {
731  testcase("lostMajority");
732 
733  auto const testAmendment = amendmentId("lostMajority");
734  auto const validators = makeValidators(16);
735 
736  auto table = makeTable(
737  weeks(8), makeSection(testAmendment), emptySection, emptySection);
738 
739  std::set<uint256> enabled;
740  majorityAmendments_t majority;
741 
742  {
743  // establish majority
745  std::vector<uint256> ourVotes;
746 
747  votes.emplace_back(testAmendment, validators.size());
748 
749  doRound(
750  feat,
751  *table,
752  weeks{1},
753  validators,
754  votes,
755  ourVotes,
756  enabled,
757  majority);
758 
759  BEAST_EXPECT(enabled.empty());
760  BEAST_EXPECT(!majority.empty());
761  }
762 
763  for (int i = 1; i < 8; ++i)
764  {
766  std::vector<uint256> ourVotes;
767 
768  // Gradually reduce support
769  votes.emplace_back(testAmendment, validators.size() - i);
770 
771  doRound(
772  feat,
773  *table,
774  weeks{i + 1},
775  validators,
776  votes,
777  ourVotes,
778  enabled,
779  majority);
780 
781  if (i < 4) // 16 - 3 = 13 => 13/16 = 0.8125 => > 80%
782  { // 16 - 4 = 12 => 12/16 = 0.75 => < 80%
783  // We are voting yes, not enabled, majority
784  BEAST_EXPECT(!ourVotes.empty());
785  BEAST_EXPECT(enabled.empty());
786  BEAST_EXPECT(!majority.empty());
787  }
788  else
789  {
790  // No majority, not enabled, keep voting
791  BEAST_EXPECT(!ourVotes.empty());
792  BEAST_EXPECT(majority.empty());
793  BEAST_EXPECT(enabled.empty());
794  }
795  }
796  }
797 
798  void
800  {
801  testcase("hasUnsupportedEnabled");
802 
803  test::jtx::Env env(*this); // Used only for its Rules
804  env.close();
805 
806  using namespace std::chrono_literals;
807  weeks constexpr w(1);
808  auto table = makeTable(w);
809  BEAST_EXPECT(!table->hasUnsupportedEnabled());
810  BEAST_EXPECT(!table->firstUnsupportedExpected());
811  BEAST_EXPECT(table->needValidatedLedger(1));
812 
813  std::set<uint256> enabled;
816  unsupported_.end(),
817  [&enabled](auto const& s) { enabled.insert(amendmentId(s)); });
818 
819  majorityAmendments_t majority;
820  table->doValidatedLedger(1, enabled, majority);
821  BEAST_EXPECT(table->hasUnsupportedEnabled());
822  BEAST_EXPECT(!table->firstUnsupportedExpected());
823 
824  NetClock::duration t{1000s};
828  [&majority, &t](auto const& s) {
829  majority[amendmentId(s)] = NetClock::time_point{--t};
830  });
831 
832  table->doValidatedLedger(1, enabled, majority);
833  BEAST_EXPECT(table->hasUnsupportedEnabled());
834  BEAST_EXPECT(
835  table->firstUnsupportedExpected() &&
836  *table->firstUnsupportedExpected() == NetClock::time_point{t} + w);
837 
838  // Make sure the table knows when it needs an update.
839  BEAST_EXPECT(!table->needValidatedLedger(256));
840  BEAST_EXPECT(table->needValidatedLedger(257));
841  }
842 
843  void
844  testFeature(uint256 const& feat)
845  {
846  testNoOnUnknown(feat);
847  testNoOnVetoed(feat);
848  testVoteEnable(feat);
849  testDetectMajority(feat);
850  testLostMajority(feat);
851  }
852 
853  void
854  run() override
855  {
856  testConstruct();
857  testGet();
858  testBadConfig();
859  testEnableVeto();
861  testFeature({});
863  }
864 };
865 
866 BEAST_DEFINE_TESTSUITE(AmendmentTable, app, ripple);
867 
868 } // 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:85
ripple::AmendmentTable_test::testVoteEnable
void testVoteEnable(uint256 const &feat)
Definition: AmendmentTable_test.cpp:587
ripple::AmendmentTable_test::unsupported_
const std::vector< std::string > unsupported_
Definition: AmendmentTable_test.cpp:80
ripple::openssl_sha256_hasher
SHA-256 digest.
Definition: digest.h:91
ripple::AmendmentTable::doVoting
virtual std::map< uint256, std::uint32_t > doVoting(Rules const &rules, NetClock::time_point closeTime, std::set< uint256 > const &enabledAmendments, majorityAmendments_t const &majorityAmendments, std::vector< std::shared_ptr< STValidation >> const &valSet)=0
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:348
ripple::AmendmentTable_test::makeSection
static Section makeSection(uint256 const &amendment)
Definition: AmendmentTable_test.cpp:63
std::pair
std::vector::reserve
T reserve(T... args)
ripple::AmendmentTable_test::testConstruct
void testConstruct()
Definition: AmendmentTable_test.cpp:114
std::vector< std::string >
std::set::find
T find(T... args)
std::vector::size
T size(T... args)
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:93
ripple::QualityDirection::in
@ in
ripple::AmendmentTable_test::testNoOnUnknown
void testNoOnUnknown(uint256 const &feat)
Definition: AmendmentTable_test.cpp:466
ripple::AmendmentTable_test::testHasUnsupported
void testHasUnsupported()
Definition: AmendmentTable_test.cpp:799
ripple::to_string
std::string to_string(ListDisposition disposition)
Definition: ValidatorList.cpp:42
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:360
ripple::STValidation
Definition: STValidation.h:43
ripple::base_uint::size
constexpr static std::size_t size()
Definition: base_uint.h:462
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:81
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:270
ripple::weeks
std::chrono::duration< int, std::ratio_multiply< days::period, std::ratio< 7 > >> weeks
Definition: chrono.h:39
ripple::fixAmendmentMajorityCalc
const uint256 fixAmendmentMajorityCalc
Definition: Feature.cpp:188
std::array
STL class.
ripple::AmendmentTable_test::supported_
const std::vector< std::string > supported_
Definition: AmendmentTable_test.cpp:74
ripple::make_AmendmentTable
std::unique_ptr< AmendmentTable > make_AmendmentTable(std::chrono::seconds majorityTime, Section const &supported, Section const &enabled, Section const &vetoed, beast::Journal journal)
Definition: AmendmentTable.cpp:695
ripple::sfLedgerSequence
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
Definition: SField.h:358
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:79
ripple::AmendmentTable_test::emptySection
const Section emptySection
Definition: AmendmentTable_test.cpp:83
ripple::test::SuiteJournal
Definition: SuiteJournal.h:88
ripple::KeyType::secp256k1
@ secp256k1
ripple::AmendmentTable_test::testDetectMajority
void testDetectMajority(uint256 const &feat)
Definition: AmendmentTable_test.cpp:665
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:104
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::doRound
void doRound(uint256 const &feat, 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:367
ripple::AmendmentTable_test::testGet
void testGet()
Definition: AmendmentTable_test.cpp:139
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:121
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::makeSection
static Section makeSection(std::vector< std::string > const &amendments)
Definition: AmendmentTable_test.cpp:54
ripple::hash_append
void hash_append(Hasher &h, Slice const &v)
Definition: Slice.h:195
std::set::count
T count(T... args)
ripple::STVector256
Definition: STVector256.h:29
std::map::empty
T empty(T... args)
ripple::Rules
Rules controlling protocol behavior.
Definition: ReadView.h:127
ripple::AmendmentTable_test::testFeature
void testFeature(uint256 const &feat)
Definition: AmendmentTable_test.cpp:844
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:495
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:88
ripple::AmendmentTable_test::testBadConfig
void testBadConfig()
Definition: AmendmentTable_test.cpp:176
std::set
STL class.
ripple::AmendmentTable_test::run
void run() override
Definition: AmendmentTable_test.cpp:854
ripple::AmendmentTable_test::amendmentId
static uint256 amendmentId(std::string in)
Definition: AmendmentTable_test.cpp:42
ripple::AmendmentTable_test::enabled_
const std::vector< std::string > enabled_
Definition: AmendmentTable_test.cpp:78
ripple::AmendmentTable_test::testNoOnVetoed
void testNoOnVetoed(uint256 const &feat)
Definition: AmendmentTable_test.cpp:527
ripple::test::jtx::Env
A transaction testing environment.
Definition: Env.h:115
ripple::AmendmentTable_test::testLostMajority
void testLostMajority(uint256 const &feat)
Definition: AmendmentTable_test.cpp:729
Json::Value
Represents a JSON value.
Definition: json_value.h:145