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();
}
Aggregations