Skip to content

Commit

Permalink
Use setMockClock instead of rollMockClock(0) to resolve flaky tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehearn committed May 29, 2014
1 parent 51b71a4 commit 4df59ad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/com/google/bitcoin/core/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ public static void setMockClock() {
/**
* Sets the mock clock to the given time (in seconds).
*/
public static void setMockClock(long mockClock) {
mockTime = new Date(mockClock * 1000);
public static void setMockClock(long mockClockSeconds) {
mockTime = new Date(mockClockSeconds * 1000);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void onKeysAdded(List<ECKey> keys2) {
@Test
public void importKeys() {
long now = Utils.currentTimeSeconds();
Utils.rollMockClock(0);
Utils.setMockClock(now);
final ECKey key1 = new ECKey();
Utils.rollMockClock(86400);
final ECKey key2 = new ECKey();
Expand Down Expand Up @@ -185,7 +185,7 @@ public void cannotMixParams() throws Exception {

@Test
public void serializationUnencrypted() throws UnreadableWalletException {
Utils.rollMockClock(0);
Utils.setMockClock();
Date now = Utils.now();
final ECKey key1 = new ECKey();
Utils.rollMockClock(5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class KeyChainGroupTest {

public KeyChainGroupTest() {
BriefLogFormatter.init();
Utils.rollMockClock(0);
Utils.setMockClock();
group = new KeyChainGroup();
group.setLookaheadSize(LOOKAHEAD_SIZE); // Don't want slow tests.
group.getActiveKeyChain(); // Force create a chain.
Expand Down

0 comments on commit 4df59ad

Please sign in to comment.