use of co.rsk.util.TestContract in project rskj by rsksmart.
the class Web3ImplTest method callFromDefaultAddressInWallet.
@Test
public void callFromDefaultAddressInWallet() throws Exception {
World world = new World();
Account acc1 = new AccountBuilder(world).name("default").balance(Coin.valueOf(10000000)).build();
Block genesis = world.getBlockByName("g00");
TestContract greeter = TestContract.greeter();
Transaction tx = new TransactionBuilder().sender(acc1).gasLimit(BigInteger.valueOf(100000)).gasPrice(BigInteger.ONE).data(greeter.runtimeBytecode).build();
List<Transaction> txs = new ArrayList<>();
txs.add(tx);
Block block1 = new BlockBuilder(world).parent(genesis).transactions(txs).build();
world.getBlockChain().tryToConnect(block1);
Web3Impl web3 = createWeb3Mocked(world);
Web3.CallArguments argsForCall = new Web3.CallArguments();
argsForCall.to = TypeConverter.toJsonHex(tx.getContractAddress().getBytes());
argsForCall.data = TypeConverter.toJsonHex(greeter.functions.get("greet").encodeSignature());
String result = web3.eth_call(argsForCall, "latest");
org.junit.Assert.assertEquals("0x0000000000000000000000000000000000000000000000000000000064617665", result);
}
Aggregations