Skip to content

Commit

Permalink
Merge pull request #1744 from MonsieurNicolas/windowsFix
Browse files Browse the repository at this point in the history
Windows fixes post pr1718

Reviewed-by: jonjove
  • Loading branch information
latobarita authored Aug 7, 2018
2 parents 4dab962 + d483a7e commit cb61d6b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 52 deletions.
7 changes: 5 additions & 2 deletions Builds/VisualStudio/stellar-core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
</ControlFlowGuard>
<SmallerTypeCheck>false</SmallerTypeCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -145,6 +146,7 @@ exit /b 0
</ControlFlowGuard>
<SmallerTypeCheck>false</SmallerTypeCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -201,6 +203,7 @@ exit /b 0
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4060;4100;4127;4324;4408;4510;4512;4582;4583;4592</DisableSpecificWarnings>
<ControlFlowGuard>false</ControlFlowGuard>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -602,7 +605,7 @@ exit /b 0
<ClInclude Include="..\..\src\invariant\InvariantManagerImpl.h" />
<ClInclude Include="..\..\src\invariant\InvariantTestUtils.h" />
<ClInclude Include="..\..\src\invariant\LedgerEntryIsValid.h" />
<ClCompile Include="..\..\src\invariant\LiabilitiesMatchOffers.h" />
<ClInclude Include="..\..\src\invariant\LiabilitiesMatchOffers.h" />
<ClInclude Include="..\..\src\ledger\CheckpointRange.h" />
<ClInclude Include="..\..\src\ledger\DataFrame.h" />
<ClInclude Include="..\..\src\ledger\LedgerRange.h" />
Expand Down Expand Up @@ -928,4 +931,4 @@ exit /b 0
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
21 changes: 12 additions & 9 deletions Builds/VisualStudio/stellar-core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,6 @@
<ClCompile Include="..\..\src\invariant\LedgerEntryIsValid.cpp">
<Filter>invariant</Filter>
</ClCompile>
<ClCompile Include="..\..\src\invariant\MinimumAccountBalance.cpp">
<Filter>invariant</Filter>
</ClCompile>
<ClCompile Include="..\..\src\invariant\AccountSubEntriesCountIsValidTests.cpp">
<Filter>invariant\tests</Filter>
</ClCompile>
Expand All @@ -837,9 +834,6 @@
<ClCompile Include="..\..\src\invariant\ConservationOfLumensTests.cpp">
<Filter>invariant\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\invariant\MinimumAccountBalanceTests.cpp">
<Filter>invariant\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\database\DatabaseConnectionStringTest.cpp">
<Filter>database\tests</Filter>
</ClCompile>
Expand Down Expand Up @@ -870,6 +864,15 @@
<ClCompile Include="..\..\src\overlay\LoadManagerTests.cpp">
<Filter>overlay\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\invariant\LiabilitiesMatchOffersTests.cpp">
<Filter>invariant\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\invariant\LiabilitiesMatchOffers.cpp">
<Filter>invariant</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ledger\LiabilitiesTests.cpp">
<Filter>ledger\tests</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\ledger\LedgerManager.h">
Expand Down Expand Up @@ -1478,9 +1481,6 @@
<ClInclude Include="..\..\src\invariant\LedgerEntryIsValid.h">
<Filter>invariant</Filter>
</ClInclude>
<ClInclude Include="..\..\src\invariant\MinimumAccountBalance.h">
<Filter>invariant</Filter>
</ClInclude>
<ClInclude Include="..\..\src\main\Maintainer.h">
<Filter>main</Filter>
</ClInclude>
Expand All @@ -1499,6 +1499,9 @@
<ClInclude Include="..\..\src\overlay\PeerSharedKeyId.h">
<Filter>overlay</Filter>
</ClInclude>
<ClInclude Include="..\..\src\invariant\LiabilitiesMatchOffers.h">
<Filter>invariant</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\AUTHORS" />
Expand Down
9 changes: 8 additions & 1 deletion src/bucket/BucketManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,14 @@ BucketManagerImpl::adoptFileAsBucket(std::string const& filename,
{
std::string err("Failed to rename bucket :");
err += strerror(errno);
throw std::runtime_error(err);
// it seems there is a race condition with external systems
// retry after sleeping for a second works around the problem
std::this_thread::sleep_for(std::chrono::seconds(1));
if (rename(filename.c_str(), canonicalName.c_str()) != 0)
{
// if rename fails again, surface the original error
throw std::runtime_error(err);
}
}

b = std::make_shared<Bucket>(canonicalName, hash);
Expand Down
3 changes: 2 additions & 1 deletion src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,8 @@ LedgerManagerImpl::closeLedger(LedgerCloseData const& ledgerData)
// Note: Index from 1 rather than 0 to match the behavior of
// storeTransaction and storeTransactionFee.
Upgrades::storeUpgradeHistory(*this, lupgrade,
upgradeDelta.getChanges(), i + 1);
upgradeDelta.getChanges(),
static_cast<int>(i + 1));
upgradeDelta.commit();
upgradeScope.commit();
}
Expand Down
35 changes: 19 additions & 16 deletions src/ledger/LiabilitiesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
SECTION("add account selling liabilities")
{
auto addSellingLiabilities =
[&](int64_t initNumSubEntries, int64_t initBalance,
[&](uint32_t initNumSubEntries, int64_t initBalance,
int64_t initSellingLiabilities, int64_t deltaLiabilities) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
ae.balance = initBalance;
Expand Down Expand Up @@ -57,7 +57,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
return res;
};
auto addSellingLiabilitiesUninitialized =
[&](int64_t initNumSubEntries, int64_t initBalance,
[&](uint32_t initNumSubEntries, int64_t initBalance,
int64_t deltaLiabilities) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
ae.balance = initBalance;
Expand All @@ -75,7 +75,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
if (res)
{
REQUIRE(af->getAccount().ext.v() ==
(deltaLiabilities != 0));
((deltaLiabilities != 0) ? 1 : 0));
REQUIRE(af->getSellingLiabilities(lm) == deltaLiabilities);
}
else
Expand Down Expand Up @@ -204,7 +204,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]")

