@Test public void testShhPost() throws Exception { //CHECKSTYLE:OFF web3j.shhPost(new ShhPost( "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1", "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1", Arrays.asList("0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"), "0x7b2274797065223a226d6", Numeric.toBigInt("0x64"), Numeric.toBigInt("0x64"))).send(); verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_post\",\"params\":[{\"from\":\"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1\",\"to\":\"0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1\",\"topics\":[\"0x776869737065722d636861742d636c69656e74\",\"0x4d5a695276454c39425154466b61693532\"],\"payload\":\"0x7b2274797065223a226d6\",\"priority\":\"0x64\",\"ttl\":\"0x64\"}],\"id\":1}"); //CHECKSTYLE:ON }
@InvokeOnHeader(Web3jConstants.SHH_POST) void shhPost(Message message) throws IOException { String fromAddress = message.getHeader(Web3jConstants.FROM_ADDRESS, configuration::getFromAddress, String.class); String toAddress = message.getHeader(Web3jConstants.TO_ADDRESS, configuration::getToAddress, String.class); List<String> topics = message.getHeader(Web3jConstants.TOPICS, configuration::getTopics, List.class); String data = message.getHeader(Web3jConstants.DATA, configuration::getData, String.class); BigInteger priority = message.getHeader(Web3jConstants.PRIORITY, configuration::getPriority, BigInteger.class); BigInteger ttl = message.getHeader(Web3jConstants.TTL, configuration::getTtl, BigInteger.class); org.web3j.protocol.core.methods.request.ShhPost shhPost = new org.web3j.protocol.core.methods.request.ShhPost(fromAddress, toAddress, topics, data, priority, ttl); Request<?, ShhPost> request = web3j.shhPost(shhPost); setRequestId(message, request); ShhPost response = request.send(); boolean hasError = checkForError(message, response); if (!hasError) { message.setBody(response.messageSent()); } }