Skip to content

Commit

Permalink
[FOLD] Use proper closeTime when accepting ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
bachase committed Sep 5, 2017
1 parent d5d2227 commit 53d4bda
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/test/consensus/LedgerTiming_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,34 @@ class LedgerTiming_test : public beast::unit_test::suite

}

void testEffCloseTime()
{
using namespace std::chrono_literals;
using tp = NetClock::time_point;
tp close;

close = effCloseTime(tp{10s}, 30s, tp{0s});
BEAST_EXPECT(close == tp{1s});

close = effCloseTime(tp{16s}, 30s, tp{0s});
BEAST_EXPECT(close == tp{30s});

close = effCloseTime(tp{16s}, 30s, tp{30s});
BEAST_EXPECT(close == tp{31s});

close = effCloseTime(tp{16s}, 30s, tp{60s});
BEAST_EXPECT(close == tp{61s});

close = effCloseTime(tp{31s}, 30s, tp{0s});
BEAST_EXPECT(close == tp{30s});
}

void
run() override
{
testGetNextLedgerTimeResolution();
testRoundCloseTime();
testEffCloseTime();
}

};
Expand Down
2 changes: 1 addition & 1 deletion src/test/csf/impl/ledgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ LedgerOracle::accept(
next.closeTimeAgree = consensusCloseTime != NetClock::time_point{};
if(next.closeTimeAgree)
next.closeTime = effCloseTime(
consensusCloseTime, closeTimeResolution, curr.parentCloseTime());
consensusCloseTime, closeTimeResolution, curr.closeTime());
else
next.closeTime = consensusCloseTime + 1s;

Expand Down

0 comments on commit 53d4bda

Please sign in to comment.