Search in sources :

Example 1 with RemascConfig

use of co.rsk.config.RemascConfig in project rskj by rsksmart.

the class RemascRskAddressActivationTest method testActivation.

@Test
public void testActivation() {
    final RskAddress rskLabsAddress = new RskAddress("14d3065c8Eb89895f4df12450EC6b130049F8034");
    final RskAddress rskLabsAddressRskip218 = new RskAddress("dcb12179ba4697350f66224c959bdd9c282818df");
    final RemascTransaction txMock = mock(RemascTransaction.class);
    final Repository repositoryMock = mock(Repository.class);
    final BlockStore blockStoreMock = mock(BlockStore.class);
    final List<LogInfo> logs = Collections.emptyList();
    final ActivationConfig activationConfig = mock(ActivationConfig.class);
    final Block blockMock = mock(Block.class);
    final RemascConfig remascConfig = spy(new RemascConfigFactory(RemascContract.REMASC_CONFIG).createRemascConfig("regtest"));
    final Remasc remasc = new Remasc(Constants.regtest(), activationConfig, repositoryMock, blockStoreMock, remascConfig, txMock, PrecompiledContracts.REMASC_ADDR, blockMock, logs);
    when(remascConfig.getRskLabsAddress()).thenReturn(rskLabsAddress);
    when(remascConfig.getRskLabsAddressRskip218()).thenReturn(rskLabsAddressRskip218);
    when(activationConfig.isActive(ConsensusRule.RSKIP218, 1)).thenReturn(false);
    when(activationConfig.isActive(ConsensusRule.RSKIP218, 2)).thenReturn(true);
    when(blockMock.getNumber()).thenReturn(1L);
    RskAddress actualAddress = remasc.getRskLabsAddress();
    Assert.assertEquals(rskLabsAddress, actualAddress);
    Assert.assertEquals(blockMock.getNumber(), 1L);
    Assert.assertFalse(activationConfig.isActive(ConsensusRule.RSKIP218, blockMock.getNumber()));
    verify(remascConfig).getRskLabsAddress();
    when(blockMock.getNumber()).thenReturn(2L);
    actualAddress = remasc.getRskLabsAddress();
    Assert.assertEquals(rskLabsAddressRskip218, actualAddress);
    Assert.assertEquals(blockMock.getNumber(), 2L);
    Assert.assertTrue(activationConfig.isActive(ConsensusRule.RSKIP218, blockMock.getNumber()));
    verify(remascConfig).getRskLabsAddressRskip218();
}
Also used : RemascConfig(co.rsk.config.RemascConfig) Repository(org.ethereum.core.Repository) BlockStore(org.ethereum.db.BlockStore) LogInfo(org.ethereum.vm.LogInfo) RemascConfigFactory(co.rsk.config.RemascConfigFactory) RskAddress(co.rsk.core.RskAddress) Block(org.ethereum.core.Block) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Test(org.junit.Test)

Aggregations

RemascConfig (co.rsk.config.RemascConfig)1 RemascConfigFactory (co.rsk.config.RemascConfigFactory)1 RskAddress (co.rsk.core.RskAddress)1 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)1 Block (org.ethereum.core.Block)1 Repository (org.ethereum.core.Repository)1 BlockStore (org.ethereum.db.BlockStore)1 LogInfo (org.ethereum.vm.LogInfo)1 Test (org.junit.Test)1