use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class RskForksBridgeTest method callGetStateForDebuggingTx.
private BridgeState callGetStateForDebuggingTx() throws IOException {
TestSystemProperties beforeBambooProperties = new TestSystemProperties();
Transaction rskTx = CallTransaction.createRawTransaction(0, Long.MAX_VALUE, Long.MAX_VALUE, PrecompiledContracts.BRIDGE_ADDR, 0, Bridge.GET_STATE_FOR_DEBUGGING.encode(new Object[] {}), beforeBambooProperties.getNetworkConstants().getChainId());
rskTx.sign(new byte[] {});
TransactionExecutorFactory transactionExecutorFactory = new TransactionExecutorFactory(beforeBambooProperties, blockStore, null, new BlockFactory(beforeBambooProperties.getActivationConfig()), new ProgramInvokeFactoryImpl(), new PrecompiledContracts(beforeBambooProperties, world.getBridgeSupportFactory()), world.getBlockTxSignatureCache());
Repository track = repository.startTracking();
TransactionExecutor executor = transactionExecutorFactory.newInstance(rskTx, 0, blockChain.getBestBlock().getCoinbase(), track, blockChain.getBestBlock(), 0).setLocalCall(true);
executor.executeTransaction();
ProgramResult res = executor.getResult();
Object[] result = Bridge.GET_STATE_FOR_DEBUGGING.decodeResult(res.getHReturn());
ActivationConfig.ForBlock activations = beforeBambooProperties.getActivationConfig().forBlock(blockChain.getBestBlock().getNumber());
return BridgeState.create(beforeBambooProperties.getNetworkConstants().getBridgeConstants(), (byte[]) result[0], activations);
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class GitHubBlockTest method runHomestead.
private void runHomestead(String name) throws IOException, ParseException {
String json = JSONReader.loadJSONFromCommit("BlockchainTests/Homestead/" + name + ".json", shacommit);
TestSystemProperties config = new TestSystemProperties();
GitHubJSONTestSuite.runGitHubJsonBlockTest(json, Collections.EMPTY_SET);
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class GitHubBlockTest method runSingleTest.
// test for conveniently running a single test
@Ignore
@Test
public void runSingleTest() throws ParseException, IOException {
TestSystemProperties config = new TestSystemProperties();
config.setGenesisInfo("frontier.json");
String json = JSONReader.loadJSONFromCommit("BlockchainTests/Homestead/bcTotalDifficultyTest.json", shacommit);
GitHubJSONTestSuite.runGitHubJsonSingleBlockTest(json, "sideChainWithNewMaxDifficultyStartingFromBlock3AfterBlock4");
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class CliToolsTest method rewindBlocks.
@Test
public void rewindBlocks() {
TestSystemProperties config = new TestSystemProperties();
BlockFactory blockFactory = new BlockFactory(config.getActivationConfig());
KeyValueDataSource keyValueDataSource = new HashMapDB();
IndexedBlockStore indexedBlockStore = new IndexedBlockStore(blockFactory, keyValueDataSource, new HashMapBlocksIndex());
int blocksToGenerate = 14;
Keccak256 parentHash = Keccak256.ZERO_HASH;
for (long i = 0; i < blocksToGenerate; i++) {
Block block = mock(Block.class);
Keccak256 blockHash = randomHash();
when(block.getHash()).thenReturn(blockHash);
when(block.getParentHash()).thenReturn(parentHash);
when(block.getNumber()).thenReturn(i);
when(block.getEncoded()).thenReturn(TestUtils.randomBytes(128));
indexedBlockStore.saveBlock(block, ZERO, true);
parentHash = blockHash;
}
Block bestBlock = indexedBlockStore.getBestBlock();
assertThat(bestBlock.getNumber(), is((long) blocksToGenerate - 1));
RskContext rskContext = mock(RskContext.class);
doReturn(indexedBlockStore).when(rskContext).getBlockStore();
RepositoryLocator repositoryLocator = mock(RepositoryLocator.class);
doReturn(Optional.of(mock(RepositorySnapshot.class))).when(repositoryLocator).findSnapshotAt(any());
doReturn(repositoryLocator).when(rskContext).getRepositoryLocator();
NodeStopper stopper = mock(NodeStopper.class);
StringBuilder output = new StringBuilder();
RewindBlocks rewindBlocksCliTool = new RewindBlocks(output::append);
rewindBlocksCliTool.execute(new String[] { "fmi" }, () -> rskContext, stopper);
String data = output.toString();
Assert.assertTrue(data.contains("No inconsistent block has been found"));
verify(stopper).stop(0);
clearInvocations(stopper);
long blockToRewind = blocksToGenerate / 2;
output = new StringBuilder();
rewindBlocksCliTool = new RewindBlocks(output::append);
rewindBlocksCliTool.execute(new String[] { String.valueOf(blockToRewind) }, () -> rskContext, stopper);
bestBlock = indexedBlockStore.getBestBlock();
assertThat(bestBlock.getNumber(), is(blockToRewind));
data = output.toString();
Assert.assertTrue(data.contains("New highest block number stored in db: " + blockToRewind));
verify(stopper).stop(0);
clearInvocations(stopper);
output = new StringBuilder();
rewindBlocksCliTool = new RewindBlocks(output::append);
rewindBlocksCliTool.execute(new String[] { String.valueOf(blocksToGenerate + 1) }, () -> rskContext, stopper);
bestBlock = indexedBlockStore.getBestBlock();
assertThat(bestBlock.getNumber(), is(blockToRewind));
data = output.toString();
Assert.assertTrue(data.contains("No need to rewind"));
verify(stopper).stop(0);
clearInvocations(stopper);
doReturn(Optional.empty()).when(repositoryLocator).findSnapshotAt(any());
output = new StringBuilder();
rewindBlocksCliTool = new RewindBlocks(output::append);
rewindBlocksCliTool.execute(new String[] { "fmi" }, () -> rskContext, stopper);
data = output.toString();
Assert.assertTrue(data.contains("Min inconsistent block number: 0"));
verify(stopper).stop(0);
clearInvocations(stopper);
output = new StringBuilder();
rewindBlocksCliTool = new RewindBlocks(output::append);
rewindBlocksCliTool.execute(new String[] { "rbc" }, () -> rskContext, stopper);
data = output.toString();
Assert.assertTrue(data.contains("Min inconsistent block number: 0"));
Assert.assertTrue(data.contains("New highest block number stored in db: -1"));
verify(stopper).stop(0);
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class ChannelManagerImplTest method blockAddressIsAvailable.
@Test
public void blockAddressIsAvailable() throws UnknownHostException {
ChannelManagerImpl channelManagerImpl = new ChannelManagerImpl(new TestSystemProperties(), null);
;
Assert.assertTrue(channelManagerImpl.isAddressBlockAvailable(InetAddress.getLocalHost()));
}
Aggregations