mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-02 08:25:55 +00:00
Split unit tests to separate files
This commit is contained in:
@@ -169,12 +169,24 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\ripple_basics\containers\ripple_RangeSetUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_basics\utility\ripple_IniFile.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_basics\utility\ripple_StringUtilitiesUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\functional\ripple_Config.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -205,6 +217,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\functional\ripple_LoadFeeTrackUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\functional\ripple_LoadMonitor.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -212,6 +230,36 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\ripple_core.cpp" />
|
||||
<ClCompile Include="..\..\modules\ripple_data\crypto\ripple_CKeyDeterministicUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_RippleAddressUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_SerializedObjectUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_SerializerUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_STAmountUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_leveldb\ripple_leveldb.cpp" />
|
||||
<ClCompile Include="..\..\modules\ripple_sqlite\ripple_sqlite.c">
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Level4</WarningLevel>
|
||||
@@ -242,6 +290,30 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_ProofOfWorkFactoryUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SerializedTransactionUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SHAMapSyncUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SHAMapUnitTests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SqliteDatabase.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -490,6 +562,12 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Subtrees\sqlite\sqlite3.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Subtrees\websocket\src\base64\base64.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1539,6 +1617,7 @@
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_Job.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_JobQueue.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_LoadEvent.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_LoadFeeTrack.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_LoadMonitor.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_core\ripple_core.h" />
|
||||
<ClInclude Include="..\..\modules\ripple_data\crypto\ripple_Base58.h" />
|
||||
@@ -1788,6 +1867,7 @@
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PathRequest.h" />
|
||||
<ClInclude Include="..\..\src\cpp\ripple\RegularKeySetTransactor.h" />
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PathState.h" />
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ProofOfWorkFactory.h" />
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_RippleCalc.h" />
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_RippleLineCache.h" />
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_RippleState.h" />
|
||||
@@ -1873,6 +1953,8 @@
|
||||
<ClInclude Include="..\..\Subtrees\leveldb\util\mutexlock.h" />
|
||||
<ClInclude Include="..\..\Subtrees\leveldb\util\posix_logger.h" />
|
||||
<ClInclude Include="..\..\Subtrees\leveldb\util\random.h" />
|
||||
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3.h" />
|
||||
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3ext.h" />
|
||||
<ClInclude Include="..\..\Subtrees\websocket\src\base64\base64.h" />
|
||||
<ClInclude Include="..\..\Subtrees\websocket\src\common.hpp" />
|
||||
<ClInclude Include="..\..\Subtrees\websocket\src\connection.hpp" />
|
||||
|
||||
@@ -145,6 +145,12 @@
|
||||
<Filter Include="1. Modules\ripple_core\functional">
|
||||
<UniqueIdentifier>{f7a586fa-b21a-4c7b-b87e-5ac62f2758e4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="0. Third Party Code\sqlite">
|
||||
<UniqueIdentifier>{3739c942-adc7-4691-b67c-8ab83e2c6f3d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="1. Modules\ripple_app\refactored\misc">
|
||||
<UniqueIdentifier>{bb14df5d-f96f-4572-9e79-5e330eed30c9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\cpp\protobuf_core.cpp">
|
||||
@@ -390,24 +396,6 @@
|
||||
<ClCompile Include="..\..\src\cpp\ripple\WSDoor.cpp">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_DatabaseCon.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Validations.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Features.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_FeeVote.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashRouter.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\Ledger.cpp">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
@@ -429,9 +417,6 @@
|
||||
<ClCompile Include="..\..\src\cpp\ripple\SerializedValidation.cpp">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Config.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\HTTPRequest.cpp">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\network</Filter>
|
||||
</ClCompile>
|
||||
@@ -492,60 +477,12 @@
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_PackedMessage.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_ProofOfWorkFactory.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_ProofOfWork.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peer.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peers.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObjectStore.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObject.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_SerializedObjectTemplate.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_InfoSub.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_PeerSet.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_CanonicalTXSet.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SerializedLedger.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SerializedTransaction.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AcceptedLedgerTx.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AcceptedLedger.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\utility\ripple_JSONCache.cpp">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_OrderBook.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AccountItem.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AccountItems.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SHAMapDelta.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\shamap</Filter>
|
||||
</ClCompile>
|
||||
@@ -579,9 +516,6 @@
|
||||
<ClCompile Include="..\..\src\cpp\ripple\WSHandler.cpp">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AccountState.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="build\proto\ripple.pb.cc">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
@@ -594,15 +528,6 @@
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_LedgerConsensus.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\consensus</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Offer.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_NicknameState.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Application.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_PathRequest.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\pathing</Filter>
|
||||
</ClCompile>
|
||||
@@ -627,9 +552,6 @@
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_LocalCredentials.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_LedgerEntrySet.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
@@ -897,12 +819,135 @@
|
||||
<ClCompile Include="..\..\modules\ripple_core\functional\ripple_LoadFeeTrack.cpp">
|
||||
<Filter>1. Modules\ripple_core\functional</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Subtrees\sqlite\sqlite3.c">
|
||||
<Filter>0. Third Party Code\sqlite</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AcceptedLedger.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AcceptedLedgerTx.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AccountItem.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AccountItems.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_AccountState.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Application.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_CanonicalTXSet.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Config.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_DatabaseCon.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Features.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_FeeVote.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObject.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashedObjectStore.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_HashRouter.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_InfoSub.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_LoadManager.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_LocalCredentials.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_NicknameState.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Offer.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_OrderBook.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peer.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Peers.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_PeerSet.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_ProofOfWork.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_ProofOfWorkFactory.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SerializedLedger.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SerializedTransaction.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_UniqueNodeList.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_Validations.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\LedgerUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_ProofOfWorkFactoryUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SHAMapSyncUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\shamap</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SHAMapUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\shamap</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\cpp\ripple\ripple_SerializedTransactionUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_basics\containers\ripple_RangeSetUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_basics\containers</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_basics\utility\ripple_StringUtilitiesUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_basics\utility</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_core\functional\ripple_LoadFeeTrackUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_core\functional</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\crypto\ripple_CKeyDeterministicUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_data\crypto</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_RippleAddressUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_SerializedObjectUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_SerializerUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\modules\ripple_data\protocol\ripple_STAmountUnitTests.cpp">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\cpp\protobuf\src\google\protobuf\service.h">
|
||||
@@ -1202,27 +1247,6 @@
|
||||
<ClInclude Include="..\..\src\cpp\ripple\WSConnection.h">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\network</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_DatabaseCon.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ILoadFeeTrack.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IValidations.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IFeatures.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IFeeVote.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IHashRouter.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IUniqueNodeList.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\Ledger.h">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
@@ -1241,9 +1265,6 @@
|
||||
<ClInclude Include="..\..\src\cpp\ripple\SerializedValidation.h">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Config.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\HTTPRequest.h">
|
||||
<Filter>1. Modules\ripple_app\_unfactored\network</Filter>
|
||||
</ClInclude>
|
||||
@@ -1307,66 +1328,18 @@
|
||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_PackedMessage.h">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ProofOfWork.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IProofOfWorkFactory.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Peer.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IPeers.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObjectStore.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObject.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_SerializedObjectTemplate.h">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_InfoSub.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PeerSet.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_basics\types\ripple_BasicTypes.h">
|
||||
<Filter>1. Modules\ripple_basics\types</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_CanonicalTXSet.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_SerializedLedger.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_SerializedTransaction.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AcceptedLedgerTx.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AcceptedLedger.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_UptimeTimerAdapter.h">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_JSONCache.h">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_OrderBook.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AccountItem.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AccountItems.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_SHAMapTreeNode.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\shamap</Filter>
|
||||
</ClInclude>
|
||||
@@ -1391,9 +1364,6 @@
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_SHAMap.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\shamap</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AccountState.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_data\utility\ripple_UptimeTimerAdapter.h">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClInclude>
|
||||
@@ -1406,15 +1376,6 @@
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_LedgerConsensus.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\consensus</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Offer.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_NicknameState.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IApplication.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PathRequest.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\pathing</Filter>
|
||||
</ClInclude>
|
||||
@@ -1448,12 +1409,6 @@
|
||||
<ClInclude Include="..\..\modules\ripple_data\protocol\ripple_TxFormats.h">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_LocalCredentials.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Version.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_LedgerEntrySet.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
@@ -1725,8 +1680,110 @@
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_ILoadFeeTrack.h">
|
||||
<Filter>1. Modules\ripple_core\functional</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3.h">
|
||||
<Filter>0. Third Party Code\sqlite</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Subtrees\sqlite\sqlite3ext.h">
|
||||
<Filter>0. Third Party Code\sqlite</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AcceptedLedger.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AcceptedLedgerTx.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AccountItem.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AccountItems.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_AccountState.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_CanonicalTXSet.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Config.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_DatabaseCon.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObject.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_HashedObjectStore.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IApplication.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IFeatures.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IFeeVote.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IHashRouter.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ILoadFeeTrack.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ILoadManager.h">
|
||||
<Filter>1. Modules\ripple_app\refactored</Filter>
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_InfoSub.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IPeers.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IProofOfWorkFactory.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IUniqueNodeList.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_IValidations.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_LocalCredentials.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_NicknameState.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Offer.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_OrderBook.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Peer.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_PeerSet.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ProofOfWork.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_SerializedLedger.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_SerializedTransaction.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_Version.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_ProofOfWorkFactory.h">
|
||||
<Filter>1. Modules\ripple_app\refactored\misc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\ripple_core\functional\ripple_LoadFeeTrack.h">
|
||||
<Filter>1. Modules\ripple_core\functional</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -109,6 +109,11 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
namespace ripple
|
||||
{
|
||||
#endif
|
||||
|
||||
// VFALCO NOTE The order of these includes is critical, since they do not
|
||||
// include their own dependencies. This is what allows us to
|
||||
// linearize the include sequence and view it in one place.
|
||||
@@ -247,6 +252,17 @@
|
||||
#include "src/cpp/ripple/WSHandler.h"
|
||||
#include "src/cpp/ripple/WalletAddTransactor.h"
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
namespace ripple
|
||||
{
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// VFALCO TODO figure out who needs these and move to a sensible private header.
|
||||
@@ -387,6 +403,7 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength)
|
||||
#include "src/cpp/ripple/ripple_PathRequest.cpp"
|
||||
#include "src/cpp/ripple/ripple_PeerSet.cpp"
|
||||
#include "src/cpp/ripple/ripple_ProofOfWork.cpp"
|
||||
#include "src/cpp/ripple/ripple_ProofOfWorkFactory.h" // private
|
||||
#include "src/cpp/ripple/ripple_ProofOfWorkFactory.cpp"
|
||||
#include "src/cpp/ripple/ripple_SerializedLedger.cpp"
|
||||
#include "src/cpp/ripple/ripple_SerializedTransaction.cpp"
|
||||
@@ -398,6 +415,28 @@ static DH* handleTmpDh (SSL* ssl, int is_export, int iKeyLength)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 4
|
||||
|
||||
// Unit Tests
|
||||
//
|
||||
// These must be outside the namespace
|
||||
//
|
||||
// VFALCO TODO Eliminate the need for boost for unit tests.
|
||||
//
|
||||
#include "src/cpp/ripple/LedgerUnitTests.cpp"
|
||||
#include "src/cpp/ripple/ripple_SHAMapUnitTests.cpp"
|
||||
#include "src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp"
|
||||
#include "src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp"
|
||||
#include "src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp"
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
SETUP_LOG (RangeSet)
|
||||
|
||||
// VFALCO NOTE std::min and std::max not good enough?
|
||||
// NOTE Why isn't this written as a template?
|
||||
// TODO Replace this with std calls.
|
||||
//
|
||||
inline uint32 min (uint32 x, uint32 y)
|
||||
{
|
||||
return (x < y) ? x : y;
|
||||
@@ -180,32 +184,3 @@ void RangeSet::simplify ()
|
||||
it = nit;
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (RangeSet_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (RangeSet_test)
|
||||
{
|
||||
WriteLog (lsTRACE, RangeSet) << "RangeSet test begins";
|
||||
|
||||
RangeSet r1, r2;
|
||||
|
||||
r1.setRange (1, 10);
|
||||
r1.clearValue (5);
|
||||
r1.setRange (11, 20);
|
||||
|
||||
r2.setRange (1, 4);
|
||||
r2.setRange (6, 10);
|
||||
r2.setRange (10, 20);
|
||||
|
||||
if (r1.hasValue (5)) BOOST_FAIL ("RangeSet fail");
|
||||
|
||||
if (!r2.hasValue (9)) BOOST_FAIL ("RangeSet fail");
|
||||
|
||||
// TODO: Traverse functions must be tested
|
||||
|
||||
WriteLog (lsTRACE, RangeSet) << "RangeSet test complete";
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
BOOST_AUTO_TEST_SUITE (RangeSet_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (RangeSet_test)
|
||||
{
|
||||
WriteLog (lsTRACE, RangeSet) << "RangeSet test begins";
|
||||
|
||||
RangeSet r1, r2;
|
||||
|
||||
r1.setRange (1, 10);
|
||||
r1.clearValue (5);
|
||||
r1.setRange (11, 20);
|
||||
|
||||
r2.setRange (1, 4);
|
||||
r2.setRange (6, 10);
|
||||
r2.setRange (10, 20);
|
||||
|
||||
if (r1.hasValue (5)) BOOST_FAIL ("RangeSet fail");
|
||||
|
||||
if (!r2.hasValue (9)) BOOST_FAIL ("RangeSet fail");
|
||||
|
||||
// TODO: Traverse functions must be tested
|
||||
|
||||
WriteLog (lsTRACE, RangeSet) << "RangeSet test complete";
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -77,3 +77,7 @@ namespace ripple
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
// These must be outside the namespace (because of boost)
|
||||
#include "containers/ripple_RangeSetUnitTests.cpp"
|
||||
#include "utility/ripple_StringUtilitiesUnitTests.cpp"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// VFALCO TODO Repalce these with something more robust and without macros.
|
||||
//
|
||||
#if !defined(WIN32) && !defined(WIN64)
|
||||
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
|
||||
#endif
|
||||
@@ -259,53 +261,3 @@ bool parseQuality (const std::string& strSource, uint32& uQuality)
|
||||
|
||||
return !!uQuality;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE ( Utils)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( ParseUrl )
|
||||
{
|
||||
std::string strScheme;
|
||||
std::string strDomain;
|
||||
int iPort;
|
||||
std::string strPath;
|
||||
|
||||
if (!parseUrl ("lower://domain", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: lower://domain failed");
|
||||
|
||||
if (strScheme != "lower")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : scheme failed");
|
||||
|
||||
if (strDomain != "domain")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : domain failed");
|
||||
|
||||
if (iPort != -1)
|
||||
BOOST_FAIL ("parseUrl: lower://domain : port failed");
|
||||
|
||||
if (strPath != "")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : path failed");
|
||||
|
||||
if (!parseUrl ("UPPER://domain:234/", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ failed");
|
||||
|
||||
if (strScheme != "upper")
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ : scheme failed");
|
||||
|
||||
if (iPort != 234)
|
||||
BOOST_FAIL (boost::str (boost::format ("parseUrl: UPPER://domain:234/ : port failed: %d") % iPort));
|
||||
|
||||
if (strPath != "/")
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ : path failed");
|
||||
|
||||
if (!parseUrl ("Mixed://domain/path", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path failed");
|
||||
|
||||
if (strScheme != "mixed")
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path tolower failed");
|
||||
|
||||
if (strPath != "/path")
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path path failed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE ( Utils)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( ParseUrl )
|
||||
{
|
||||
std::string strScheme;
|
||||
std::string strDomain;
|
||||
int iPort;
|
||||
std::string strPath;
|
||||
|
||||
if (!parseUrl ("lower://domain", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: lower://domain failed");
|
||||
|
||||
if (strScheme != "lower")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : scheme failed");
|
||||
|
||||
if (strDomain != "domain")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : domain failed");
|
||||
|
||||
if (iPort != -1)
|
||||
BOOST_FAIL ("parseUrl: lower://domain : port failed");
|
||||
|
||||
if (strPath != "")
|
||||
BOOST_FAIL ("parseUrl: lower://domain : path failed");
|
||||
|
||||
if (!parseUrl ("UPPER://domain:234/", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ failed");
|
||||
|
||||
if (strScheme != "upper")
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ : scheme failed");
|
||||
|
||||
if (iPort != 234)
|
||||
BOOST_FAIL (boost::str (boost::format ("parseUrl: UPPER://domain:234/ : port failed: %d") % iPort));
|
||||
|
||||
if (strPath != "/")
|
||||
BOOST_FAIL ("parseUrl: UPPER://domain:234/ : path failed");
|
||||
|
||||
if (!parseUrl ("Mixed://domain/path", strScheme, strDomain, iPort, strPath))
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path failed");
|
||||
|
||||
if (strScheme != "mixed")
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path tolower failed");
|
||||
|
||||
if (strPath != "/path")
|
||||
BOOST_FAIL ("parseUrl: Mixed://domain/path path failed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -4,209 +4,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class LoadManager;
|
||||
|
||||
class LoadFeeTrack : public ILoadFeeTrack
|
||||
{
|
||||
public:
|
||||
LoadFeeTrack ()
|
||||
: mLocalTxnLoadFee (lftNormalFee)
|
||||
, mRemoteTxnLoadFee (lftNormalFee)
|
||||
, raiseCount (0)
|
||||
{
|
||||
}
|
||||
|
||||
// Scale using load as well as base rate
|
||||
uint64 scaleFeeLoad (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits, bool bAdmin)
|
||||
{
|
||||
static uint64 midrange (0x00000000FFFFFFFF);
|
||||
|
||||
bool big = (fee > midrange);
|
||||
|
||||
if (big) // big fee, divide first to avoid overflow
|
||||
fee /= baseFee;
|
||||
else // normal fee, multiply first for accuracy
|
||||
fee *= referenceFeeUnits;
|
||||
|
||||
uint32 feeFactor = std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee);
|
||||
|
||||
// Let admins pay the normal fee until the local load exceeds four times the remote
|
||||
if (bAdmin && (feeFactor > mRemoteTxnLoadFee) && (feeFactor < (4 * mRemoteTxnLoadFee)))
|
||||
feeFactor = mRemoteTxnLoadFee;
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
fee = mulDiv (fee, feeFactor, lftNormalFee);
|
||||
}
|
||||
|
||||
if (big) // Fee was big to start, must now multiply
|
||||
fee *= referenceFeeUnits;
|
||||
else // Fee was small to start, mst now divide
|
||||
fee /= baseFee;
|
||||
|
||||
return fee;
|
||||
}
|
||||
|
||||
// Scale from fee units to millionths of a ripple
|
||||
uint64 scaleFeeBase (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits)
|
||||
{
|
||||
return mulDiv (fee, referenceFeeUnits, baseFee);
|
||||
}
|
||||
|
||||
uint32 getRemoteFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return mRemoteTxnLoadFee;
|
||||
}
|
||||
|
||||
uint32 getLocalFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return mLocalTxnLoadFee;
|
||||
}
|
||||
|
||||
uint32 getLoadBase ()
|
||||
{
|
||||
return lftNormalFee;
|
||||
}
|
||||
|
||||
uint32 getLoadFactor ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee);
|
||||
}
|
||||
|
||||
bool isLoaded ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return (raiseCount != 0) || (mLocalTxnLoadFee != lftNormalFee);
|
||||
}
|
||||
|
||||
void setRemoteFee (uint32 f)
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
mRemoteTxnLoadFee = f;
|
||||
}
|
||||
|
||||
bool raiseLocalFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
if (++raiseCount < 2)
|
||||
return false;
|
||||
|
||||
uint32 origFee = mLocalTxnLoadFee;
|
||||
|
||||
if (mLocalTxnLoadFee < mRemoteTxnLoadFee) // make sure this fee takes effect
|
||||
mLocalTxnLoadFee = mRemoteTxnLoadFee;
|
||||
|
||||
mLocalTxnLoadFee += (mLocalTxnLoadFee / lftFeeIncFraction); // increment by 1/16th
|
||||
|
||||
if (mLocalTxnLoadFee > lftFeeMax)
|
||||
mLocalTxnLoadFee = lftFeeMax;
|
||||
|
||||
if (origFee == mLocalTxnLoadFee)
|
||||
return false;
|
||||
|
||||
WriteLog (lsDEBUG, LoadManager) << "Local load fee raised from " << origFee << " to " << mLocalTxnLoadFee;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool lowerLocalFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
uint32 origFee = mLocalTxnLoadFee;
|
||||
raiseCount = 0;
|
||||
|
||||
mLocalTxnLoadFee -= (mLocalTxnLoadFee / lftFeeDecFraction ); // reduce by 1/4
|
||||
|
||||
if (mLocalTxnLoadFee < lftNormalFee)
|
||||
mLocalTxnLoadFee = lftNormalFee;
|
||||
|
||||
if (origFee == mLocalTxnLoadFee)
|
||||
return false;
|
||||
|
||||
WriteLog (lsDEBUG, LoadManager) << "Local load fee lowered from " << origFee << " to " << mLocalTxnLoadFee;
|
||||
return true;
|
||||
}
|
||||
|
||||
Json::Value getJson (uint64 baseFee, uint32 referenceFeeUnits)
|
||||
{
|
||||
Json::Value j (Json::objectValue);
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
// base_fee = The cost to send a "reference" transaction under no load, in millionths of a Ripple
|
||||
j["base_fee"] = Json::Value::UInt (baseFee);
|
||||
|
||||
// load_fee = The cost to send a "reference" transaction now, in millionths of a Ripple
|
||||
j["load_fee"] = Json::Value::UInt (
|
||||
mulDiv (baseFee, std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee), lftNormalFee));
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
private:
|
||||
// VFALCO TODO Move this function to some "math utilities" file
|
||||
// compute (value)*(mul)/(div) - avoid overflow but keep precision
|
||||
uint64 mulDiv (uint64 value, uint32 mul, uint64 div)
|
||||
{
|
||||
// VFALCO TODO replace with beast::literal64bitUnsigned ()
|
||||
//
|
||||
static uint64 boundary = (0x00000000FFFFFFFF);
|
||||
|
||||
if (value > boundary) // Large value, avoid overflow
|
||||
return (value / div) * mul;
|
||||
else // Normal value, preserve accuracy
|
||||
return (value * mul) / div;
|
||||
}
|
||||
|
||||
private:
|
||||
static const int lftNormalFee = 256; // 256 is the minimum/normal load factor
|
||||
static const int lftFeeIncFraction = 16; // increase fee by 1/16
|
||||
static const int lftFeeDecFraction = 4; // decrease fee by 1/4
|
||||
static const int lftFeeMax = lftNormalFee * 1000000;
|
||||
|
||||
uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee
|
||||
uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee
|
||||
int raiseCount;
|
||||
|
||||
boost::mutex mLock;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
ILoadFeeTrack* ILoadFeeTrack::New ()
|
||||
{
|
||||
return new LoadFeeTrack;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (LoadManager_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (LoadFeeTrack_test)
|
||||
{
|
||||
WriteLog (lsDEBUG, LoadManager) << "Running load fee track test";
|
||||
|
||||
Config d; // get a default configuration object
|
||||
LoadFeeTrack l;
|
||||
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 10000);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeLoad (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE, false), 10000);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (1, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 1);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeLoad (1, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE, false), 1);
|
||||
|
||||
// Check new default fee values give same fees as old defaults
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_DEFAULT, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 10);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_ACCOUNT_RESERVE, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 200 * SYSTEM_CURRENCY_PARTS);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_OWNER_RESERVE, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 50 * SYSTEM_CURRENCY_PARTS);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_NICKNAME_CREATE, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 1000);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_OFFER, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 10);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_CONTRACT_OPERATION, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 1);
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
183
modules/ripple_core/functional/ripple_LoadFeeTrack.h
Normal file
183
modules/ripple_core/functional/ripple_LoadFeeTrack.h
Normal file
@@ -0,0 +1,183 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_LOADFEETRACK_RIPPLEHEADER
|
||||
#define RIPPLE_LOADFEETRACK_RIPPLEHEADER
|
||||
|
||||
// PRIVATE HEADER
|
||||
class LoadManager;
|
||||
|
||||
class LoadFeeTrack : public ILoadFeeTrack
|
||||
{
|
||||
public:
|
||||
LoadFeeTrack ()
|
||||
: mLocalTxnLoadFee (lftNormalFee)
|
||||
, mRemoteTxnLoadFee (lftNormalFee)
|
||||
, raiseCount (0)
|
||||
{
|
||||
}
|
||||
|
||||
// Scale using load as well as base rate
|
||||
uint64 scaleFeeLoad (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits, bool bAdmin)
|
||||
{
|
||||
static uint64 midrange (0x00000000FFFFFFFF);
|
||||
|
||||
bool big = (fee > midrange);
|
||||
|
||||
if (big) // big fee, divide first to avoid overflow
|
||||
fee /= baseFee;
|
||||
else // normal fee, multiply first for accuracy
|
||||
fee *= referenceFeeUnits;
|
||||
|
||||
uint32 feeFactor = std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee);
|
||||
|
||||
// Let admins pay the normal fee until the local load exceeds four times the remote
|
||||
if (bAdmin && (feeFactor > mRemoteTxnLoadFee) && (feeFactor < (4 * mRemoteTxnLoadFee)))
|
||||
feeFactor = mRemoteTxnLoadFee;
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
fee = mulDiv (fee, feeFactor, lftNormalFee);
|
||||
}
|
||||
|
||||
if (big) // Fee was big to start, must now multiply
|
||||
fee *= referenceFeeUnits;
|
||||
else // Fee was small to start, mst now divide
|
||||
fee /= baseFee;
|
||||
|
||||
return fee;
|
||||
}
|
||||
|
||||
// Scale from fee units to millionths of a ripple
|
||||
uint64 scaleFeeBase (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits)
|
||||
{
|
||||
return mulDiv (fee, referenceFeeUnits, baseFee);
|
||||
}
|
||||
|
||||
uint32 getRemoteFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return mRemoteTxnLoadFee;
|
||||
}
|
||||
|
||||
uint32 getLocalFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return mLocalTxnLoadFee;
|
||||
}
|
||||
|
||||
uint32 getLoadBase ()
|
||||
{
|
||||
return lftNormalFee;
|
||||
}
|
||||
|
||||
uint32 getLoadFactor ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee);
|
||||
}
|
||||
|
||||
bool isLoaded ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
return (raiseCount != 0) || (mLocalTxnLoadFee != lftNormalFee);
|
||||
}
|
||||
|
||||
void setRemoteFee (uint32 f)
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
mRemoteTxnLoadFee = f;
|
||||
}
|
||||
|
||||
bool raiseLocalFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
if (++raiseCount < 2)
|
||||
return false;
|
||||
|
||||
uint32 origFee = mLocalTxnLoadFee;
|
||||
|
||||
if (mLocalTxnLoadFee < mRemoteTxnLoadFee) // make sure this fee takes effect
|
||||
mLocalTxnLoadFee = mRemoteTxnLoadFee;
|
||||
|
||||
mLocalTxnLoadFee += (mLocalTxnLoadFee / lftFeeIncFraction); // increment by 1/16th
|
||||
|
||||
if (mLocalTxnLoadFee > lftFeeMax)
|
||||
mLocalTxnLoadFee = lftFeeMax;
|
||||
|
||||
if (origFee == mLocalTxnLoadFee)
|
||||
return false;
|
||||
|
||||
WriteLog (lsDEBUG, LoadManager) << "Local load fee raised from " << origFee << " to " << mLocalTxnLoadFee;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool lowerLocalFee ()
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
uint32 origFee = mLocalTxnLoadFee;
|
||||
raiseCount = 0;
|
||||
|
||||
mLocalTxnLoadFee -= (mLocalTxnLoadFee / lftFeeDecFraction ); // reduce by 1/4
|
||||
|
||||
if (mLocalTxnLoadFee < lftNormalFee)
|
||||
mLocalTxnLoadFee = lftNormalFee;
|
||||
|
||||
if (origFee == mLocalTxnLoadFee)
|
||||
return false;
|
||||
|
||||
WriteLog (lsDEBUG, LoadManager) << "Local load fee lowered from " << origFee << " to " << mLocalTxnLoadFee;
|
||||
return true;
|
||||
}
|
||||
|
||||
Json::Value getJson (uint64 baseFee, uint32 referenceFeeUnits)
|
||||
{
|
||||
Json::Value j (Json::objectValue);
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock sl (mLock);
|
||||
|
||||
// base_fee = The cost to send a "reference" transaction under no load, in millionths of a Ripple
|
||||
j["base_fee"] = Json::Value::UInt (baseFee);
|
||||
|
||||
// load_fee = The cost to send a "reference" transaction now, in millionths of a Ripple
|
||||
j["load_fee"] = Json::Value::UInt (
|
||||
mulDiv (baseFee, std::max (mLocalTxnLoadFee, mRemoteTxnLoadFee), lftNormalFee));
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
private:
|
||||
// VFALCO TODO Move this function to some "math utilities" file
|
||||
// compute (value)*(mul)/(div) - avoid overflow but keep precision
|
||||
uint64 mulDiv (uint64 value, uint32 mul, uint64 div)
|
||||
{
|
||||
// VFALCO TODO replace with beast::literal64bitUnsigned ()
|
||||
//
|
||||
static uint64 boundary = (0x00000000FFFFFFFF);
|
||||
|
||||
if (value > boundary) // Large value, avoid overflow
|
||||
return (value / div) * mul;
|
||||
else // Normal value, preserve accuracy
|
||||
return (value * mul) / div;
|
||||
}
|
||||
|
||||
private:
|
||||
static const int lftNormalFee = 256; // 256 is the minimum/normal load factor
|
||||
static const int lftFeeIncFraction = 16; // increase fee by 1/16
|
||||
static const int lftFeeDecFraction = 4; // decrease fee by 1/4
|
||||
static const int lftFeeMax = lftNormalFee * 1000000;
|
||||
|
||||
uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee
|
||||
uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee
|
||||
int raiseCount;
|
||||
|
||||
boost::mutex mLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
BOOST_AUTO_TEST_SUITE (LoadManager_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (LoadFeeTrack_test)
|
||||
{
|
||||
WriteLog (lsDEBUG, LoadManager) << "Running load fee track test";
|
||||
|
||||
Config d; // get a default configuration object
|
||||
LoadFeeTrack l;
|
||||
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 10000);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeLoad (10000, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE, false), 10000);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (1, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 1);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeLoad (1, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE, false), 1);
|
||||
|
||||
// Check new default fee values give same fees as old defaults
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_DEFAULT, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 10);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_ACCOUNT_RESERVE, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 200 * SYSTEM_CURRENCY_PARTS);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_OWNER_RESERVE, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 50 * SYSTEM_CURRENCY_PARTS);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_NICKNAME_CREATE, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 1000);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_OFFER, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 10);
|
||||
BOOST_REQUIRE_EQUAL (l.scaleFeeBase (d.FEE_CONTRACT_OPERATION, d.FEE_DEFAULT, d.TRANSACTION_FEE_BASE), 1);
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -19,9 +19,23 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
namespace ripple
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "functional/ripple_Config.cpp"
|
||||
#include "functional/ripple_LoadFeeTrack.h" // private
|
||||
#include "functional/ripple_LoadFeeTrack.cpp"
|
||||
#include "functional/ripple_Job.cpp"
|
||||
#include "functional/ripple_JobQueue.cpp"
|
||||
#include "functional/ripple_LoadEvent.cpp"
|
||||
#include "functional/ripple_LoadMonitor.cpp"
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
// These must be outside the namespace
|
||||
|
||||
#include "functional/ripple_LoadFeeTrackUnitTests.cpp"
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
namespace ripple
|
||||
{
|
||||
#endif
|
||||
|
||||
// VFALCO NOTE Indentation shows dependency hierarchy
|
||||
//
|
||||
/**/#include "functional/ripple_Config.h"
|
||||
@@ -41,4 +46,8 @@
|
||||
/*.*/#include "functional/ripple_Job.h"
|
||||
/**/#include "functional/ripple_JobQueue.h"
|
||||
|
||||
#if RIPPLE_USE_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -346,38 +346,3 @@ EC_KEY* CKey::GeneratePrivateDeterministicKey (const RippleAddress& pubGen, cons
|
||||
|
||||
return pkey;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (DeterministicKeys_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (DeterminsticKeys_test1)
|
||||
{
|
||||
Log (lsDEBUG) << "Beginning deterministic key test";
|
||||
|
||||
uint128 seed1, seed2;
|
||||
seed1.SetHex ("71ED064155FFADFA38782C5E0158CB26");
|
||||
seed2.SetHex ("CF0C3BE4485961858C4198515AE5B965");
|
||||
CKey root1 (seed1), root2 (seed2);
|
||||
|
||||
uint256 priv1, priv2;
|
||||
root1.GetPrivateKeyU (priv1);
|
||||
root2.GetPrivateKeyU (priv2);
|
||||
|
||||
if (priv1.GetHex () != "7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8")
|
||||
BOOST_FAIL ("Incorrect private key for generator");
|
||||
|
||||
if (priv2.GetHex () != "98BC2EACB26EB021D1A6293C044D88BA2F0B6729A2772DEEBF2E21A263C1740B")
|
||||
BOOST_FAIL ("Incorrect private key for generator");
|
||||
|
||||
RippleAddress nSeed;
|
||||
nSeed.setSeed (seed1);
|
||||
|
||||
if (nSeed.humanSeed () != "shHM53KPZ87Gwdqarm1bAmPeXg8Tn")
|
||||
BOOST_FAIL ("Incorrect human seed");
|
||||
|
||||
if (nSeed.humanSeed1751 () != "MAD BODY ACE MINT OKAY HUB WHAT DATA SACK FLAT DANA MATH")
|
||||
BOOST_FAIL ("Incorrect 1751 seed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
BOOST_AUTO_TEST_SUITE (DeterministicKeys_test)
|
||||
|
||||
BOOST_AUTO_TEST_CASE (DeterminsticKeys_test1)
|
||||
{
|
||||
Log (lsDEBUG) << "Beginning deterministic key test";
|
||||
|
||||
uint128 seed1, seed2;
|
||||
seed1.SetHex ("71ED064155FFADFA38782C5E0158CB26");
|
||||
seed2.SetHex ("CF0C3BE4485961858C4198515AE5B965");
|
||||
CKey root1 (seed1), root2 (seed2);
|
||||
|
||||
uint256 priv1, priv2;
|
||||
root1.GetPrivateKeyU (priv1);
|
||||
root2.GetPrivateKeyU (priv2);
|
||||
|
||||
if (priv1.GetHex () != "7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8")
|
||||
BOOST_FAIL ("Incorrect private key for generator");
|
||||
|
||||
if (priv2.GetHex () != "98BC2EACB26EB021D1A6293C044D88BA2F0B6729A2772DEEBF2E21A263C1740B")
|
||||
BOOST_FAIL ("Incorrect private key for generator");
|
||||
|
||||
RippleAddress nSeed;
|
||||
nSeed.setSeed (seed1);
|
||||
|
||||
if (nSeed.humanSeed () != "shHM53KPZ87Gwdqarm1bAmPeXg8Tn")
|
||||
BOOST_FAIL ("Incorrect human seed");
|
||||
|
||||
if (nSeed.humanSeed1751 () != "MAD BODY ACE MINT OKAY HUB WHAT DATA SACK FLAT DANA MATH")
|
||||
BOOST_FAIL ("Incorrect 1751 seed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
@@ -865,71 +865,3 @@ RippleAddress RippleAddress::createSeedGeneric (const std::string& strText)
|
||||
|
||||
return naNew;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (ripple_address)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( check_crypto )
|
||||
{
|
||||
// Construct a seed.
|
||||
RippleAddress naSeed;
|
||||
|
||||
BOOST_CHECK (naSeed.setSeedGeneric ("masterpassphrase"));
|
||||
BOOST_CHECK_MESSAGE (naSeed.humanSeed () == "snoPBrXtMeMyMHUVTgbuqAfg1SUTb", naSeed.humanSeed ());
|
||||
|
||||
// Create node public/private key pair
|
||||
RippleAddress naNodePublic = RippleAddress::createNodePublic (naSeed);
|
||||
RippleAddress naNodePrivate = RippleAddress::createNodePrivate (naSeed);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naNodePublic.humanNodePublic () == "n94a1u4jAz288pZLtw6yFWVbi89YamiC6JBXPVUj5zmExe5fTVg9", naNodePublic.humanNodePublic ());
|
||||
BOOST_CHECK_MESSAGE (naNodePrivate.humanNodePrivate () == "pnen77YEeUd4fFKG7iycBWcwKpTaeFRkW2WFostaATy1DSupwXe", naNodePrivate.humanNodePrivate ());
|
||||
|
||||
// Check node signing.
|
||||
Blob vucTextSrc = strCopy ("Hello, nurse!");
|
||||
uint256 uHash = Serializer::getSHA512Half (vucTextSrc);
|
||||
Blob vucTextSig;
|
||||
|
||||
naNodePrivate.signNodePrivate (uHash, vucTextSig);
|
||||
BOOST_CHECK_MESSAGE (naNodePublic.verifyNodePublic (uHash, vucTextSig), "Verify failed.");
|
||||
|
||||
// Construct a public generator from the seed.
|
||||
RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naSeed);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naGenerator.humanGenerator () == "fhuJKrhSDzV2SkjLn9qbwm5AaRmrxDPfFsHDCP6yfDZWcxDFz4mt", naGenerator.humanGenerator ());
|
||||
|
||||
// Create account #0 public/private key pair.
|
||||
RippleAddress naAccountPublic0 = RippleAddress::createAccountPublic (naGenerator, 0);
|
||||
RippleAddress naAccountPrivate0 = RippleAddress::createAccountPrivate (naGenerator, naSeed, 0);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic0.humanAccountID () == "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", naAccountPublic0.humanAccountID ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic0.humanAccountPublic () == "aBQG8RQAzjs1eTKFEAQXr2gS4utcDiEC9wmi7pfUPTi27VCahwgw", naAccountPublic0.humanAccountPublic ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate0.humanAccountPrivate () == "p9JfM6HHi64m6mvB6v5k7G2b1cXzGmYiCNJf6GHPKvFTWdeRVjh", naAccountPrivate0.humanAccountPrivate ());
|
||||
|
||||
// Create account #1 public/private key pair.
|
||||
RippleAddress naAccountPublic1 = RippleAddress::createAccountPublic (naGenerator, 1);
|
||||
RippleAddress naAccountPrivate1 = RippleAddress::createAccountPrivate (naGenerator, naSeed, 1);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic1.humanAccountID () == "r4bYF7SLUMD7QgSLLpgJx38WJSY12ViRjP", naAccountPublic1.humanAccountID ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic1.humanAccountPublic () == "aBPXpTfuLy1Bhk3HnGTTAqnovpKWQ23NpFMNkAF6F1Atg5vDyPrw", naAccountPublic1.humanAccountPublic ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate1.humanAccountPrivate () == "p9JEm822LMrzJii1k7TvdphfENTp6G5jr253Xa5rkzUWVr8ogQt", naAccountPrivate1.humanAccountPrivate ());
|
||||
|
||||
// Check account signing.
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate0.accountPrivateSign (uHash, vucTextSig), "Signing failed.");
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic0.accountPublicVerify (uHash, vucTextSig), "Verify failed.");
|
||||
BOOST_CHECK_MESSAGE (!naAccountPublic1.accountPublicVerify (uHash, vucTextSig), "Anti-verify failed.");
|
||||
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate1.accountPrivateSign (uHash, vucTextSig), "Signing failed.");
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic1.accountPublicVerify (uHash, vucTextSig), "Verify failed.");
|
||||
BOOST_CHECK_MESSAGE (!naAccountPublic0.accountPublicVerify (uHash, vucTextSig), "Anti-verify failed.");
|
||||
|
||||
// Check account encryption.
|
||||
Blob vucTextCipher
|
||||
= naAccountPrivate0.accountPrivateEncrypt (naAccountPublic1, vucTextSrc);
|
||||
Blob vucTextRecovered
|
||||
= naAccountPrivate1.accountPrivateDecrypt (naAccountPublic0, vucTextCipher);
|
||||
|
||||
BOOST_CHECK_MESSAGE (vucTextSrc == vucTextRecovered, "Encrypt-decrypt failed.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
BOOST_AUTO_TEST_SUITE (ripple_address)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( check_crypto )
|
||||
{
|
||||
// Construct a seed.
|
||||
RippleAddress naSeed;
|
||||
|
||||
BOOST_CHECK (naSeed.setSeedGeneric ("masterpassphrase"));
|
||||
BOOST_CHECK_MESSAGE (naSeed.humanSeed () == "snoPBrXtMeMyMHUVTgbuqAfg1SUTb", naSeed.humanSeed ());
|
||||
|
||||
// Create node public/private key pair
|
||||
RippleAddress naNodePublic = RippleAddress::createNodePublic (naSeed);
|
||||
RippleAddress naNodePrivate = RippleAddress::createNodePrivate (naSeed);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naNodePublic.humanNodePublic () == "n94a1u4jAz288pZLtw6yFWVbi89YamiC6JBXPVUj5zmExe5fTVg9", naNodePublic.humanNodePublic ());
|
||||
BOOST_CHECK_MESSAGE (naNodePrivate.humanNodePrivate () == "pnen77YEeUd4fFKG7iycBWcwKpTaeFRkW2WFostaATy1DSupwXe", naNodePrivate.humanNodePrivate ());
|
||||
|
||||
// Check node signing.
|
||||
Blob vucTextSrc = strCopy ("Hello, nurse!");
|
||||
uint256 uHash = Serializer::getSHA512Half (vucTextSrc);
|
||||
Blob vucTextSig;
|
||||
|
||||
naNodePrivate.signNodePrivate (uHash, vucTextSig);
|
||||
BOOST_CHECK_MESSAGE (naNodePublic.verifyNodePublic (uHash, vucTextSig), "Verify failed.");
|
||||
|
||||
// Construct a public generator from the seed.
|
||||
RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naSeed);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naGenerator.humanGenerator () == "fhuJKrhSDzV2SkjLn9qbwm5AaRmrxDPfFsHDCP6yfDZWcxDFz4mt", naGenerator.humanGenerator ());
|
||||
|
||||
// Create account #0 public/private key pair.
|
||||
RippleAddress naAccountPublic0 = RippleAddress::createAccountPublic (naGenerator, 0);
|
||||
RippleAddress naAccountPrivate0 = RippleAddress::createAccountPrivate (naGenerator, naSeed, 0);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic0.humanAccountID () == "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", naAccountPublic0.humanAccountID ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic0.humanAccountPublic () == "aBQG8RQAzjs1eTKFEAQXr2gS4utcDiEC9wmi7pfUPTi27VCahwgw", naAccountPublic0.humanAccountPublic ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate0.humanAccountPrivate () == "p9JfM6HHi64m6mvB6v5k7G2b1cXzGmYiCNJf6GHPKvFTWdeRVjh", naAccountPrivate0.humanAccountPrivate ());
|
||||
|
||||
// Create account #1 public/private key pair.
|
||||
RippleAddress naAccountPublic1 = RippleAddress::createAccountPublic (naGenerator, 1);
|
||||
RippleAddress naAccountPrivate1 = RippleAddress::createAccountPrivate (naGenerator, naSeed, 1);
|
||||
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic1.humanAccountID () == "r4bYF7SLUMD7QgSLLpgJx38WJSY12ViRjP", naAccountPublic1.humanAccountID ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic1.humanAccountPublic () == "aBPXpTfuLy1Bhk3HnGTTAqnovpKWQ23NpFMNkAF6F1Atg5vDyPrw", naAccountPublic1.humanAccountPublic ());
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate1.humanAccountPrivate () == "p9JEm822LMrzJii1k7TvdphfENTp6G5jr253Xa5rkzUWVr8ogQt", naAccountPrivate1.humanAccountPrivate ());
|
||||
|
||||
// Check account signing.
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate0.accountPrivateSign (uHash, vucTextSig), "Signing failed.");
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic0.accountPublicVerify (uHash, vucTextSig), "Verify failed.");
|
||||
BOOST_CHECK_MESSAGE (!naAccountPublic1.accountPublicVerify (uHash, vucTextSig), "Anti-verify failed.");
|
||||
|
||||
BOOST_CHECK_MESSAGE (naAccountPrivate1.accountPrivateSign (uHash, vucTextSig), "Signing failed.");
|
||||
BOOST_CHECK_MESSAGE (naAccountPublic1.accountPublicVerify (uHash, vucTextSig), "Verify failed.");
|
||||
BOOST_CHECK_MESSAGE (!naAccountPublic0.accountPublicVerify (uHash, vucTextSig), "Anti-verify failed.");
|
||||
|
||||
// Check account encryption.
|
||||
Blob vucTextCipher
|
||||
= naAccountPrivate0.accountPrivateEncrypt (naAccountPublic1, vucTextSrc);
|
||||
Blob vucTextRecovered
|
||||
= naAccountPrivate1.accountPrivateDecrypt (naAccountPublic0, vucTextCipher);
|
||||
|
||||
BOOST_CHECK_MESSAGE (vucTextSrc == vucTextRecovered, "Encrypt-decrypt failed.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -1298,521 +1298,3 @@ Json::Value STAmount::getJson (int) const
|
||||
setJson (elem);
|
||||
return elem;
|
||||
}
|
||||
|
||||
// For unit tests:
|
||||
static STAmount serdes (const STAmount& s)
|
||||
{
|
||||
Serializer ser;
|
||||
|
||||
s.add (ser);
|
||||
|
||||
SerializerIterator sit (ser);
|
||||
|
||||
return STAmount::deserialize (sit);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (amount)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( setValue_test )
|
||||
{
|
||||
STAmount saTmp;
|
||||
|
||||
#if 0
|
||||
// Check native floats
|
||||
saTmp.setFullValue ("1^0");
|
||||
BOOST_CHECK_MESSAGE (SYSTEM_CURRENCY_PARTS == saTmp.getNValue (), "float integer failed");
|
||||
saTmp.setFullValue ("0^1");
|
||||
BOOST_CHECK_MESSAGE (SYSTEM_CURRENCY_PARTS / 10 == saTmp.getNValue (), "float fraction failed");
|
||||
saTmp.setFullValue ("0^12");
|
||||
BOOST_CHECK_MESSAGE (12 * SYSTEM_CURRENCY_PARTS / 100 == saTmp.getNValue (), "float fraction failed");
|
||||
saTmp.setFullValue ("1^2");
|
||||
BOOST_CHECK_MESSAGE (SYSTEM_CURRENCY_PARTS + (2 * SYSTEM_CURRENCY_PARTS / 10) == saTmp.getNValue (), "float combined failed");
|
||||
#endif
|
||||
|
||||
// Check native integer
|
||||
saTmp.setFullValue ("1");
|
||||
BOOST_CHECK_MESSAGE (1 == saTmp.getNValue (), "integer failed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( NativeCurrency_test )
|
||||
{
|
||||
STAmount zero, one (1), hundred (100);
|
||||
|
||||
if (serdes (zero) != zero) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (one) != one) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (hundred) != hundred) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!zero.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!hundred.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!zero.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (one.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (hundred.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount ().getText () != "0") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (31).getText () != "31") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (310).getText () != "310") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
BOOST_TEST_MESSAGE ("Amount NC Complete");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( CustomCurrency_test )
|
||||
{
|
||||
STAmount zero (CURRENCY_ONE, ACCOUNT_ONE), one (CURRENCY_ONE, ACCOUNT_ONE, 1), hundred (CURRENCY_ONE, ACCOUNT_ONE, 100);
|
||||
|
||||
serdes (one).getRaw ();
|
||||
|
||||
if (serdes (zero) != zero) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (one) != one) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (hundred) != hundred) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (zero.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (hundred.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!zero.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (one.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (hundred.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE).getText () != "0") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31).getText () != "31") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, 1).getText () != "310") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -1).getText () != "3.1") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -2).getText () != "0.31") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 1");
|
||||
|
||||
if (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 2");
|
||||
|
||||
if (STAmount::multiply (STAmount (20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 3");
|
||||
|
||||
if (STAmount::multiply (STAmount (20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 4");
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
||||
{
|
||||
WriteLog (lsFATAL, STAmount) << "60/3 = " <<
|
||||
STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60),
|
||||
STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText ();
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
}
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "20")
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), uint160 (), ACCOUNT_XRP).getText () != "20")
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
|
||||
STAmount a1 (CURRENCY_ONE, ACCOUNT_ONE, 60), a2 (CURRENCY_ONE, ACCOUNT_ONE, 10, -1);
|
||||
|
||||
if (STAmount::divide (a2, a1, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a1, a2)))
|
||||
BOOST_FAIL ("STAmount setRate(getRate) fail");
|
||||
|
||||
if (STAmount::divide (a1, a2, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a2, a1)))
|
||||
BOOST_FAIL ("STAmount setRate(getRate) fail");
|
||||
|
||||
BOOST_TEST_MESSAGE ("Amount CC Complete");
|
||||
}
|
||||
|
||||
static bool roundTest (int n, int d, int m)
|
||||
{
|
||||
// check STAmount rounding
|
||||
STAmount num (CURRENCY_ONE, ACCOUNT_ONE, n);
|
||||
STAmount den (CURRENCY_ONE, ACCOUNT_ONE, d);
|
||||
STAmount mul (CURRENCY_ONE, ACCOUNT_ONE, m);
|
||||
STAmount quot = STAmount::divide (n, d, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount res = STAmount::multiply (quot, mul, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (res.isNative ())
|
||||
BOOST_FAIL ("Product is native");
|
||||
|
||||
res.roundSelf ();
|
||||
|
||||
STAmount cmp (CURRENCY_ONE, ACCOUNT_ONE, (n * m) / d);
|
||||
|
||||
if (cmp.isNative ())
|
||||
BOOST_FAIL ("Comparison amount is native");
|
||||
|
||||
if (res == cmp)
|
||||
return true;
|
||||
|
||||
cmp.throwComparable (res);
|
||||
WriteLog (lsWARNING, STAmount) << "(" << num.getText () << "/" << den.getText () << ") X " << mul.getText () << " = "
|
||||
<< res.getText () << " not " << cmp.getText ();
|
||||
BOOST_FAIL ("Round fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
static void mulTest (int a, int b)
|
||||
{
|
||||
STAmount aa (CURRENCY_ONE, ACCOUNT_ONE, a);
|
||||
STAmount bb (CURRENCY_ONE, ACCOUNT_ONE, b);
|
||||
STAmount prod1 (STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE));
|
||||
|
||||
if (prod1.isNative ())
|
||||
BOOST_FAIL ("product is native");
|
||||
|
||||
STAmount prod2 (CURRENCY_ONE, ACCOUNT_ONE, static_cast<uint64> (a) * static_cast<uint64> (b));
|
||||
|
||||
if (prod1 != prod2)
|
||||
{
|
||||
WriteLog (lsWARNING, STAmount) << "nn(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText ()
|
||||
<< " not " << prod2.getFullText ();
|
||||
BOOST_WARN ("Multiplication result is not exact");
|
||||
}
|
||||
|
||||
aa = a;
|
||||
prod1 = STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (prod1 != prod2)
|
||||
{
|
||||
WriteLog (lsWARNING, STAmount) << "n(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText ()
|
||||
<< " not " << prod2.getFullText ();
|
||||
BOOST_WARN ("Multiplication result is not exact");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( CurrencyMulDivTests )
|
||||
{
|
||||
CBigNum b;
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
uint64 r = rand ();
|
||||
r <<= 32;
|
||||
r |= rand ();
|
||||
b.setuint64 (r);
|
||||
|
||||
if (b.getuint64 () != r)
|
||||
{
|
||||
WriteLog (lsFATAL, STAmount) << r << " != " << b.getuint64 () << " " << b.ToString (16);
|
||||
BOOST_FAIL ("setull64/getull64 failure");
|
||||
}
|
||||
}
|
||||
|
||||
// Test currency multiplication and division operations such as
|
||||
// convertToDisplayAmount, convertToInternalAmount, getRate, getClaimed, and getNeeded
|
||||
|
||||
if (STAmount::getRate (STAmount (1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 1");
|
||||
|
||||
if (STAmount::getRate (STAmount (10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 2");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 3");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 4");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 5");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 6");
|
||||
|
||||
if (STAmount::getRate (STAmount (1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 7");
|
||||
|
||||
if (STAmount::getRate (STAmount (10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 8");
|
||||
|
||||
roundTest (1, 3, 3);
|
||||
roundTest (2, 3, 9);
|
||||
roundTest (1, 7, 21);
|
||||
roundTest (1, 2, 4);
|
||||
roundTest (3, 9, 18);
|
||||
roundTest (7, 11, 44);
|
||||
|
||||
for (int i = 0; i <= 100000; ++i)
|
||||
mulTest (rand () % 10000000, rand () % 10000000);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( UnderFlowTests )
|
||||
{
|
||||
STAmount bigNative (STAmount::cMaxNative / 2);
|
||||
STAmount bigValue (CURRENCY_ONE, ACCOUNT_ONE,
|
||||
(STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMaxOffset - 1);
|
||||
STAmount smallValue (CURRENCY_ONE, ACCOUNT_ONE,
|
||||
(STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMinOffset + 1);
|
||||
STAmount zero (CURRENCY_ONE, ACCOUNT_ONE, 0);
|
||||
|
||||
STAmount smallXsmall = STAmount::multiply (smallValue, smallValue, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (!smallXsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: smallXsmall != 0");
|
||||
|
||||
STAmount bigDsmall = STAmount::divide (smallValue, bigValue, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: small/big != 0: " << bigDsmall);
|
||||
|
||||
bigDsmall = STAmount::divide (smallValue, bigNative, CURRENCY_ONE, uint160 ());
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: small/bigNative != 0: " << bigDsmall);
|
||||
|
||||
bigDsmall = STAmount::divide (smallValue, bigValue, uint160 (), uint160 ());
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: (small/big)->N != 0: " << bigDsmall);
|
||||
|
||||
bigDsmall = STAmount::divide (smallValue, bigNative, uint160 (), uint160 ());
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: (small/bigNative)->N != 0: " << bigDsmall);
|
||||
|
||||
// very bad offer
|
||||
uint64 r = STAmount::getRate (smallValue, bigValue);
|
||||
|
||||
if (r != 0)
|
||||
BOOST_FAIL ("STAmount: getRate(smallOut/bigIn) != 0" << r);
|
||||
|
||||
// very good offer
|
||||
r = STAmount::getRate (bigValue, smallValue);
|
||||
|
||||
if (r != 0)
|
||||
BOOST_FAIL ("STAmount:: getRate(smallIn/bigOUt) != 0" << r);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
static void canonicalizeRound (bool isNative, uint64& value, int& offset, bool roundUp)
|
||||
void STAmount::canonicalizeRound (bool isNative, uint64& value, int& offset, bool roundUp)
|
||||
{
|
||||
if (!roundUp) // canonicalize already rounds down
|
||||
return;
|
||||
@@ -298,54 +298,3 @@ STAmount STAmount::divRound (const STAmount& num, const STAmount& den,
|
||||
return STAmount (uCurrencyID, uIssuerID, amount, offset, resultNegative);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (amountRound)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( amountRound_test )
|
||||
{
|
||||
uint64 value = 25000000000000000ull;
|
||||
int offset = -14;
|
||||
canonicalizeRound (false, value, offset, true);
|
||||
|
||||
STAmount one (CURRENCY_ONE, ACCOUNT_ONE, 1);
|
||||
STAmount two (CURRENCY_ONE, ACCOUNT_ONE, 2);
|
||||
STAmount three (CURRENCY_ONE, ACCOUNT_ONE, 3);
|
||||
|
||||
STAmount oneThird1 = STAmount::divRound (one, three, CURRENCY_ONE, ACCOUNT_ONE, false);
|
||||
STAmount oneThird2 = STAmount::divide (one, three, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount oneThird3 = STAmount::divRound (one, three, CURRENCY_ONE, ACCOUNT_ONE, true);
|
||||
WriteLog (lsINFO, STAmount) << oneThird1;
|
||||
WriteLog (lsINFO, STAmount) << oneThird2;
|
||||
WriteLog (lsINFO, STAmount) << oneThird3;
|
||||
|
||||
STAmount twoThird1 = STAmount::divRound (two, three, CURRENCY_ONE, ACCOUNT_ONE, false);
|
||||
STAmount twoThird2 = STAmount::divide (two, three, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount twoThird3 = STAmount::divRound (two, three, CURRENCY_ONE, ACCOUNT_ONE, true);
|
||||
WriteLog (lsINFO, STAmount) << twoThird1;
|
||||
WriteLog (lsINFO, STAmount) << twoThird2;
|
||||
WriteLog (lsINFO, STAmount) << twoThird3;
|
||||
|
||||
STAmount oneA = STAmount::mulRound (oneThird1, three, CURRENCY_ONE, ACCOUNT_ONE, false);
|
||||
STAmount oneB = STAmount::multiply (oneThird2, three, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount oneC = STAmount::mulRound (oneThird3, three, CURRENCY_ONE, ACCOUNT_ONE, true);
|
||||
WriteLog (lsINFO, STAmount) << oneA;
|
||||
WriteLog (lsINFO, STAmount) << oneB;
|
||||
WriteLog (lsINFO, STAmount) << oneC;
|
||||
|
||||
STAmount fourThirdsA = STAmount::addRound (twoThird2, twoThird2, false);
|
||||
STAmount fourThirdsB = twoThird2 + twoThird2;
|
||||
STAmount fourThirdsC = STAmount::addRound (twoThird2, twoThird2, true);
|
||||
WriteLog (lsINFO, STAmount) << fourThirdsA;
|
||||
WriteLog (lsINFO, STAmount) << fourThirdsB;
|
||||
WriteLog (lsINFO, STAmount) << fourThirdsC;
|
||||
|
||||
STAmount dripTest1 = STAmount::mulRound (twoThird2, two, uint160 (), uint160 (), false);
|
||||
STAmount dripTest2 = STAmount::multiply (twoThird2, two, uint160 (), uint160 ());
|
||||
STAmount dripTest3 = STAmount::mulRound (twoThird2, two, uint160 (), uint160 (), true);
|
||||
WriteLog (lsINFO, STAmount) << dripTest1;
|
||||
WriteLog (lsINFO, STAmount) << dripTest2;
|
||||
WriteLog (lsINFO, STAmount) << dripTest3;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
583
modules/ripple_data/protocol/ripple_STAmountUnitTests.cpp
Normal file
583
modules/ripple_data/protocol/ripple_STAmountUnitTests.cpp
Normal file
@@ -0,0 +1,583 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// For unit tests:
|
||||
static STAmount serdes (const STAmount& s)
|
||||
{
|
||||
Serializer ser;
|
||||
|
||||
s.add (ser);
|
||||
|
||||
SerializerIterator sit (ser);
|
||||
|
||||
return STAmount::deserialize (sit);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (amount)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( setValue_test )
|
||||
{
|
||||
STAmount saTmp;
|
||||
|
||||
#if 0
|
||||
// Check native floats
|
||||
saTmp.setFullValue ("1^0");
|
||||
BOOST_CHECK_MESSAGE (SYSTEM_CURRENCY_PARTS == saTmp.getNValue (), "float integer failed");
|
||||
saTmp.setFullValue ("0^1");
|
||||
BOOST_CHECK_MESSAGE (SYSTEM_CURRENCY_PARTS / 10 == saTmp.getNValue (), "float fraction failed");
|
||||
saTmp.setFullValue ("0^12");
|
||||
BOOST_CHECK_MESSAGE (12 * SYSTEM_CURRENCY_PARTS / 100 == saTmp.getNValue (), "float fraction failed");
|
||||
saTmp.setFullValue ("1^2");
|
||||
BOOST_CHECK_MESSAGE (SYSTEM_CURRENCY_PARTS + (2 * SYSTEM_CURRENCY_PARTS / 10) == saTmp.getNValue (), "float combined failed");
|
||||
#endif
|
||||
|
||||
// Check native integer
|
||||
saTmp.setFullValue ("1");
|
||||
BOOST_CHECK_MESSAGE (1 == saTmp.getNValue (), "integer failed");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( NativeCurrency_test )
|
||||
{
|
||||
STAmount zero, one (1), hundred (100);
|
||||
|
||||
if (serdes (zero) != zero) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (one) != one) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (hundred) != hundred) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!zero.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!hundred.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!zero.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (one.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (hundred.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount ().getText () != "0") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (31).getText () != "31") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (310).getText () != "310") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
BOOST_TEST_MESSAGE ("Amount NC Complete");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( CustomCurrency_test )
|
||||
{
|
||||
STAmount zero (CURRENCY_ONE, ACCOUNT_ONE), one (CURRENCY_ONE, ACCOUNT_ONE, 1), hundred (CURRENCY_ONE, ACCOUNT_ONE, 100);
|
||||
|
||||
serdes (one).getRaw ();
|
||||
|
||||
if (serdes (zero) != zero) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (one) != one) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (serdes (hundred) != hundred) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (zero.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (hundred.isNative ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (!zero.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (one.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (hundred.isZero ()) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred < hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred > one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred > hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred <= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred <= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred >= hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred == one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred == hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((zero != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (zero != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((one != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (one != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != zero)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (! (hundred != one)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if ((hundred != hundred)) BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE).getText () != "0") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31).getText () != "31") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, 1).getText () != "310") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -1).getText () != "3.1") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 31, -2).getText () != "0.31") BOOST_FAIL ("STAmount fail");
|
||||
|
||||
if (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 1");
|
||||
|
||||
if (STAmount::multiply (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 2");
|
||||
|
||||
if (STAmount::multiply (STAmount (20), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 3");
|
||||
|
||||
if (STAmount::multiply (STAmount (20), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "60")
|
||||
BOOST_FAIL ("STAmount multiply fail 4");
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
||||
{
|
||||
WriteLog (lsFATAL, STAmount) << "60/3 = " <<
|
||||
STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60),
|
||||
STAmount (3), CURRENCY_ONE, ACCOUNT_ONE).getText ();
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
}
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (3), uint160 (), ACCOUNT_XRP).getText () != "20")
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), CURRENCY_ONE, ACCOUNT_ONE).getText () != "20")
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
|
||||
if (STAmount::divide (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 3), uint160 (), ACCOUNT_XRP).getText () != "20")
|
||||
BOOST_FAIL ("STAmount divide fail");
|
||||
|
||||
STAmount a1 (CURRENCY_ONE, ACCOUNT_ONE, 60), a2 (CURRENCY_ONE, ACCOUNT_ONE, 10, -1);
|
||||
|
||||
if (STAmount::divide (a2, a1, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a1, a2)))
|
||||
BOOST_FAIL ("STAmount setRate(getRate) fail");
|
||||
|
||||
if (STAmount::divide (a1, a2, CURRENCY_ONE, ACCOUNT_ONE) != STAmount::setRate (STAmount::getRate (a2, a1)))
|
||||
BOOST_FAIL ("STAmount setRate(getRate) fail");
|
||||
|
||||
BOOST_TEST_MESSAGE ("Amount CC Complete");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
static bool roundTest (int n, int d, int m)
|
||||
{
|
||||
// check STAmount rounding
|
||||
STAmount num (CURRENCY_ONE, ACCOUNT_ONE, n);
|
||||
STAmount den (CURRENCY_ONE, ACCOUNT_ONE, d);
|
||||
STAmount mul (CURRENCY_ONE, ACCOUNT_ONE, m);
|
||||
STAmount quot = STAmount::divide (n, d, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount res = STAmount::multiply (quot, mul, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (res.isNative ())
|
||||
BOOST_FAIL ("Product is native");
|
||||
|
||||
res.roundSelf ();
|
||||
|
||||
STAmount cmp (CURRENCY_ONE, ACCOUNT_ONE, (n * m) / d);
|
||||
|
||||
if (cmp.isNative ())
|
||||
BOOST_FAIL ("Comparison amount is native");
|
||||
|
||||
if (res == cmp)
|
||||
return true;
|
||||
|
||||
cmp.throwComparable (res);
|
||||
WriteLog (lsWARNING, STAmount) << "(" << num.getText () << "/" << den.getText () << ") X " << mul.getText () << " = "
|
||||
<< res.getText () << " not " << cmp.getText ();
|
||||
BOOST_FAIL ("Round fail");
|
||||
return false;
|
||||
}
|
||||
|
||||
static void mulTest (int a, int b)
|
||||
{
|
||||
STAmount aa (CURRENCY_ONE, ACCOUNT_ONE, a);
|
||||
STAmount bb (CURRENCY_ONE, ACCOUNT_ONE, b);
|
||||
STAmount prod1 (STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE));
|
||||
|
||||
if (prod1.isNative ())
|
||||
BOOST_FAIL ("product is native");
|
||||
|
||||
STAmount prod2 (CURRENCY_ONE, ACCOUNT_ONE, static_cast<uint64> (a) * static_cast<uint64> (b));
|
||||
|
||||
if (prod1 != prod2)
|
||||
{
|
||||
WriteLog (lsWARNING, STAmount) << "nn(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText ()
|
||||
<< " not " << prod2.getFullText ();
|
||||
BOOST_WARN ("Multiplication result is not exact");
|
||||
}
|
||||
|
||||
aa = a;
|
||||
prod1 = STAmount::multiply (aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (prod1 != prod2)
|
||||
{
|
||||
WriteLog (lsWARNING, STAmount) << "n(" << aa.getFullText () << " * " << bb.getFullText () << ") = " << prod1.getFullText ()
|
||||
<< " not " << prod2.getFullText ();
|
||||
BOOST_WARN ("Multiplication result is not exact");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( CurrencyMulDivTests )
|
||||
{
|
||||
CBigNum b;
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
uint64 r = rand ();
|
||||
r <<= 32;
|
||||
r |= rand ();
|
||||
b.setuint64 (r);
|
||||
|
||||
if (b.getuint64 () != r)
|
||||
{
|
||||
WriteLog (lsFATAL, STAmount) << r << " != " << b.getuint64 () << " " << b.ToString (16);
|
||||
BOOST_FAIL ("setull64/getull64 failure");
|
||||
}
|
||||
}
|
||||
|
||||
// Test currency multiplication and division operations such as
|
||||
// convertToDisplayAmount, convertToInternalAmount, getRate, getClaimed, and getNeeded
|
||||
|
||||
if (STAmount::getRate (STAmount (1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 1");
|
||||
|
||||
if (STAmount::getRate (STAmount (10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 2");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 3");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 4");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1), STAmount (10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 5");
|
||||
|
||||
if (STAmount::getRate (STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10), STAmount (1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 6");
|
||||
|
||||
if (STAmount::getRate (STAmount (1), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 10)) != (((100ull - 14) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 7");
|
||||
|
||||
if (STAmount::getRate (STAmount (10), STAmount (CURRENCY_ONE, ACCOUNT_ONE, 1)) != (((100ull - 16) << (64 - 8)) | 1000000000000000ull))
|
||||
BOOST_FAIL ("STAmount getRate fail 8");
|
||||
|
||||
roundTest (1, 3, 3);
|
||||
roundTest (2, 3, 9);
|
||||
roundTest (1, 7, 21);
|
||||
roundTest (1, 2, 4);
|
||||
roundTest (3, 9, 18);
|
||||
roundTest (7, 11, 44);
|
||||
|
||||
for (int i = 0; i <= 100000; ++i)
|
||||
mulTest (rand () % 10000000, rand () % 10000000);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( UnderFlowTests )
|
||||
{
|
||||
STAmount bigNative (STAmount::cMaxNative / 2);
|
||||
STAmount bigValue (CURRENCY_ONE, ACCOUNT_ONE,
|
||||
(STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMaxOffset - 1);
|
||||
STAmount smallValue (CURRENCY_ONE, ACCOUNT_ONE,
|
||||
(STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMinOffset + 1);
|
||||
STAmount zero (CURRENCY_ONE, ACCOUNT_ONE, 0);
|
||||
|
||||
STAmount smallXsmall = STAmount::multiply (smallValue, smallValue, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (!smallXsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: smallXsmall != 0");
|
||||
|
||||
STAmount bigDsmall = STAmount::divide (smallValue, bigValue, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: small/big != 0: " << bigDsmall);
|
||||
|
||||
bigDsmall = STAmount::divide (smallValue, bigNative, CURRENCY_ONE, uint160 ());
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: small/bigNative != 0: " << bigDsmall);
|
||||
|
||||
bigDsmall = STAmount::divide (smallValue, bigValue, uint160 (), uint160 ());
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: (small/big)->N != 0: " << bigDsmall);
|
||||
|
||||
bigDsmall = STAmount::divide (smallValue, bigNative, uint160 (), uint160 ());
|
||||
|
||||
if (!bigDsmall.isZero ())
|
||||
BOOST_FAIL ("STAmount: (small/bigNative)->N != 0: " << bigDsmall);
|
||||
|
||||
// very bad offer
|
||||
uint64 r = STAmount::getRate (smallValue, bigValue);
|
||||
|
||||
if (r != 0)
|
||||
BOOST_FAIL ("STAmount: getRate(smallOut/bigIn) != 0" << r);
|
||||
|
||||
// very good offer
|
||||
r = STAmount::getRate (bigValue, smallValue);
|
||||
|
||||
if (r != 0)
|
||||
BOOST_FAIL ("STAmount:: getRate(smallIn/bigOUt) != 0" << r);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (amountRound)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( amountRound_test )
|
||||
{
|
||||
uint64 value = 25000000000000000ull;
|
||||
int offset = -14;
|
||||
STAmount::canonicalizeRound (false, value, offset, true);
|
||||
|
||||
STAmount one (CURRENCY_ONE, ACCOUNT_ONE, 1);
|
||||
STAmount two (CURRENCY_ONE, ACCOUNT_ONE, 2);
|
||||
STAmount three (CURRENCY_ONE, ACCOUNT_ONE, 3);
|
||||
|
||||
STAmount oneThird1 = STAmount::divRound (one, three, CURRENCY_ONE, ACCOUNT_ONE, false);
|
||||
STAmount oneThird2 = STAmount::divide (one, three, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount oneThird3 = STAmount::divRound (one, three, CURRENCY_ONE, ACCOUNT_ONE, true);
|
||||
WriteLog (lsINFO, STAmount) << oneThird1;
|
||||
WriteLog (lsINFO, STAmount) << oneThird2;
|
||||
WriteLog (lsINFO, STAmount) << oneThird3;
|
||||
|
||||
STAmount twoThird1 = STAmount::divRound (two, three, CURRENCY_ONE, ACCOUNT_ONE, false);
|
||||
STAmount twoThird2 = STAmount::divide (two, three, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount twoThird3 = STAmount::divRound (two, three, CURRENCY_ONE, ACCOUNT_ONE, true);
|
||||
WriteLog (lsINFO, STAmount) << twoThird1;
|
||||
WriteLog (lsINFO, STAmount) << twoThird2;
|
||||
WriteLog (lsINFO, STAmount) << twoThird3;
|
||||
|
||||
STAmount oneA = STAmount::mulRound (oneThird1, three, CURRENCY_ONE, ACCOUNT_ONE, false);
|
||||
STAmount oneB = STAmount::multiply (oneThird2, three, CURRENCY_ONE, ACCOUNT_ONE);
|
||||
STAmount oneC = STAmount::mulRound (oneThird3, three, CURRENCY_ONE, ACCOUNT_ONE, true);
|
||||
WriteLog (lsINFO, STAmount) << oneA;
|
||||
WriteLog (lsINFO, STAmount) << oneB;
|
||||
WriteLog (lsINFO, STAmount) << oneC;
|
||||
|
||||
STAmount fourThirdsA = STAmount::addRound (twoThird2, twoThird2, false);
|
||||
STAmount fourThirdsB = twoThird2 + twoThird2;
|
||||
STAmount fourThirdsC = STAmount::addRound (twoThird2, twoThird2, true);
|
||||
WriteLog (lsINFO, STAmount) << fourThirdsA;
|
||||
WriteLog (lsINFO, STAmount) << fourThirdsB;
|
||||
WriteLog (lsINFO, STAmount) << fourThirdsC;
|
||||
|
||||
STAmount dripTest1 = STAmount::mulRound (twoThird2, two, uint160 (), uint160 (), false);
|
||||
STAmount dripTest2 = STAmount::multiply (twoThird2, two, uint160 (), uint160 ());
|
||||
STAmount dripTest3 = STAmount::mulRound (twoThird2, two, uint160 (), uint160 (), true);
|
||||
WriteLog (lsINFO, STAmount) << dripTest1;
|
||||
WriteLog (lsINFO, STAmount) << dripTest2;
|
||||
WriteLog (lsINFO, STAmount) << dripTest3;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -1547,84 +1547,3 @@ UPTR_T<STObject> STObject::parseJson (const Json::Value& object, SField::ref inN
|
||||
|
||||
return UPTR_T<STObject> (new STObject (*name, data));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (SerializedObject)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( FieldManipulation_test )
|
||||
{
|
||||
if (sfGeneric.isUseful ())
|
||||
BOOST_FAIL ("sfGeneric must not be useful");
|
||||
|
||||
SField sfTestVL (STI_VL, 255, "TestVL");
|
||||
SField sfTestH256 (STI_HASH256, 255, "TestH256");
|
||||
SField sfTestU32 (STI_UINT32, 255, "TestU32");
|
||||
SField sfTestObject (STI_OBJECT, 255, "TestObject");
|
||||
|
||||
SOTemplate elements;
|
||||
elements.push_back (SOElement (sfFlags, SOE_REQUIRED));
|
||||
elements.push_back (SOElement (sfTestVL, SOE_REQUIRED));
|
||||
elements.push_back (SOElement (sfTestH256, SOE_OPTIONAL));
|
||||
elements.push_back (SOElement (sfTestU32, SOE_REQUIRED));
|
||||
|
||||
STObject object1 (elements, sfTestObject);
|
||||
STObject object2 (object1);
|
||||
|
||||
if (object1.getSerializer () != object2.getSerializer ()) BOOST_FAIL ("STObject error 1");
|
||||
|
||||
if (object1.isFieldPresent (sfTestH256) || !object1.isFieldPresent (sfTestVL))
|
||||
BOOST_FAIL ("STObject error");
|
||||
|
||||
object1.makeFieldPresent (sfTestH256);
|
||||
|
||||
if (!object1.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject Error 2");
|
||||
|
||||
if (object1.getFieldH256 (sfTestH256) != uint256 ()) BOOST_FAIL ("STObject error 3");
|
||||
|
||||
if (object1.getSerializer () == object2.getSerializer ())
|
||||
{
|
||||
WriteLog (lsINFO, STObject) << "O1: " << object1.getJson (0);
|
||||
WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0);
|
||||
BOOST_FAIL ("STObject error 4");
|
||||
}
|
||||
|
||||
object1.makeFieldAbsent (sfTestH256);
|
||||
|
||||
if (object1.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject error 5");
|
||||
|
||||
if (object1.getFlags () != 0) BOOST_FAIL ("STObject error 6");
|
||||
|
||||
if (object1.getSerializer () != object2.getSerializer ()) BOOST_FAIL ("STObject error 7");
|
||||
|
||||
STObject copy (object1);
|
||||
|
||||
if (object1.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject error 8");
|
||||
|
||||
if (copy.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject error 9");
|
||||
|
||||
if (object1.getSerializer () != copy.getSerializer ()) BOOST_FAIL ("STObject error 10");
|
||||
|
||||
copy.setFieldU32 (sfTestU32, 1);
|
||||
|
||||
if (object1.getSerializer () == copy.getSerializer ()) BOOST_FAIL ("STObject error 11");
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
Blob j (i, 2);
|
||||
|
||||
object1.setFieldVL (sfTestVL, j);
|
||||
|
||||
Serializer s;
|
||||
object1.add (s);
|
||||
SerializerIterator it (s);
|
||||
|
||||
STObject object3 (elements, it, sfTestObject);
|
||||
|
||||
if (object1.getFieldVL (sfTestVL) != j) BOOST_FAIL ("STObject error");
|
||||
|
||||
if (object3.getFieldVL (sfTestVL) != j) BOOST_FAIL ("STObject error");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (SerializedObject)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( FieldManipulation_test )
|
||||
{
|
||||
if (sfGeneric.isUseful ())
|
||||
BOOST_FAIL ("sfGeneric must not be useful");
|
||||
|
||||
SField sfTestVL (STI_VL, 255, "TestVL");
|
||||
SField sfTestH256 (STI_HASH256, 255, "TestH256");
|
||||
SField sfTestU32 (STI_UINT32, 255, "TestU32");
|
||||
SField sfTestObject (STI_OBJECT, 255, "TestObject");
|
||||
|
||||
SOTemplate elements;
|
||||
elements.push_back (SOElement (sfFlags, SOE_REQUIRED));
|
||||
elements.push_back (SOElement (sfTestVL, SOE_REQUIRED));
|
||||
elements.push_back (SOElement (sfTestH256, SOE_OPTIONAL));
|
||||
elements.push_back (SOElement (sfTestU32, SOE_REQUIRED));
|
||||
|
||||
STObject object1 (elements, sfTestObject);
|
||||
STObject object2 (object1);
|
||||
|
||||
if (object1.getSerializer () != object2.getSerializer ()) BOOST_FAIL ("STObject error 1");
|
||||
|
||||
if (object1.isFieldPresent (sfTestH256) || !object1.isFieldPresent (sfTestVL))
|
||||
BOOST_FAIL ("STObject error");
|
||||
|
||||
object1.makeFieldPresent (sfTestH256);
|
||||
|
||||
if (!object1.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject Error 2");
|
||||
|
||||
if (object1.getFieldH256 (sfTestH256) != uint256 ()) BOOST_FAIL ("STObject error 3");
|
||||
|
||||
if (object1.getSerializer () == object2.getSerializer ())
|
||||
{
|
||||
WriteLog (lsINFO, STObject) << "O1: " << object1.getJson (0);
|
||||
WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0);
|
||||
BOOST_FAIL ("STObject error 4");
|
||||
}
|
||||
|
||||
object1.makeFieldAbsent (sfTestH256);
|
||||
|
||||
if (object1.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject error 5");
|
||||
|
||||
if (object1.getFlags () != 0) BOOST_FAIL ("STObject error 6");
|
||||
|
||||
if (object1.getSerializer () != object2.getSerializer ()) BOOST_FAIL ("STObject error 7");
|
||||
|
||||
STObject copy (object1);
|
||||
|
||||
if (object1.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject error 8");
|
||||
|
||||
if (copy.isFieldPresent (sfTestH256)) BOOST_FAIL ("STObject error 9");
|
||||
|
||||
if (object1.getSerializer () != copy.getSerializer ()) BOOST_FAIL ("STObject error 10");
|
||||
|
||||
copy.setFieldU32 (sfTestU32, 1);
|
||||
|
||||
if (object1.getSerializer () == copy.getSerializer ()) BOOST_FAIL ("STObject error 11");
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
Blob j (i, 2);
|
||||
|
||||
object1.setFieldVL (sfTestVL, j);
|
||||
|
||||
Serializer s;
|
||||
object1.add (s);
|
||||
SerializerIterator it (s);
|
||||
|
||||
STObject object3 (elements, it, sfTestObject);
|
||||
|
||||
if (object1.getFieldVL (sfTestVL) != j) BOOST_FAIL ("STObject error");
|
||||
|
||||
if (object3.getFieldVL (sfTestVL) != j) BOOST_FAIL ("STObject error");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
@@ -727,6 +727,8 @@ public:
|
||||
|
||||
STAmount getRound () const;
|
||||
void roundSelf ();
|
||||
|
||||
static void canonicalizeRound (bool isNative, uint64& value, int& offset, bool roundUp);
|
||||
|
||||
private:
|
||||
template <class Iterator>
|
||||
|
||||
@@ -704,24 +704,3 @@ Blob SerializerIterator::getRaw (int iLength)
|
||||
|
||||
return mSerializer.getRaw (iPos, iLength);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (Serializer_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( Serializer_PrefixHash_test )
|
||||
{
|
||||
Serializer s1;
|
||||
s1.add32 (3);
|
||||
s1.add256 (uint256 ());
|
||||
|
||||
Serializer s2;
|
||||
s2.add32 (0x12345600);
|
||||
s2.addRaw (s1.peekData ());
|
||||
|
||||
if (s1.getPrefixHash (0x12345600) != s2.getSHA512Half ())
|
||||
BOOST_FAIL ("Prefix hash does not work");
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
23
modules/ripple_data/protocol/ripple_SerializerUnitTests.cpp
Normal file
23
modules/ripple_data/protocol/ripple_SerializerUnitTests.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (Serializer_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( Serializer_PrefixHash_test )
|
||||
{
|
||||
Serializer s1;
|
||||
s1.add32 (3);
|
||||
s1.add256 (uint256 ());
|
||||
|
||||
Serializer s2;
|
||||
s2.add32 (0x12345600);
|
||||
s2.addRaw (s1.peekData ());
|
||||
|
||||
if (s1.getPrefixHash (0x12345600) != s2.getSHA512Half ())
|
||||
BOOST_FAIL ("Prefix hash does not work");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
@@ -97,6 +97,13 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// These must be outside the namespace because of boost
|
||||
#include "crypto/ripple_CKeyDeterministicUnitTests.cpp"
|
||||
#include "protocol/ripple_RippleAddressUnitTests.cpp"
|
||||
#include "protocol/ripple_SerializedObjectUnitTests.cpp"
|
||||
#include "protocol/ripple_SerializerUnitTests.cpp"
|
||||
#include "protocol/ripple_STAmountUnitTests.cpp"
|
||||
|
||||
// VFALCO TODO Fix this for SConstruct
|
||||
#if BEAST_MSVC
|
||||
#include "ripple.pb.cc"
|
||||
|
||||
@@ -1919,16 +1919,3 @@ std::vector<uint256> Ledger::getNeededAccountStateHashes (int max, SHAMapSyncFil
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (quality)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( getquality )
|
||||
{
|
||||
uint256 uBig ("D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000");
|
||||
|
||||
if (6125895493223874560 != Ledger::getQuality (uBig))
|
||||
BOOST_FAIL ("Ledger::getQuality fails.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
// vim:ts=4
|
||||
|
||||
17
src/cpp/ripple/LedgerUnitTests.cpp
Normal file
17
src/cpp/ripple/LedgerUnitTests.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (quality)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( getquality )
|
||||
{
|
||||
uint256 uBig ("D2DC44E5DC189318DB36EF87D2104CDF0A0FE3A4B698BEEE55038D7EA4C68000");
|
||||
|
||||
if (6125895493223874560 != Ledger::getQuality (uBig))
|
||||
BOOST_FAIL ("Ledger::getQuality fails.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -4,46 +4,6 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
class ProofOfWorkFactory : public IProofOfWorkFactory
|
||||
{
|
||||
public:
|
||||
ProofOfWorkFactory ();
|
||||
|
||||
ProofOfWork getProof ();
|
||||
POWResult checkProof (const std::string& token, uint256 const& solution);
|
||||
uint64 getDifficulty ()
|
||||
{
|
||||
return ProofOfWork::getDifficulty (mTarget, mIterations);
|
||||
}
|
||||
void setDifficulty (int i);
|
||||
|
||||
void loadHigh ();
|
||||
void loadLow ();
|
||||
void sweep (void);
|
||||
|
||||
uint256 const& getSecret () const
|
||||
{
|
||||
return mSecret;
|
||||
}
|
||||
void setSecret (uint256 const& secret)
|
||||
{
|
||||
mSecret = secret;
|
||||
}
|
||||
|
||||
static int getPowEntry (uint256 const& target, int iterations);
|
||||
|
||||
private:
|
||||
uint256 mSecret;
|
||||
int mIterations;
|
||||
uint256 mTarget;
|
||||
time_t mLastDifficultyChange;
|
||||
int mValidTime;
|
||||
int mPowEntry;
|
||||
|
||||
powMap_t mSolvedChallenges;
|
||||
boost::mutex mLock;
|
||||
};
|
||||
|
||||
ProofOfWorkFactory::ProofOfWorkFactory () : mValidTime (180)
|
||||
{
|
||||
setDifficulty (1);
|
||||
@@ -271,64 +231,3 @@ IProofOfWorkFactory* IProofOfWorkFactory::New ()
|
||||
return new ProofOfWorkFactory;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (ProofOfWork_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( ProofOfWork_test )
|
||||
{
|
||||
ProofOfWorkFactory gen;
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (16777216);
|
||||
|
||||
if (solution.isZero ())
|
||||
BOOST_FAIL ("Unable to solve proof of work");
|
||||
|
||||
if (!pow.checkSolution (solution))
|
||||
BOOST_FAIL ("Solution did not check");
|
||||
|
||||
WriteLog (lsDEBUG, ProofOfWork) << "A bad nonce error is expected";
|
||||
POWResult r = gen.checkProof (pow.getToken (), uint256 ());
|
||||
|
||||
if (r != powBADNONCE)
|
||||
{
|
||||
Log (lsFATAL) << "POWResult = " << static_cast<int> (r);
|
||||
BOOST_FAIL ("Empty solution didn't show bad nonce");
|
||||
}
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
BOOST_FAIL ("Solution did not check with issuer");
|
||||
|
||||
WriteLog (lsDEBUG, ProofOfWork) << "A reused nonce error is expected";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powREUSED)
|
||||
BOOST_FAIL ("Reuse solution not detected");
|
||||
|
||||
#ifdef SOLVE_POWS
|
||||
|
||||
for (int i = 0; i < 12; ++i)
|
||||
{
|
||||
gen.setDifficulty (i);
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (131072);
|
||||
|
||||
if (solution.isZero ())
|
||||
WriteLog (lsINFO, ProofOfWork) << "Giving up";
|
||||
else
|
||||
{
|
||||
WriteLog (lsINFO, ProofOfWork) << "Solution found";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
{
|
||||
WriteLog (lsFATAL, ProofOfWork) << "Solution fails";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
52
src/cpp/ripple/ripple_ProofOfWorkFactory.h
Normal file
52
src/cpp/ripple/ripple_ProofOfWorkFactory.h
Normal file
@@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef RIPPLE_PROOFOFWORKFACTORY_RIPPLEHEADER
|
||||
#define RIPPLE_PROOFOFWORKFACTORY_RIPPLEHEADER
|
||||
|
||||
// PRIVATE HEADER
|
||||
|
||||
class ProofOfWorkFactory : public IProofOfWorkFactory
|
||||
{
|
||||
public:
|
||||
ProofOfWorkFactory ();
|
||||
|
||||
ProofOfWork getProof ();
|
||||
POWResult checkProof (const std::string& token, uint256 const& solution);
|
||||
uint64 getDifficulty ()
|
||||
{
|
||||
return ProofOfWork::getDifficulty (mTarget, mIterations);
|
||||
}
|
||||
void setDifficulty (int i);
|
||||
|
||||
void loadHigh ();
|
||||
void loadLow ();
|
||||
void sweep (void);
|
||||
|
||||
uint256 const& getSecret () const
|
||||
{
|
||||
return mSecret;
|
||||
}
|
||||
void setSecret (uint256 const& secret)
|
||||
{
|
||||
mSecret = secret;
|
||||
}
|
||||
|
||||
static int getPowEntry (uint256 const& target, int iterations);
|
||||
|
||||
private:
|
||||
uint256 mSecret;
|
||||
int mIterations;
|
||||
uint256 mTarget;
|
||||
time_t mLastDifficultyChange;
|
||||
int mValidTime;
|
||||
int mPowEntry;
|
||||
|
||||
powMap_t mSolvedChallenges;
|
||||
boost::mutex mLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
65
src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp
Normal file
65
src/cpp/ripple/ripple_ProofOfWorkFactoryUnitTests.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (ProofOfWork_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( ProofOfWork_test )
|
||||
{
|
||||
ProofOfWorkFactory gen;
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (16777216);
|
||||
|
||||
if (solution.isZero ())
|
||||
BOOST_FAIL ("Unable to solve proof of work");
|
||||
|
||||
if (!pow.checkSolution (solution))
|
||||
BOOST_FAIL ("Solution did not check");
|
||||
|
||||
WriteLog (lsDEBUG, ProofOfWork) << "A bad nonce error is expected";
|
||||
POWResult r = gen.checkProof (pow.getToken (), uint256 ());
|
||||
|
||||
if (r != powBADNONCE)
|
||||
{
|
||||
Log (lsFATAL) << "POWResult = " << static_cast<int> (r);
|
||||
BOOST_FAIL ("Empty solution didn't show bad nonce");
|
||||
}
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
BOOST_FAIL ("Solution did not check with issuer");
|
||||
|
||||
WriteLog (lsDEBUG, ProofOfWork) << "A reused nonce error is expected";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powREUSED)
|
||||
BOOST_FAIL ("Reuse solution not detected");
|
||||
|
||||
#ifdef SOLVE_POWS
|
||||
|
||||
for (int i = 0; i < 12; ++i)
|
||||
{
|
||||
gen.setDifficulty (i);
|
||||
ProofOfWork pow = gen.getProof ();
|
||||
WriteLog (lsINFO, ProofOfWork) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty ();
|
||||
uint256 solution = pow.solve (131072);
|
||||
|
||||
if (solution.isZero ())
|
||||
WriteLog (lsINFO, ProofOfWork) << "Giving up";
|
||||
else
|
||||
{
|
||||
WriteLog (lsINFO, ProofOfWork) << "Solution found";
|
||||
|
||||
if (gen.checkProof (pow.getToken (), solution) != powOK)
|
||||
{
|
||||
WriteLog (lsFATAL, ProofOfWork) << "Solution fails";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ()
|
||||
@@ -1046,86 +1046,3 @@ void SHAMap::dump (bool hash)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Blob IntToVUC (int v)
|
||||
{
|
||||
Blob vuc;
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
vuc.push_back (static_cast<unsigned char> (v));
|
||||
|
||||
return vuc;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (SHAMap_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( SHAMap_test )
|
||||
{
|
||||
// h3 and h4 differ only in the leaf, same terminal node (level 19)
|
||||
WriteLog (lsTRACE, SHAMap) << "SHAMap test";
|
||||
uint256 h1, h2, h3, h4, h5;
|
||||
h1.SetHex ("092891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
h2.SetHex ("436ccbac3347baa1f1e53baeef1f43334da88f1f6d70d963b833afd6dfa289fe");
|
||||
h3.SetHex ("b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
|
||||
SHAMap sMap (smtFREE);
|
||||
SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
|
||||
|
||||
if (!sMap.addItem (i2, true, false)) BOOST_FAIL ("no add");
|
||||
|
||||
if (!sMap.addItem (i1, true, false)) BOOST_FAIL ("no add");
|
||||
|
||||
SHAMapItem::pointer i;
|
||||
|
||||
i = sMap.peekFirstItem ();
|
||||
|
||||
if (!i || (*i != i1)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (!i || (*i != i2)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (i) BOOST_FAIL ("bad traverse");
|
||||
|
||||
sMap.addItem (i4, true, false);
|
||||
sMap.delItem (i2.getTag ());
|
||||
sMap.addItem (i3, true, false);
|
||||
|
||||
i = sMap.peekFirstItem ();
|
||||
|
||||
if (!i || (*i != i1)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (!i || (*i != i3)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (!i || (*i != i4)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (i) BOOST_FAIL ("bad traverse");
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "SHAMap snap test";
|
||||
uint256 mapHash = sMap.getHash ();
|
||||
SHAMap::pointer map2 = sMap.snapShot (false);
|
||||
|
||||
if (sMap.getHash () != mapHash) BOOST_FAIL ("bad snapshot");
|
||||
|
||||
if (map2->getHash () != mapHash) BOOST_FAIL ("bad snapshot");
|
||||
|
||||
if (!sMap.delItem (sMap.peekFirstItem ()->getTag ())) BOOST_FAIL ("bad mod");
|
||||
|
||||
if (sMap.getHash () == mapHash) BOOST_FAIL ("bad snapshot");
|
||||
|
||||
if (map2->getHash () != mapHash) BOOST_FAIL ("bad snapshot");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -572,57 +572,6 @@ void SHAMap::getFetchPack (SHAMap* have, bool includeLeaves, int max,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#define SMS_DEBUG
|
||||
#endif
|
||||
|
||||
static SHAMapItem::pointer makeRandomAS ()
|
||||
{
|
||||
Serializer s;
|
||||
|
||||
for (int d = 0; d < 3; ++d) s.add32 (rand ());
|
||||
|
||||
return boost::make_shared<SHAMapItem> (s.getRIPEMD160 ().to256 (), s.peekData ());
|
||||
}
|
||||
|
||||
static bool confuseMap (SHAMap& map, int count)
|
||||
{
|
||||
// add a bunch of random states to a map, then remove them
|
||||
// map should be the same
|
||||
uint256 beforeHash = map.getHash ();
|
||||
|
||||
std::list<uint256> items;
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
SHAMapItem::pointer item = makeRandomAS ();
|
||||
items.push_back (item->getTag ());
|
||||
|
||||
if (!map.addItem (*item, false, false))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Unable to add item to map";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<uint256>::iterator it = items.begin (); it != items.end (); ++it)
|
||||
{
|
||||
if (!map.delItem (*it))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Unable to remove item from map";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (beforeHash != map.getHash ())
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Hashes do not match";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::list<Blob > SHAMap::getTrustedPath (uint256 const& index)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
@@ -644,148 +593,3 @@ std::list<Blob > SHAMap::getTrustedPath (uint256 const& index)
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE ( SHAMapSync )
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( SHAMapSync_test )
|
||||
{
|
||||
WriteLog (lsTRACE, SHAMap) << "begin sync test";
|
||||
unsigned int seed;
|
||||
RAND_pseudo_bytes (reinterpret_cast<unsigned char*> (&seed), sizeof (seed));
|
||||
srand (seed);
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "Constructing maps";
|
||||
SHAMap source (smtFREE), destination (smtFREE);
|
||||
|
||||
// add random data to the source map
|
||||
WriteLog (lsTRACE, SHAMap) << "Adding random data";
|
||||
int items = 10000;
|
||||
|
||||
for (int i = 0; i < items; ++i)
|
||||
source.addItem (*makeRandomAS (), false, false);
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "Adding items, then removing them";
|
||||
|
||||
if (!confuseMap (source, 500)) BOOST_FAIL ("ConfuseMap");
|
||||
|
||||
source.setImmutable ();
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "SOURCE COMPLETE, SYNCHING";
|
||||
|
||||
std::vector<SHAMapNode> nodeIDs, gotNodeIDs;
|
||||
std::list< Blob > gotNodes;
|
||||
std::vector<uint256> hashes;
|
||||
|
||||
std::vector<SHAMapNode>::iterator nodeIDIterator;
|
||||
std::list< Blob >::iterator rawNodeIterator;
|
||||
|
||||
int passes = 0;
|
||||
int nodes = 0;
|
||||
|
||||
destination.setSynching ();
|
||||
|
||||
if (!source.getNodeFat (SHAMapNode (), nodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "GetNodeFat(root) fails";
|
||||
BOOST_FAIL ("GetNodeFat");
|
||||
}
|
||||
|
||||
if (gotNodes.size () < 1)
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Didn't get root node " << gotNodes.size ();
|
||||
BOOST_FAIL ("NodeSize");
|
||||
}
|
||||
|
||||
if (!destination.addRootNode (*gotNodes.begin (), snfWIRE, NULL))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "AddRootNode fails";
|
||||
BOOST_FAIL ("AddRootNode");
|
||||
}
|
||||
|
||||
nodeIDs.clear ();
|
||||
gotNodes.clear ();
|
||||
|
||||
WriteLog (lsINFO, SHAMap) << "ROOT COMPLETE, INNER SYNCHING";
|
||||
#ifdef SMS_DEBUG
|
||||
int bytes = 0;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
++passes;
|
||||
hashes.clear ();
|
||||
|
||||
// get the list of nodes we know we need
|
||||
destination.getMissingNodes (nodeIDs, hashes, 2048, NULL);
|
||||
|
||||
if (nodeIDs.empty ()) break;
|
||||
|
||||
WriteLog (lsINFO, SHAMap) << nodeIDs.size () << " needed nodes";
|
||||
|
||||
// get as many nodes as possible based on this information
|
||||
for (nodeIDIterator = nodeIDs.begin (); nodeIDIterator != nodeIDs.end (); ++nodeIDIterator)
|
||||
{
|
||||
if (!source.getNodeFat (*nodeIDIterator, gotNodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "GetNodeFat fails";
|
||||
BOOST_FAIL ("GetNodeFat");
|
||||
}
|
||||
}
|
||||
|
||||
assert (gotNodeIDs.size () == gotNodes.size ());
|
||||
nodeIDs.clear ();
|
||||
hashes.clear ();
|
||||
|
||||
if (gotNodeIDs.empty ())
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "No nodes gotten";
|
||||
BOOST_FAIL ("Got Node ID");
|
||||
}
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << gotNodeIDs.size () << " found nodes";
|
||||
|
||||
for (nodeIDIterator = gotNodeIDs.begin (), rawNodeIterator = gotNodes.begin ();
|
||||
nodeIDIterator != gotNodeIDs.end (); ++nodeIDIterator, ++rawNodeIterator)
|
||||
{
|
||||
++nodes;
|
||||
#ifdef SMS_DEBUG
|
||||
bytes += rawNodeIterator->size ();
|
||||
#endif
|
||||
|
||||
if (!destination.addKnownNode (*nodeIDIterator, *rawNodeIterator, NULL))
|
||||
{
|
||||
WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails";
|
||||
BOOST_FAIL ("AddKnownNode");
|
||||
}
|
||||
}
|
||||
|
||||
gotNodeIDs.clear ();
|
||||
gotNodes.clear ();
|
||||
|
||||
|
||||
}
|
||||
while (1);
|
||||
|
||||
destination.clearSynching ();
|
||||
|
||||
#ifdef SMS_DEBUG
|
||||
WriteLog (lsINFO, SHAMap) << "SYNCHING COMPLETE " << items << " items, " << nodes << " nodes, " <<
|
||||
bytes / 1024 << " KB";
|
||||
#endif
|
||||
|
||||
if (!source.deepCompare (destination))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "DeepCompare fails";
|
||||
BOOST_FAIL ("Deep Compare");
|
||||
}
|
||||
|
||||
#ifdef SMS_DEBUG
|
||||
WriteLog (lsINFO, SHAMap) << "SHAMapSync test passed: " << items << " items, " <<
|
||||
passes << " passes, " << nodes << " nodes";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
199
src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp
Normal file
199
src/cpp/ripple/ripple_SHAMapSyncUnitTests.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifdef DEBUG
|
||||
#define SMS_DEBUG
|
||||
#endif
|
||||
|
||||
static SHAMapItem::pointer makeRandomAS ()
|
||||
{
|
||||
Serializer s;
|
||||
|
||||
for (int d = 0; d < 3; ++d) s.add32 (rand ());
|
||||
|
||||
return boost::make_shared<SHAMapItem> (s.getRIPEMD160 ().to256 (), s.peekData ());
|
||||
}
|
||||
|
||||
static bool confuseMap (SHAMap& map, int count)
|
||||
{
|
||||
// add a bunch of random states to a map, then remove them
|
||||
// map should be the same
|
||||
uint256 beforeHash = map.getHash ();
|
||||
|
||||
std::list<uint256> items;
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
SHAMapItem::pointer item = makeRandomAS ();
|
||||
items.push_back (item->getTag ());
|
||||
|
||||
if (!map.addItem (*item, false, false))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Unable to add item to map";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<uint256>::iterator it = items.begin (); it != items.end (); ++it)
|
||||
{
|
||||
if (!map.delItem (*it))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Unable to remove item from map";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (beforeHash != map.getHash ())
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Hashes do not match";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE ( SHAMapSync )
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( SHAMapSync_test )
|
||||
{
|
||||
WriteLog (lsTRACE, SHAMap) << "begin sync test";
|
||||
unsigned int seed;
|
||||
RAND_pseudo_bytes (reinterpret_cast<unsigned char*> (&seed), sizeof (seed));
|
||||
srand (seed);
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "Constructing maps";
|
||||
SHAMap source (smtFREE), destination (smtFREE);
|
||||
|
||||
// add random data to the source map
|
||||
WriteLog (lsTRACE, SHAMap) << "Adding random data";
|
||||
int items = 10000;
|
||||
|
||||
for (int i = 0; i < items; ++i)
|
||||
source.addItem (*makeRandomAS (), false, false);
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "Adding items, then removing them";
|
||||
|
||||
if (!confuseMap (source, 500)) BOOST_FAIL ("ConfuseMap");
|
||||
|
||||
source.setImmutable ();
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "SOURCE COMPLETE, SYNCHING";
|
||||
|
||||
std::vector<SHAMapNode> nodeIDs, gotNodeIDs;
|
||||
std::list< Blob > gotNodes;
|
||||
std::vector<uint256> hashes;
|
||||
|
||||
std::vector<SHAMapNode>::iterator nodeIDIterator;
|
||||
std::list< Blob >::iterator rawNodeIterator;
|
||||
|
||||
int passes = 0;
|
||||
int nodes = 0;
|
||||
|
||||
destination.setSynching ();
|
||||
|
||||
if (!source.getNodeFat (SHAMapNode (), nodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "GetNodeFat(root) fails";
|
||||
BOOST_FAIL ("GetNodeFat");
|
||||
}
|
||||
|
||||
if (gotNodes.size () < 1)
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "Didn't get root node " << gotNodes.size ();
|
||||
BOOST_FAIL ("NodeSize");
|
||||
}
|
||||
|
||||
if (!destination.addRootNode (*gotNodes.begin (), snfWIRE, NULL))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "AddRootNode fails";
|
||||
BOOST_FAIL ("AddRootNode");
|
||||
}
|
||||
|
||||
nodeIDs.clear ();
|
||||
gotNodes.clear ();
|
||||
|
||||
WriteLog (lsINFO, SHAMap) << "ROOT COMPLETE, INNER SYNCHING";
|
||||
#ifdef SMS_DEBUG
|
||||
int bytes = 0;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
++passes;
|
||||
hashes.clear ();
|
||||
|
||||
// get the list of nodes we know we need
|
||||
destination.getMissingNodes (nodeIDs, hashes, 2048, NULL);
|
||||
|
||||
if (nodeIDs.empty ()) break;
|
||||
|
||||
WriteLog (lsINFO, SHAMap) << nodeIDs.size () << " needed nodes";
|
||||
|
||||
// get as many nodes as possible based on this information
|
||||
for (nodeIDIterator = nodeIDs.begin (); nodeIDIterator != nodeIDs.end (); ++nodeIDIterator)
|
||||
{
|
||||
if (!source.getNodeFat (*nodeIDIterator, gotNodeIDs, gotNodes, (rand () % 2) == 0, (rand () % 2) == 0))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "GetNodeFat fails";
|
||||
BOOST_FAIL ("GetNodeFat");
|
||||
}
|
||||
}
|
||||
|
||||
assert (gotNodeIDs.size () == gotNodes.size ());
|
||||
nodeIDs.clear ();
|
||||
hashes.clear ();
|
||||
|
||||
if (gotNodeIDs.empty ())
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "No nodes gotten";
|
||||
BOOST_FAIL ("Got Node ID");
|
||||
}
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << gotNodeIDs.size () << " found nodes";
|
||||
|
||||
for (nodeIDIterator = gotNodeIDs.begin (), rawNodeIterator = gotNodes.begin ();
|
||||
nodeIDIterator != gotNodeIDs.end (); ++nodeIDIterator, ++rawNodeIterator)
|
||||
{
|
||||
++nodes;
|
||||
#ifdef SMS_DEBUG
|
||||
bytes += rawNodeIterator->size ();
|
||||
#endif
|
||||
|
||||
if (!destination.addKnownNode (*nodeIDIterator, *rawNodeIterator, NULL))
|
||||
{
|
||||
WriteLog (lsTRACE, SHAMap) << "AddKnownNode fails";
|
||||
BOOST_FAIL ("AddKnownNode");
|
||||
}
|
||||
}
|
||||
|
||||
gotNodeIDs.clear ();
|
||||
gotNodes.clear ();
|
||||
|
||||
|
||||
}
|
||||
while (1);
|
||||
|
||||
destination.clearSynching ();
|
||||
|
||||
#ifdef SMS_DEBUG
|
||||
WriteLog (lsINFO, SHAMap) << "SYNCHING COMPLETE " << items << " items, " << nodes << " nodes, " <<
|
||||
bytes / 1024 << " KB";
|
||||
#endif
|
||||
|
||||
if (!source.deepCompare (destination))
|
||||
{
|
||||
WriteLog (lsFATAL, SHAMap) << "DeepCompare fails";
|
||||
BOOST_FAIL ("Deep Compare");
|
||||
}
|
||||
|
||||
#ifdef SMS_DEBUG
|
||||
WriteLog (lsINFO, SHAMap) << "SHAMapSync test passed: " << items << " items, " <<
|
||||
passes << " passes, " << nodes << " nodes";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
88
src/cpp/ripple/ripple_SHAMapUnitTests.cpp
Normal file
88
src/cpp/ripple/ripple_SHAMapUnitTests.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
// VFALCO TODO Rename this to createFilledVector and pass an unsigned char, tidy up
|
||||
//
|
||||
static Blob IntToVUC (int v)
|
||||
{
|
||||
Blob vuc;
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
vuc.push_back (static_cast<unsigned char> (v));
|
||||
|
||||
return vuc;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (SHAMap_suite)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( SHAMap_test )
|
||||
{
|
||||
// h3 and h4 differ only in the leaf, same terminal node (level 19)
|
||||
WriteLog (lsTRACE, SHAMap) << "SHAMap test";
|
||||
uint256 h1, h2, h3, h4, h5;
|
||||
h1.SetHex ("092891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
h2.SetHex ("436ccbac3347baa1f1e53baeef1f43334da88f1f6d70d963b833afd6dfa289fe");
|
||||
h3.SetHex ("b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
|
||||
SHAMap sMap (smtFREE);
|
||||
SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
|
||||
|
||||
if (!sMap.addItem (i2, true, false)) BOOST_FAIL ("no add");
|
||||
|
||||
if (!sMap.addItem (i1, true, false)) BOOST_FAIL ("no add");
|
||||
|
||||
SHAMapItem::pointer i;
|
||||
|
||||
i = sMap.peekFirstItem ();
|
||||
|
||||
if (!i || (*i != i1)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (!i || (*i != i2)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (i) BOOST_FAIL ("bad traverse");
|
||||
|
||||
sMap.addItem (i4, true, false);
|
||||
sMap.delItem (i2.getTag ());
|
||||
sMap.addItem (i3, true, false);
|
||||
|
||||
i = sMap.peekFirstItem ();
|
||||
|
||||
if (!i || (*i != i1)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (!i || (*i != i3)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (!i || (*i != i4)) BOOST_FAIL ("bad traverse");
|
||||
|
||||
i = sMap.peekNextItem (i->getTag ());
|
||||
|
||||
if (i) BOOST_FAIL ("bad traverse");
|
||||
|
||||
WriteLog (lsTRACE, SHAMap) << "SHAMap snap test";
|
||||
uint256 mapHash = sMap.getHash ();
|
||||
SHAMap::pointer map2 = sMap.snapShot (false);
|
||||
|
||||
if (sMap.getHash () != mapHash) BOOST_FAIL ("bad snapshot");
|
||||
|
||||
if (map2->getHash () != mapHash) BOOST_FAIL ("bad snapshot");
|
||||
|
||||
if (!sMap.delItem (sMap.peekFirstItem ()->getTag ())) BOOST_FAIL ("bad mod");
|
||||
|
||||
if (sMap.getHash () == mapHash) BOOST_FAIL ("bad snapshot");
|
||||
|
||||
if (map2->getHash () != mapHash) BOOST_FAIL ("bad snapshot");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
@@ -307,50 +307,3 @@ std::string SerializedTransaction::getMetaSQL (Serializer rawTxn, uint32 inLedge
|
||||
% getTransactionID ().GetHex () % getTransactionType () % getSourceAccount ().humanAccountID ()
|
||||
% getSequence () % inLedger % status % rTxn % escapedMetaData);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE (SerializedTransactionTS)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( STrans_test )
|
||||
{
|
||||
RippleAddress seed;
|
||||
seed.setSeedRandom ();
|
||||
RippleAddress generator = RippleAddress::createGeneratorPublic (seed);
|
||||
RippleAddress publicAcct = RippleAddress::createAccountPublic (generator, 1);
|
||||
RippleAddress privateAcct = RippleAddress::createAccountPrivate (generator, seed, 1);
|
||||
|
||||
SerializedTransaction j (ttACCOUNT_SET);
|
||||
j.setSourceAccount (publicAcct);
|
||||
j.setSigningPubKey (publicAcct);
|
||||
j.setFieldVL (sfMessageKey, publicAcct.getAccountPublic ());
|
||||
j.sign (privateAcct);
|
||||
|
||||
if (!j.checkSign ()) BOOST_FAIL ("Transaction fails signature test");
|
||||
|
||||
Serializer rawTxn;
|
||||
j.add (rawTxn);
|
||||
SerializerIterator sit (rawTxn);
|
||||
SerializedTransaction copy (sit);
|
||||
|
||||
if (copy != j)
|
||||
{
|
||||
Log (lsFATAL) << j.getJson (0);
|
||||
Log (lsFATAL) << copy.getJson (0);
|
||||
BOOST_FAIL ("Transaction fails serialize/deserialize test");
|
||||
}
|
||||
|
||||
UPTR_T<STObject> new_obj = STObject::parseJson (j.getJson (0), sfGeneric);
|
||||
|
||||
if (new_obj.get () == NULL) BOOST_FAIL ("Unable to build object from json");
|
||||
|
||||
if (STObject (j) != *new_obj)
|
||||
{
|
||||
Log (lsINFO) << "ORIG: " << j.getJson (0);
|
||||
Log (lsINFO) << "BUILT " << new_obj->getJson (0);
|
||||
BOOST_FAIL ("Built a different transaction");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
48
src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp
Normal file
48
src/cpp/ripple/ripple_SerializedTransactionUnitTests.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
BOOST_AUTO_TEST_SUITE (SerializedTransactionTS)
|
||||
|
||||
BOOST_AUTO_TEST_CASE ( STrans_test )
|
||||
{
|
||||
RippleAddress seed;
|
||||
seed.setSeedRandom ();
|
||||
RippleAddress generator = RippleAddress::createGeneratorPublic (seed);
|
||||
RippleAddress publicAcct = RippleAddress::createAccountPublic (generator, 1);
|
||||
RippleAddress privateAcct = RippleAddress::createAccountPrivate (generator, seed, 1);
|
||||
|
||||
SerializedTransaction j (ttACCOUNT_SET);
|
||||
j.setSourceAccount (publicAcct);
|
||||
j.setSigningPubKey (publicAcct);
|
||||
j.setFieldVL (sfMessageKey, publicAcct.getAccountPublic ());
|
||||
j.sign (privateAcct);
|
||||
|
||||
if (!j.checkSign ()) BOOST_FAIL ("Transaction fails signature test");
|
||||
|
||||
Serializer rawTxn;
|
||||
j.add (rawTxn);
|
||||
SerializerIterator sit (rawTxn);
|
||||
SerializedTransaction copy (sit);
|
||||
|
||||
if (copy != j)
|
||||
{
|
||||
Log (lsFATAL) << j.getJson (0);
|
||||
Log (lsFATAL) << copy.getJson (0);
|
||||
BOOST_FAIL ("Transaction fails serialize/deserialize test");
|
||||
}
|
||||
|
||||
UPTR_T<STObject> new_obj = STObject::parseJson (j.getJson (0), sfGeneric);
|
||||
|
||||
if (new_obj.get () == NULL) BOOST_FAIL ("Unable to build object from json");
|
||||
|
||||
if (STObject (j) != *new_obj)
|
||||
{
|
||||
Log (lsINFO) << "ORIG: " << j.getJson (0);
|
||||
Log (lsINFO) << "BUILT " << new_obj->getJson (0);
|
||||
BOOST_FAIL ("Built a different transaction");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END ();
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
SETUP_LOG (SqliteDatabase)
|
||||
|
||||
//using namespace std;
|
||||
|
||||
SqliteStatement::SqliteStatement (SqliteDatabase* db, const char* sql, bool aux)
|
||||
{
|
||||
assert (db);
|
||||
|
||||
Reference in New Issue
Block a user