Search in sources :

Example 6 with ExecutionEnvironment

use of co.rsk.pcc.ExecutionEnvironment in project rskj by rsksmart.

the class DeriveExtendedPublicKeyTest method createMethod.

@Before
public void createMethod() {
    ExecutionEnvironment executionEnvironment = mock(ExecutionEnvironment.class);
    HDWalletUtilsHelper helper = new HDWalletUtilsHelper();
    method = new DeriveExtendedPublicKey(executionEnvironment, helper);
}
Also used : ExecutionEnvironment(co.rsk.pcc.ExecutionEnvironment) Before(org.junit.Before)

Example 7 with ExecutionEnvironment

use of co.rsk.pcc.ExecutionEnvironment in project rskj by rsksmart.

the class ExtractPublicKeyFromExtendedPublicKeyTest method createMethod.

@Before
public void createMethod() {
    ExecutionEnvironment executionEnvironment = mock(ExecutionEnvironment.class);
    HDWalletUtilsHelper helper = new HDWalletUtilsHelper();
    method = new ExtractPublicKeyFromExtendedPublicKey(executionEnvironment, helper);
}
Also used : ExecutionEnvironment(co.rsk.pcc.ExecutionEnvironment) Before(org.junit.Before)

Example 8 with ExecutionEnvironment

use of co.rsk.pcc.ExecutionEnvironment in project rskj by rsksmart.

the class BlockHeaderContractTest method setUp.

@Before
public void setUp() {
    config = new TestSystemProperties();
    blockFactory = new BlockFactory(config.getActivationConfig());
    PrecompiledContracts precompiledContracts = new PrecompiledContracts(config, null);
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    // Enabling necessary RSKIPs for every precompiled contract to be available
    when(activations.isActive(ConsensusRule.RSKIP119)).thenReturn(true);
    world = new World();
    contract = (BlockHeaderContract) precompiledContracts.getContractForAddress(activations, DataWord.valueFromHex(BLOCK_HEADER_CONTRACT_ADDRESS));
    // contract methods
    getCoinbaseFunction = getContractFunction(contract, GetCoinbaseAddress.class);
    getMinGasPriceFunction = getContractFunction(contract, GetMinimumGasPrice.class);
    getBlockHashFunction = getContractFunction(contract, GetBlockHash.class);
    getMergedMiningTagsFunction = getContractFunction(contract, GetMergedMiningTags.class);
    getGasLimitFunction = getContractFunction(contract, GetGasLimit.class);
    getGasUsedFunction = getContractFunction(contract, GetGasUsed.class);
    getDifficultyFunction = getContractFunction(contract, GetDifficulty.class);
    getBitcoinHeaderFunction = getContractFunction(contract, GetBitcoinHeader.class);
    getUncleCoinbaseAddressFunction = getContractFunction(contract, GetUncleCoinbaseAddress.class);
    // invoke transaction
    rskTx = Transaction.builder().nonce(NONCE).gasPrice(GAS_PRICE).gasLimit(GAS_LIMIT).destination(Hex.decode(PrecompiledContracts.BLOCK_HEADER_ADDR_STR)).data(Hex.decode(DATA)).chainId(Constants.REGTEST_CHAIN_ID).value(AMOUNT).build();
    rskTx.sign(new ECKey().getPrivKeyBytes());
    executionEnvironment = mock(ExecutionEnvironment.class);
    Whitebox.setInternalState(contract, "executionEnvironment", executionEnvironment);
}
Also used : ExecutionEnvironment(co.rsk.pcc.ExecutionEnvironment) ECKey(org.ethereum.crypto.ECKey) World(co.rsk.test.World) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) TestSystemProperties(co.rsk.config.TestSystemProperties) Before(org.junit.Before)

Example 9 with ExecutionEnvironment

use of co.rsk.pcc.ExecutionEnvironment in project rskj by rsksmart.

the class BlockAccessorTest method getGenesisBlock.

@Test
public void getGenesisBlock() throws NativeContractIllegalArgumentException {
    ExecutionEnvironment executionEnvironment = EnvironmentUtils.getEnvironmentWithBlockchainOfLength(1);
    Optional<Block> genesis = blockAccessor.getBlock(ZERO_BLOCK_DEPTH, executionEnvironment);
    Optional<Block> firstBlock = blockAccessor.getBlock(ONE_BLOCK_DEPTH, executionEnvironment);
    Assert.assertTrue(genesis.isPresent());
    Assert.assertFalse(firstBlock.isPresent());
    Assert.assertEquals(0, genesis.get().getNumber());
}
Also used : ExecutionEnvironment(co.rsk.pcc.ExecutionEnvironment) Block(org.ethereum.core.Block) Test(org.junit.Test)

Aggregations

ExecutionEnvironment (co.rsk.pcc.ExecutionEnvironment)9 Before (org.junit.Before)6 TestSystemProperties (co.rsk.config.TestSystemProperties)3 World (co.rsk.test.World)2 Block (org.ethereum.core.Block)2 Test (org.junit.Test)2 RskSystemProperties (co.rsk.config.RskSystemProperties)1 RskAddress (co.rsk.core.RskAddress)1 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)1 ECKey (org.ethereum.crypto.ECKey)1 PrecompiledContracts (org.ethereum.vm.PrecompiledContracts)1