use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.
the class BlockchainLoaderTest method testLoadBlockchainEmptyBlockchain.
@Test
public void testLoadBlockchainEmptyBlockchain() {
RskTestFactory objects = new RskTestFactory() {
@Override
protected GenesisLoader buildGenesisLoader() {
return new TestGenesisLoader(getTrieStore(), "blockchain_loader_genesis.json", BigInteger.ZERO, true, true, true);
}
};
// calls loadBlockchain
Blockchain blockchain = objects.getBlockchain();
RepositorySnapshot repository = objects.getRepositoryLocator().snapshotAt(blockchain.getBestBlock().getHeader());
TestSystemProperties testSystemProperties = new TestSystemProperties();
ActivationConfig.ForBlock activations = testSystemProperties.getActivationConfig().forBlock(0);
int enabledPCCs = PrecompiledContracts.GENESIS_ADDRESSES.size();
for (ConsensusRule consensusRule : PrecompiledContracts.CONSENSUS_ENABLED_ADDRESSES.values()) {
if (activations.isActive(consensusRule)) {
enabledPCCs++;
}
}
int testAccountsSize = 3;
// PCCs + test accounts in blockchain_loader_genesis.json
int genesisAccountKeysSize = enabledPCCs + testAccountsSize;
Assert.assertEquals(genesisAccountKeysSize, repository.getAccountsKeys().size());
RskAddress daba01 = new RskAddress("dabadabadabadabadabadabadabadabadaba0001");
Assert.assertEquals(Coin.valueOf(2000), repository.getBalance(daba01));
Assert.assertEquals(BigInteger.valueOf(24), repository.getNonce(daba01));
RskAddress daba02 = new RskAddress("dabadabadabadabadabadabadabadabadaba0002");
Assert.assertEquals(Coin.valueOf(1000), repository.getBalance(daba02));
Assert.assertEquals(BigInteger.ZERO, repository.getNonce(daba02));
RskAddress address = new RskAddress("77045e71a7a2c50903d88e564cd72fab11e82051");
Assert.assertEquals(Coin.valueOf(10), repository.getBalance(address));
Assert.assertEquals(BigInteger.valueOf(25), repository.getNonce(address));
Assert.assertEquals(DataWord.ONE, repository.getStorageValue(address, DataWord.ZERO));
Assert.assertEquals(DataWord.valueOf(3), repository.getStorageValue(address, DataWord.ONE));
Assert.assertEquals(274, Objects.requireNonNull(repository.getCode(address)).length);
}
use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.
the class BlockResultDTOTest method buildBlockWithTransactions.
private Block buildBlockWithTransactions(List<Transaction> transactions) {
RskTestFactory objects = new RskTestFactory() {
@Override
protected GenesisLoader buildGenesisLoader() {
return new TestGenesisLoader(getTrieStore(), "rsk-unittests.json", BigInteger.ZERO, true, true, true);
}
};
Blockchain blockChain = objects.getBlockchain();
// Build block with remasc and normal txs
BlockBuilder builder = new BlockBuilder(null, null, null).parent(blockChain.getBestBlock());
return builder.transactions(transactions).build();
}
use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.
the class Web3ImplLogsTest method setUp.
// 20965255 getValue()
// 371303c0 inc()
@Before
public void setUp() {
RskTestFactory factory = new RskTestFactory();
blockChain = factory.getBlockchain();
blockStore = factory.getBlockStore();
trieStore = factory.getTrieStore();
mainchainView = factory.getMiningMainchainView();
repositoryLocator = factory.getRepositoryLocator();
transactionPool = factory.getTransactionPool();
eth = factory.getRsk();
receiptStore = factory.getReceiptStore();
web3 = createWeb3();
}
use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.
the class BlockExecutorTest method setUp.
@Before
public void setUp() {
RskTestFactory objects = new RskTestFactory(CONFIG);
blockchain = objects.getBlockchain();
executor = objects.getBlockExecutor();
trieStore = objects.getTrieStore();
repository = objects.getRepositoryLocator().snapshotAt(blockchain.getBestBlock().getHeader());
}
use of org.ethereum.util.RskTestFactory in project rskj by rsksmart.
the class MinerManagerTest method setup.
@Before
public void setup() {
RskTestFactory factory = new RskTestFactory(config);
blockchain = factory.getBlockchain();
miningMainchainView = factory.getMiningMainchainView();
transactionPool = factory.getTransactionPool();
repositoryLocator = factory.getRepositoryLocator();
blockStore = factory.getBlockStore();
blockFactory = factory.getBlockFactory();
blockExecutor = factory.getBlockExecutor();
}
Aggregations