use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class Web3ImplRpcTest method getRpcModules.
@Test
public void getRpcModules() {
Ethereum eth = Web3Mocks.getMockEthereum();
Blockchain blockchain = Web3Mocks.getMockBlockchain();
PersonalModule pm = new PersonalModuleWalletDisabled();
Web3Impl web3 = new Web3RskImpl(eth, blockchain, new TestSystemProperties(), null, null, pm, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
Map<String, String> result = web3.rpc_modules();
Assert.assertNotNull(result);
Assert.assertFalse(result.isEmpty());
Assert.assertTrue(result.containsKey("eth"));
Assert.assertEquals("1.0", result.get("eth"));
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class HandshakeHandlerTest method setup.
@Before
public void setup() {
RskSystemProperties config = new TestSystemProperties();
hhKey = config.getMyKey();
handler = new HandshakeHandler(config, mock(PeerScoringManager.class), mock(P2pHandler.class), mock(MessageCodec.class), // this needs to be the real object so we can test changing the HELLO message
new ConfigCapabilitiesImpl(config));
channel = mock(Channel.class);
when(channel.getNodeStatistics()).thenReturn(new NodeStatistics());
// We don't pass the handler to the constructor to avoid calling HandshakeHandler.channelActive
ch = new EmbeddedChannel();
ch.pipeline().addLast(handler);
ctx = ch.pipeline().firstContext();
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class ChannelManagerImplTest method peersForTests.
public Map<NodeID, Channel> peersForTests(int count) {
Map<NodeID, Channel> peers = new ConcurrentHashMap<>();
TestSystemProperties config = mock(TestSystemProperties.class);
when(config.maxConnectionsAllowed()).thenReturn(1);
when(config.networkCIDR()).thenReturn(32);
for (int i = 0; i < count; i++) {
Channel peer = mock(Channel.class);
when(peer.getNodeId()).thenReturn(new NodeID(HashUtil.randomPeerId()));
peers.put(peer.getNodeId(), peer);
}
return peers;
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class BlockChainBuilder method build.
public BlockChainImpl build() {
BlocksIndex blocksIndex = new HashMapBlocksIndex();
if (config == null) {
config = new TestSystemProperties();
}
if (trieStore == null) {
trieStore = new TrieStoreImpl(new HashMapDB().setClearOnClose(false));
}
if (repository == null) {
repository = new MutableRepository(trieStore, new Trie(trieStore));
}
if (stateRootHandler == null) {
stateRootHandler = new StateRootHandler(config.getActivationConfig(), new StateRootsStoreImpl(new HashMapDB()));
}
if (genesis == null) {
genesis = new BlockGenerator().getGenesisBlock();
}
GenesisLoaderImpl.loadGenesisInitalState(repository, genesis);
repository.commit();
genesis.setStateRoot(repository.getRoot());
genesis.flushRLP();
BlockFactory blockFactory = new BlockFactory(config.getActivationConfig());
if (blockStore == null) {
blockStore = new IndexedBlockStore(blockFactory, new HashMapDB(), blocksIndex);
}
if (receiptStore == null) {
KeyValueDataSource ds = new HashMapDB();
ds.init();
receiptStore = new ReceiptStoreImpl(ds);
}
if (listener == null) {
listener = new BlockExecutorTest.SimpleEthereumListener();
}
if (bridgeSupportFactory == null) {
bridgeSupportFactory = new BridgeSupportFactory(new RepositoryBtcBlockStoreWithCache.Factory(config.getNetworkConstants().getBridgeConstants().getBtcParams()), config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig());
}
BlockValidatorBuilder validatorBuilder = new BlockValidatorBuilder();
validatorBuilder.addBlockRootValidationRule().addBlockUnclesValidationRule(blockStore).addBlockTxsValidationRule(trieStore).blockStore(blockStore);
BlockValidator blockValidator = validatorBuilder.build();
ReceivedTxSignatureCache receivedTxSignatureCache = new ReceivedTxSignatureCache();
BlockTxSignatureCache blockTxSignatureCache = new BlockTxSignatureCache(receivedTxSignatureCache);
TransactionExecutorFactory transactionExecutorFactory = new TransactionExecutorFactory(config, blockStore, receiptStore, blockFactory, new ProgramInvokeFactoryImpl(), new PrecompiledContracts(config, bridgeSupportFactory), blockTxSignatureCache);
repositoryLocator = new RepositoryLocator(trieStore, stateRootHandler);
transactionPool = new TransactionPoolImpl(config, repositoryLocator, this.blockStore, blockFactory, new TestCompositeEthereumListener(), transactionExecutorFactory, new ReceivedTxSignatureCache(), 10, 100);
BlockExecutor blockExecutor = new BlockExecutor(config.getActivationConfig(), repositoryLocator, transactionExecutorFactory);
BlockChainImpl blockChain = new BlockChainLoader(blockStore, receiptStore, transactionPool, listener, blockValidator, blockExecutor, genesis, stateRootHandler, repositoryLocator).loadBlockchain();
if (this.testing) {
blockChain.setBlockValidator(new DummyBlockValidator());
blockChain.setNoValidation(true);
}
blockStore.saveBlock(genesis, genesis.getCumulativeDifficulty(), true);
if (this.blocks != null) {
for (Block b : this.blocks) {
blockExecutor.executeAndFillAll(b, blockChain.getBestBlock().getHeader());
blockChain.tryToConnect(b);
}
}
return blockChain;
}
use of co.rsk.config.TestSystemProperties in project rskj by rsksmart.
the class BlockBuilder method build.
public Block build() {
Block block = blockGenerator.createChildBlock(parent, txs, uncles, difficulty, this.minGasPrice, gasLimit);
if (blockChain != null) {
final TestSystemProperties config = new TestSystemProperties();
StateRootHandler stateRootHandler = new StateRootHandler(config.getActivationConfig(), new StateRootsStoreImpl(new HashMapDB()));
BlockExecutor executor = new BlockExecutor(config.getActivationConfig(), new RepositoryLocator(trieStore, stateRootHandler), new TransactionExecutorFactory(config, blockStore, null, new BlockFactory(config.getActivationConfig()), new ProgramInvokeFactoryImpl(), new PrecompiledContracts(config, bridgeSupportFactory), new BlockTxSignatureCache(new ReceivedTxSignatureCache())));
executor.executeAndFill(block, parent.getHeader());
}
return block;
}
Aggregations