Skip to content

Commit

Permalink
Add a test that covers transaction set building logic on randomized d…
Browse files Browse the repository at this point in the history
…ata. (#4507)

# Description

Add a test that covers transaction set building logic on randomized
data.

While this is not comprehensive (and probably can't be), I think that
will add increase our confidence in the upcoming tx set refactoring and
might prevent accidental changes in the future.

# Checklist
- [ ] Reviewed the
[contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes)
document
- [ ] Rebased on top of master (no merge commits)
- [ ] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio
extension)
- [ ] Compiles
- [ ] Ran all tests
- [ ] If change impacts performance, include supporting evidence per the
[performance
document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
  • Loading branch information
dmkozh authored Nov 4, 2024
2 parents 268f666 + 4d1b43f commit ef84d82
Show file tree
Hide file tree
Showing 16 changed files with 590 additions and 40 deletions.
8 changes: 5 additions & 3 deletions Builds/VisualStudio/stellar-core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ exit /b 0
<ClCompile Include="..\..\src\historywork\VerifyTxResultsWork.cpp" />
<ClCompile Include="..\..\src\historywork\WriteSnapshotWork.cpp" />
<ClCompile Include="..\..\src\historywork\WriteVerifiedCheckpointHashesWork.cpp" />
<ClCompile Include="..\..\src\history\CheckpointBuilder.cpp" />
<ClCompile Include="..\..\src\history\FileTransferInfo.cpp" />
<ClCompile Include="..\..\src\history\HistoryArchive.cpp" />
<ClCompile Include="..\..\src\history\HistoryArchiveManager.cpp" />
Expand Down Expand Up @@ -640,6 +641,7 @@ exit /b 0
<ClCompile Include="..\..\src\ledger\test\LiabilitiesTests.cpp" />
<ClCompile Include="..\..\src\ledger\SorobanMetrics.cpp" />
<ClCompile Include="..\..\src\ledger\TrustLineWrapper.cpp" />
<ClCompile Include="..\..\src\main\AppConnector.cpp" />
<ClCompile Include="..\..\src\main\Diagnostics.cpp" />
<ClCompile Include="..\..\src\main\QueryServer.cpp" />
<ClCompile Include="..\..\src\main\SettingsUpgradeUtils.cpp" />
Expand All @@ -654,7 +656,6 @@ exit /b 0
<ClCompile Include="..\..\src\overlay\FlowControlCapacity.cpp" />
<ClCompile Include="..\..\src\overlay\Hmac.cpp" />
<ClCompile Include="..\..\src\overlay\ItemFetcher.cpp" />
<ClCompile Include="..\..\src\overlay\OverlayAppConnector.cpp" />
<ClCompile Include="..\..\src\overlay\OverlayManagerImpl.cpp" />
<ClCompile Include="..\..\src\overlay\OverlayMetrics.cpp" />
<ClCompile Include="..\..\src\overlay\Peer.cpp" />
Expand Down Expand Up @@ -1032,6 +1033,7 @@ exit /b 0
<ClInclude Include="..\..\src\historywork\VerifyTxResultsWork.h" />
<ClInclude Include="..\..\src\historywork\WriteSnapshotWork.h" />
<ClInclude Include="..\..\src\historywork\WriteVerifiedCheckpointHashesWork.h" />
<ClInclude Include="..\..\src\history\CheckpointBuilder.h" />
<ClInclude Include="..\..\src\history\FileTransferInfo.h" />
<ClInclude Include="..\..\src\history\HistoryArchive.h" />
<ClInclude Include="..\..\src\history\HistoryArchiveManager.h" />
Expand Down Expand Up @@ -1075,6 +1077,7 @@ exit /b 0
<ClInclude Include="..\..\src\ledger\test\LedgerTestUtils.h" />
<ClInclude Include="..\..\src\ledger\SorobanMetrics.h" />
<ClInclude Include="..\..\src\ledger\TrustLineWrapper.h" />
<ClInclude Include="..\..\src\main\AppConnector.h" />
<ClInclude Include="..\..\src\main\Diagnostics.h" />
<ClInclude Include="..\..\src\main\QueryServer.h" />
<ClInclude Include="..\..\src\main\SettingsUpgradeUtils.h" />
Expand All @@ -1085,7 +1088,6 @@ exit /b 0
<ClInclude Include="..\..\src\overlay\FlowControlCapacity.h" />
<ClInclude Include="..\..\src\overlay\Hmac.h" />
<ClInclude Include="..\..\src\overlay\ItemFetcher.h" />
<ClInclude Include="..\..\src\overlay\OverlayAppConnector.h" />
<ClInclude Include="..\..\src\overlay\OverlayManager.h" />
<ClInclude Include="..\..\src\overlay\OverlayManagerImpl.h" />
<ClInclude Include="..\..\src\overlay\OverlayMetrics.h" />
Expand Down Expand Up @@ -1744,4 +1746,4 @@ $(OutDir)\bin\cxxbridge.exe ..\..\src\rust\src\lib.rs --cfg test=false --output
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
25 changes: 18 additions & 7 deletions Builds/VisualStudio/stellar-core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1338,9 +1338,6 @@
<ClCompile Include="..\..\src\overlay\TxAdverts.cpp">
<Filter>overlay</Filter>
</ClCompile>
<ClCompile Include="..\..\src\overlay\OverlayAppConnector.cpp">
<Filter>overlay</Filter>
</ClCompile>
<ClCompile Include="..\..\src\overlay\TxDemandsManager.cpp">
<Filter>overlay</Filter>
</ClCompile>
Expand Down Expand Up @@ -1377,6 +1374,15 @@
<ClCompile Include="..\..\src\ledger\LedgerStateSnapshot.cpp">
<Filter>ledger</Filter>
</ClCompile>
<ClCompile Include="..\..\lib\tracy\public\TracyClient.cpp" />
<ClCompile Include="..\..\src\simulation\ApplyLoad.cpp" />
<ClCompile Include="..\..\src\simulation\TxGenerator.cpp" />
<ClCompile Include="..\..\src\main\AppConnector.cpp">
<Filter>main</Filter>
</ClCompile>
<ClCompile Include="..\..\src\history\CheckpointBuilder.cpp">
<Filter>history</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\lib\util\cpptoml.h">
Expand Down Expand Up @@ -2363,9 +2369,6 @@
<ClInclude Include="..\..\src\overlay\TxAdverts.h">
<Filter>overlay</Filter>
</ClInclude>
<ClInclude Include="..\..\src\overlay\OverlayAppConnector.h">
<Filter>overlay</Filter>
</ClInclude>
<ClInclude Include="..\..\src\overlay\TxDemandsManager.h">
<Filter>overlay</Filter>
</ClInclude>
Expand Down Expand Up @@ -2405,6 +2408,14 @@
<ClInclude Include="..\..\src\ledger\LedgerStateSnapshot.h">
<Filter>ledger</Filter>
</ClInclude>
<ClInclude Include="..\..\src\simulation\ApplyLoad.h" />
<ClInclude Include="..\..\src\simulation\TxGenerator.h" />
<ClInclude Include="..\..\src\main\AppConnector.h">
<Filter>main</Filter>
</ClInclude>
<ClInclude Include="..\..\src\history\CheckpointBuilder.h">
<Filter>history</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\AUTHORS" />
Expand Down Expand Up @@ -2650,4 +2661,4 @@
<Text Include="..\..\INSTALL-Windows.md" />
<Text Include="..\..\LICENSE-APACHE.txt" />
</ItemGroup>
</Project>
</Project>
7 changes: 7 additions & 0 deletions src/herder/SurgePricingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,16 @@ SurgePricingPriorityQueue::TxComparator::txLessThan(
{
return cmp3 < 0;
}
#ifndef BUILD_TESTS
// break tie with pointer arithmetic
auto lx = reinterpret_cast<size_t>(tx1.get()) ^ mSeed;
auto rx = reinterpret_cast<size_t>(tx2.get()) ^ mSeed;
#else
// Sort transactions deterministically in tests in order to ensure
// reproducibility.
auto lx = tx1->getFullHash();
auto rx = tx2->getFullHash();
#endif
return lx < rx;
}

Expand Down
2 changes: 1 addition & 1 deletion src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6060,4 +6060,4 @@ TEST_CASE_VERSIONS("Fair nomination win rates", "[herder]")
testWinProbabilities(sks, validators, 10000);
}
}
}
}
Loading

0 comments on commit ef84d82

Please sign in to comment.