SECTION("add account buying liabilities")
{
auto addBuyingLiabilities = [&](int64_t initNumSubEntries,
auto addBuyingLiabilities = [&](uint32_t initNumSubEntries,
int64_t initBalance,
int64_t initBuyingLiabilities,
int64_t deltaLiabilities) {
Expand Down Expand Up @@ -238,7 +238,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
}
return res;
};
auto addBuyingLiabilitiesUninitialized = [&](int64_t initNumSubEntries,
auto addBuyingLiabilitiesUninitialized = [&](uint32_t initNumSubEntries,
int64_t initBalance,
int64_t deltaLiabilities) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
Expand All @@ -256,7 +256,8 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
REQUIRE(af->getSellingLiabilities(lm) == 0);
if (res)
{
REQUIRE(af->getAccount().ext.v() == (deltaLiabilities != 0));
REQUIRE(af->getAccount().ext.v() ==
((deltaLiabilities != 0) ? 1 : 0));
REQUIRE(af->getBuyingLiabilities(lm) == deltaLiabilities);
}
else
Expand Down Expand Up @@ -390,11 +391,11 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
0, lm.getMinBalance(0), INT64_MAX - lm.getMinBalance(0) - 1,
1));

REQUIRE(!addBuyingLiabilities(INT64_MAX, INT64_MAX / 2 + 1,
REQUIRE(!addBuyingLiabilities(UINT32_MAX, INT64_MAX / 2 + 1,
INT64_MAX / 2, 1));
REQUIRE(!addBuyingLiabilities(INT64_MAX, INT64_MAX / 2,
REQUIRE(!addBuyingLiabilities(UINT32_MAX, INT64_MAX / 2,
INT64_MAX / 2 + 1, 1));
REQUIRE(addBuyingLiabilities(INT64_MAX, INT64_MAX / 2,
REQUIRE(addBuyingLiabilities(UINT32_MAX, INT64_MAX / 2,
INT64_MAX / 2, 1));
}
});
Expand Down Expand Up @@ -460,7 +461,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
if (res)
{
REQUIRE(tf->getTrustLine().ext.v() ==
(deltaLiabilities != 0));
((deltaLiabilities != 0) ? 1 : 0));
REQUIRE(tf->getSellingLiabilities(lm) == deltaLiabilities);
}
else
Expand Down Expand Up @@ -594,7 +595,8 @@ TEST_CASE("liabilities", "[ledger][liabilities]")
REQUIRE(tf->getSellingLiabilities(lm) == 0);
if (res)
{
REQUIRE(tf->getTrustLine().ext.v() == (deltaLiabilities != 0));
REQUIRE(tf->getTrustLine().ext.v() ==
((deltaLiabilities != 0) ? 1 : 0));
REQUIRE(tf->getBuyingLiabilities(lm) == deltaLiabilities);
}
else
Expand Down Expand Up @@ -682,7 +684,7 @@ TEST_CASE("balance with liabilities", "[ledger][liabilities]")

SECTION("account add balance")
{
auto addBalance = [&](int64_t initNumSubEntries, int64_t initBalance,
auto addBalance = [&](uint32_t initNumSubEntries, int64_t initBalance,
Liabilities initLiabilities,
int64_t deltaBalance) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
Expand Down Expand Up @@ -779,9 +781,10 @@ TEST_CASE("balance with liabilities", "[ledger][liabilities]")

SECTION("account add subentries")
{
auto addSubEntries = [&](int64_t initNumSubEntries, int64_t initBalance,
auto addSubEntries = [&](uint32_t initNumSubEntries,
int64_t initBalance,
int64_t initSellingLiabilities,
int64_t deltaNumSubEntries) {
int32_t deltaNumSubEntries) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
ae.balance = initBalance;
ae.numSubEntries = initNumSubEntries;
Expand Down Expand Up @@ -938,7 +941,7 @@ TEST_CASE("available balance and limit", "[ledger][liabilities]")

SECTION("account available balance")
{
auto checkAvailableBalance = [&](int64_t initNumSubEntries,
auto checkAvailableBalance = [&](uint32_t initNumSubEntries,
int64_t initBalance,
int64_t initSellingLiabilities) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
Expand Down Expand Up @@ -987,7 +990,7 @@ TEST_CASE("available balance and limit", "[ledger][liabilities]")

SECTION("account available limit")
{
auto checkAvailableLimit = [&](int64_t initNumSubEntries,
auto checkAvailableLimit = [&](uint32_t initNumSubEntries,
int64_t initBalance,
int64_t initBuyingLiabilities) {
AccountEntry ae = LedgerTestUtils::generateValidAccountEntry();
Expand Down
1 change: 0 additions & 1 deletion src/transactions/MergeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ TEST_CASE("merge", "[tx][merge]")
SECTION("destination with native buying liabilities")
{
auto& lm = app->getLedgerManager();
auto txfee = lm.getTxFee();
auto minBal = lm.getMinBalance(1);
auto acc1 = root.create("acc1", minBal + txfee);
auto acc2 = root.create("acc2", minBal + txfee + 1);
Expand Down
20 changes: 0 additions & 20 deletions src/transactions/OfferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,9 +1759,6 @@ TEST_CASE("create offer", "[tx][offers]")
});

// Test when existing offers
auto reserve = app->getLedgerManager()
.getCurrentLedgerHeader()
.baseReserve;
root.pay(acc1, xlm, txfee);
REQUIRE_THROWS_AS(
market.addOffer(acc1, {usd, xlm, Price{1, 1}, 501}),
Expand Down Expand Up @@ -2590,9 +2587,6 @@ TEST_CASE("create offer", "[tx][offers]")
{
SECTION("selling native")
{
auto reserve = app->getLedgerManager()
.getCurrentLedgerHeader()
.baseReserve;
auto const minBalance =
app->getLedgerManager().getMinBalance(2);
auto acc1 = root.create("acc1", minBalance + 3 * txfee + 499);
Expand Down Expand Up @@ -2626,9 +2620,6 @@ TEST_CASE("create offer", "[tx][offers]")

SECTION("buying native")
{
auto reserve = app->getLedgerManager()
.getCurrentLedgerHeader()
.baseReserve;
auto const minBalance =
app->getLedgerManager().getMinBalance(4);
auto acc1 = root.create("acc1", minBalance + 5 * txfee);
Expand Down Expand Up @@ -2671,9 +2662,6 @@ TEST_CASE("create offer", "[tx][offers]")

SECTION("non-native")
{
auto reserve = app->getLedgerManager()
.getCurrentLedgerHeader()
.baseReserve;
auto const minBalance =
app->getLedgerManager().getMinBalance(3);
auto acc1 = root.create("acc1", minBalance + 4 * txfee);
Expand Down Expand Up @@ -2713,8 +2701,6 @@ TEST_CASE("create offer", "[tx][offers]")
{
SECTION("issuer offers do not overflow selling liabilities")
{
auto reserve =
app->getLedgerManager().getCurrentLedgerHeader().baseReserve;
auto const minBalance = app->getLedgerManager().getMinBalance(3);
auto acc1 = root.create("acc1", minBalance + 10000);
auto cur1 = acc1.asset("CUR1");
Expand All @@ -2736,8 +2722,6 @@ TEST_CASE("create offer", "[tx][offers]")

SECTION("issuer offers do not overflow buying liabilities")
{
auto reserve =
app->getLedgerManager().getCurrentLedgerHeader().baseReserve;
auto const minBalance = app->getLedgerManager().getMinBalance(3);
auto acc1 = root.create("acc1", minBalance + 10000);
auto cur1 = acc1.asset("CUR1");
Expand All @@ -2760,8 +2744,6 @@ TEST_CASE("create offer", "[tx][offers]")

SECTION("issuer offers contribute buying liabilities to other assets")
{
auto reserve =
app->getLedgerManager().getCurrentLedgerHeader().baseReserve;
auto const minBalance = app->getLedgerManager().getMinBalance(3);
auto acc1 = root.create("acc1", minBalance + 10000);
auto cur1 = acc1.asset("CUR1");
Expand All @@ -2782,8 +2764,6 @@ TEST_CASE("create offer", "[tx][offers]")

SECTION("issuer offers contribute selling liabilities to other assets")
{
auto reserve =
app->getLedgerManager().getCurrentLedgerHeader().baseReserve;
auto const minBalance = app->getLedgerManager().getMinBalance(3);
auto acc1 = root.create("acc1", minBalance + 10000);
auto cur1 = acc1.asset("CUR1");
Expand Down
2 changes: 0 additions & 2 deletions src/transactions/PaymentTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ TEST_CASE("payment", "[tx][payment]")
auto const minBal0 = app->getLedgerManager().getMinBalance(0);
auto const minBal3 = app->getLedgerManager().getMinBalance(3);

auto txfee = app->getLedgerManager().getTxFee();
auto const native = makeNativeAsset();
auto acc1 = root.create("acc1", minBal3 + 2 * txfee + 500);
TestMarket market(*app);
Expand All @@ -154,7 +153,6 @@ TEST_CASE("payment", "[tx][payment]")
auto const minBal0 = app->getLedgerManager().getMinBalance(0);
auto const minBal3 = app->getLedgerManager().getMinBalance(3);

auto txfee = app->getLedgerManager().getTxFee();
auto const native = makeNativeAsset();
auto acc1 = root.create("acc1", minBal3 + 2 * txfee + 500);
TestMarket market(*app);
Expand Down

0 comments on commit cb61d6b

Please sign in to comment.