use of org.ethereum.core.TransactionExecutor in project rskj by rsksmart.
the class CodeReplaceTest method replaceCodeTest2.
@Test
public void replaceCodeTest2() throws IOException, InterruptedException {
// We test code replacement during initialization: this is forbitten.
BigInteger nonce = config.getBlockchainConfig().getCommonConstants().getInitialNonce();
BlockChainImpl blockchain = org.ethereum.core.ImportLightTest.createBlockchain(GenesisLoader.loadGenesis(config, nonce, getClass().getResourceAsStream("/genesis/genesis-light.json"), false));
ECKey sender = ECKey.fromPrivate(Hex.decode("3ec771c31cac8c0dba77a69e503765701d3c2bb62435888d4ffa38fed60c445c"));
System.out.println("address: " + Hex.toHexString(sender.getAddress()));
String asm = // (4b) header script v1
"HEADER !0x01 !0x01 !0x00 " + // (5b) we attempt to replace the code
"0x01 0x00 CODEREPLACE " + // (7b) Extract real code into address 0, skip first 12 bytes, copy 1 bytes
"0x01 0x15 0x00 CODECOPY " + // (5b) offset 0, size 0x01, now return the first code
"0x01 0x00 RETURN " + // (1b) REAL code to install
"STOP ";
EVMAssembler assembler = new EVMAssembler();
byte[] code = assembler.assemble(asm);
// Creates a contract
Transaction tx1 = createTx(blockchain, sender, new byte[0], code);
TransactionExecutor executor1 = executeTransaction(blockchain, tx1);
// Now we can directly check the store and see the new code.
Assert.assertTrue(executor1.getResult().getException() != null);
}
Aggregations