use of co.rsk.test.World in project rskj by rsksmart.
the class Web3ImplLogsTest method getLogsFromBlockchainWithCallContractAndFilterByUnknownTopic.
@Test
public void getLogsFromBlockchainWithCallContractAndFilterByUnknownTopic() throws Exception {
World world = new World();
Web3Impl web3 = getWeb3WithContractCall(world);
Web3.FilterRequest fr = new Web3.FilterRequest();
fr.fromBlock = "earliest";
fr.topics = new Object[1];
fr.topics[0] = "0102030405060102030405060102030405060102030405060102030405060102";
Object[] logs = web3.eth_getLogs(fr);
Assert.assertNotNull(logs);
Assert.assertEquals(0, logs.length);
}
use of co.rsk.test.World in project rskj by rsksmart.
the class Web3ImplLogsTest method getLogsFromBlockchainWithCallContractAndFilterByKnownTopic.
@Test
public void getLogsFromBlockchainWithCallContractAndFilterByKnownTopic() throws Exception {
World world = new World();
Web3Impl web3 = getWeb3WithContractCall(world);
Block block1 = world.getBlockChain().getBlockByNumber(1l);
Web3.FilterRequest fr = new Web3.FilterRequest();
fr.fromBlock = "earliest";
fr.topics = new Object[1];
fr.topics[0] = GET_VALUED_EVENT_SIGNATURE;
Object[] logs = web3.eth_getLogs(fr);
Assert.assertNotNull(logs);
String address = "0x" + Hex.toHexString(block1.getTransactionsList().get(0).getContractAddress().getBytes());
Assert.assertEquals(1, logs.length);
Assert.assertEquals(address, ((LogFilterElement) logs[0]).address);
}
use of co.rsk.test.World in project rskj by rsksmart.
the class Web3ImplLogsTest method getLogsFromBlockchainWithCallContractAndFilterByUnknownContractAddress.
@Test
public void getLogsFromBlockchainWithCallContractAndFilterByUnknownContractAddress() throws Exception {
World world = new World();
Web3Impl web3 = getWeb3WithContractCall(world);
Web3.FilterRequest fr = new Web3.FilterRequest();
fr.fromBlock = "earliest";
List<String> addresses = new ArrayList<>();
addresses.add(Hex.toHexString(new byte[20]));
fr.address = addresses;
Object[] logs = web3.eth_getLogs(fr);
Assert.assertNotNull(logs);
Assert.assertEquals(0, logs.length);
}
use of co.rsk.test.World in project rskj by rsksmart.
the class Web3ImplLogsTest method getWeb3WithContractCreationWithoutEvents.
private Web3Impl getWeb3WithContractCreationWithoutEvents() {
World world = new World();
Account acc1 = new AccountBuilder(world).name("notDefault").balance(Coin.valueOf(10000000)).build();
Block genesis = world.getBlockByName("g00");
/* contract compiled in data attribute of tx
contract greeter {
address owner;
modifier onlyOwner { if (msg.sender != owner) throw; _ ; }
function greeter() public {
owner = msg.sender;
}
function greet(string param) onlyOwner constant returns (string) {
return param;
}
} */
Transaction tx = new TransactionBuilder().sender(acc1).gasLimit(BigInteger.valueOf(100000)).gasPrice(BigInteger.ONE).data(compiledGreeter).build();
List<Transaction> txs = new ArrayList<>();
txs.add(tx);
BlockChainImpl blockChain = world.getBlockChain();
Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
blockChain.tryToConnect(block1);
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), blockChain.getBlockStore(), null, null, null, 10, 100);
Web3Impl web3 = createWeb3(world.getBlockChain(), transactionPool);
web3.personal_newAccountWithSeed("notDefault");
return web3;
}
use of co.rsk.test.World in project rskj by rsksmart.
the class Web3ImplLogsTest method getWeb3WithEventInContractCreation.
private Web3Impl getWeb3WithEventInContractCreation() {
ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB());
World world = getWorld3WithBlockWithEventInContractCreation(config, receiptStore);
TransactionPool transactionPool = new TransactionPoolImpl(config, world.getRepository(), world.getBlockChain().getBlockStore(), receiptStore, null, null, 10, 100);
Web3Impl web3 = createWeb3(world.getBlockChain(), transactionPool, receiptStore);
web3.personal_newAccountWithSeed("notDefault");
return web3;
}
Aggregations