Search in sources :

Example 1 with JsonBftConfigOptions

use of org.hyperledger.besu.config.JsonBftConfigOptions in project besu by hyperledger.

the class IbftForksSchedulesFactoryTest method createsScheduleWithForkThatOverridesGenesisValues.

@Test
public void createsScheduleWithForkThatOverridesGenesisValues() {
    final MutableBftConfigOptions configOptions = new MutableBftConfigOptions(JsonBftConfigOptions.DEFAULT);
    final ObjectNode fork = JsonUtil.objectNodeFromMap(Map.of(BftFork.FORK_BLOCK_KEY, 1, BftFork.BLOCK_PERIOD_SECONDS_KEY, 10, BftFork.BLOCK_REWARD_KEY, "5"));
    final ForksSchedule<BftConfigOptions> forksSchedule = IbftForksSchedulesFactory.create(createGenesisConfig(configOptions, fork));
    assertThat(forksSchedule.getFork(0)).usingRecursiveComparison().isEqualTo(new ForkSpec<>(0, configOptions));
    final Map<String, Object> forkOptions = new HashMap<>(configOptions.asMap());
    forkOptions.put(BftFork.BLOCK_PERIOD_SECONDS_KEY, 10);
    forkOptions.put(BftFork.BLOCK_REWARD_KEY, "5");
    final BftConfigOptions expectedForkConfig = new MutableBftConfigOptions(new JsonBftConfigOptions(JsonUtil.objectNodeFromMap(forkOptions)));
    final ForkSpec<BftConfigOptions> expectedFork = new ForkSpec<>(1, expectedForkConfig);
    assertThat(forksSchedule.getFork(1)).usingRecursiveComparison().isEqualTo(expectedFork);
    assertThat(forksSchedule.getFork(2)).usingRecursiveComparison().isEqualTo(expectedFork);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ForkSpec(org.hyperledger.besu.consensus.common.ForkSpec) JsonBftConfigOptions(org.hyperledger.besu.config.JsonBftConfigOptions) BftConfigOptions(org.hyperledger.besu.config.BftConfigOptions) MutableBftConfigOptions(org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions) HashMap(java.util.HashMap) MutableBftConfigOptions(org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions) JsonBftConfigOptions(org.hyperledger.besu.config.JsonBftConfigOptions) Test(org.junit.Test) BaseForksSchedulesFactoryTest(org.hyperledger.besu.consensus.common.bft.BaseForksSchedulesFactoryTest)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 HashMap (java.util.HashMap)1 BftConfigOptions (org.hyperledger.besu.config.BftConfigOptions)1 JsonBftConfigOptions (org.hyperledger.besu.config.JsonBftConfigOptions)1 ForkSpec (org.hyperledger.besu.consensus.common.ForkSpec)1 BaseForksSchedulesFactoryTest (org.hyperledger.besu.consensus.common.bft.BaseForksSchedulesFactoryTest)1 MutableBftConfigOptions (org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions)1 Test (org.junit.Test)1