Skip to content

Commit

Permalink
#191: test reject
Browse files Browse the repository at this point in the history
  • Loading branch information
eustimenko committed Sep 19, 2019
1 parent aa452ce commit 2447e6b
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
import org.ethereum.beacon.core.types.BLSSignature;
import org.ethereum.beacon.core.types.Time;
import org.ethereum.beacon.db.Database;
import org.ethereum.beacon.schedulers.ControlledSchedulers;
import org.ethereum.beacon.schedulers.Schedulers;
import org.junit.Assert;
import org.junit.Test;
import tech.pegasys.artemis.ethereum.core.Hash32;
import tech.pegasys.artemis.util.uint.UInt64;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -119,4 +122,30 @@ public BeaconStateEx apply(BeaconStateEx stateEx) {
chainStorage,
schedulers);
}

@Test
public void testRejectBlocks() {
ControlledSchedulers schedulers = Schedulers.createControlled();
schedulers.setCurrentTime(Instant.now().plus(1, ChronoUnit.DAYS).toEpochMilli());

BeaconChainSpec spec =
BeaconChainSpec.Builder.createWithDefaultParams()
.withComputableGenesisTime(false)
.withVerifyDepositProof(false)
.build();
StateTransition<BeaconStateEx> perSlotTransition =
StateTransitionTestUtil.createNextSlotTransition();
MutableBeaconChain beaconChain = createBeaconChain(spec, perSlotTransition, schedulers);

beaconChain.init();
BeaconTuple initialTuple = beaconChain.getRecentlyProcessed();
Assert.assertEquals(spec.getConstants().getGenesisSlot(), initialTuple.getBlock().getSlot());

BeaconTuple recentlyProcessed = beaconChain.getRecentlyProcessed();
BeaconBlock aBlock =
createBlock(recentlyProcessed, spec, schedulers.getCurrentTime(), perSlotTransition);

Assert.assertEquals(ImportResult.ExpiredBlock, beaconChain.insert(aBlock));
Assert.assertEquals(aBlock, beaconChain.getRecentlyProcessed().getBlock());
}
}

0 comments on commit 2447e6b

Please sign in to comment.