Skip to content

Commit

Permalink
#191: add time to slot
Browse files Browse the repository at this point in the history
  • Loading branch information
eustimenko committed Sep 20, 2019
1 parent 55ba795 commit b0c224d
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
import org.ethereum.beacon.core.BeaconBlock;
import org.ethereum.beacon.core.BeaconBlockBody;
import org.ethereum.beacon.core.BeaconState;
import org.ethereum.beacon.core.spec.SpecConstants;
import org.ethereum.beacon.core.state.Eth1Data;
import org.ethereum.beacon.core.types.BLSSignature;
import org.ethereum.beacon.core.types.Millis;
import org.ethereum.beacon.core.types.ShardNumber;
import org.ethereum.beacon.core.types.SlotNumber;
import org.ethereum.beacon.core.types.Time;
import org.ethereum.beacon.db.Database;
Expand Down Expand Up @@ -133,14 +136,27 @@ public void testRejectBlocks_future() {

BeaconChainSpec spec =
BeaconChainSpec.Builder.createWithDefaultParams()
.withConstants(new SpecConstants() {
@Override
public ShardNumber getShardCount() {
return ShardNumber.of(16);
}

@Override
public SlotNumber.EpochLength getSlotsPerEpoch() {
return new SlotNumber.EpochLength(UInt64.valueOf(4));
}
})
.withComputableGenesisTime(false)
.withVerifyDepositProof(false)
.build();

StateTransition<BeaconStateEx> perSlotTransition =
StateTransitionTestUtil.createNextSlotTransition();
MutableBeaconChain beaconChain = createBeaconChain(spec, perSlotTransition, schedulers);

MutableBeaconChain beaconChain = createBeaconChain(spec, perSlotTransition, schedulers);
beaconChain.init();

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

Expand All @@ -153,7 +169,8 @@ public void testRejectBlocks_future() {
// assert block.slot <= get_current_slot(store.time) + 1
BeaconState state = perSlotTransition.apply(new BeaconStateExImpl(parent.getState()));
SlotNumber currentSlot = spec.get_current_slot(parent.getState(), schedulers.getCurrentTime());
SlotNumber nextToCurrentSlot = spec.get_current_slot(state, currentTime).increment();
schedulers.addTime(Millis.BIT_SIZE);
SlotNumber nextToCurrentSlot = spec.get_current_slot(state, schedulers.getCurrentTime()).increment();
final boolean actual = nextToCurrentSlot.greaterEqual(currentSlot);

// assert store.time >= pre_state.genesis_time + block.slot * SECONDS_PER_SLOT
Expand Down

0 comments on commit b0c224d

Please sign in to comment.