Created
January 2, 2019 06:36
-
-
Save fuzz-ai/8937d94760f66eda1dfbcb31e3b63fdc to your computer and use it in GitHub Desktop.
testStress() original version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void | |
| testStress() | |
| { | |
| using namespace csf; | |
| LedgerTrie<Ledger> t; | |
| LedgerHistoryHelper h; | |
| // Test quasi-randomly add/remove supporting for different ledgers | |
| // from a branching history. | |
| // Ledgers have sequence 1,2,3,4 | |
| std::uint32_t const depth = 4; | |
| // Each ledger has 4 possible children | |
| std::uint32_t const width = 4; | |
| std::uint32_t const iterations = 10000; | |
| // Use explicit seed to have same results for CI | |
| std::mt19937 gen{ 42 }; | |
| std::uniform_int_distribution<> depthDist(0, depth-1); | |
| std::uniform_int_distribution<> widthDist(0, width-1); | |
| std::uniform_int_distribution<> flip(0, 1); | |
| for(std::uint32_t i = 0; i < iterations; ++i) | |
| { | |
| // pick a random ledger history | |
| std::string curr = ""; | |
| char depth = depthDist(gen); | |
| char offset = 0; | |
| for(char d = 0; d < depth; ++d) | |
| { | |
| char a = offset + widthDist(gen); | |
| curr += a; | |
| offset = (a + 1) * width; | |
| } | |
| // 50-50 to add remove | |
| if(flip(gen) == 0) | |
| t.insert(h[curr]); | |
| else | |
| t.remove(h[curr]); | |
| if(!BEAST_EXPECT(t.checkInvariants())) | |
| return; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment