Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Fukushima <[email protected]>
  • Loading branch information
gfukushima committed Jul 7, 2023
1 parent bfe1743 commit 70482fc
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@
*/
package tech.pegasys.web3signer.core.jsonrpcproxy;

import io.netty.handler.codec.http.HttpResponseStatus;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.EeaSendRawTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.EeaSendTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.PrivateTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.support.TransactionCountResponder;

import java.util.Optional;

import static io.netty.handler.codec.http.HttpResponseStatus.GATEWAY_TIMEOUT;
import static java.math.BigInteger.ONE;
import static tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.EeaSendTransaction.PRIVACY_GROUP_ID;
Expand All @@ -44,6 +32,19 @@
import static tech.pegasys.web3signer.core.service.jsonrpc.response.JsonRpcError.NONCE_TOO_LOW;
import static tech.pegasys.web3signer.core.service.jsonrpc.response.JsonRpcError.SIGNING_FROM_IS_NOT_AN_UNLOCKED_ACCOUNT;

import tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.EeaSendRawTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.EeaSendTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.model.jsonrpc.PrivateTransaction;
import tech.pegasys.web3signer.core.jsonrpcproxy.support.TransactionCountResponder;

import java.util.Optional;

import io.netty.handler.codec.http.HttpResponseStatus;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.methods.response.EthSendTransaction;

/** Signing is a step during proxying a sendTransaction() JSON-RPC request to an Ethereum node. */
class SigningEeaSendTransactionIntegrationTest extends DefaultTestBase {

Expand Down Expand Up @@ -166,7 +167,8 @@ void signTransactionWhenFromAddressCaseMismatchesUnlockedAccount() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -191,7 +193,8 @@ void signTransactionWhenToAddressIsEmpty() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -209,7 +212,8 @@ void signTransactionWhenEmptyToAddress() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -230,7 +234,8 @@ void signTransactionWhenToHasAddressMissingHexPrefix() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -249,7 +254,8 @@ void signTransactionWhenFromHasAddressMissingHexPrefix() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -267,7 +273,8 @@ void signTransactionWhenMissingToAddress() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -285,7 +292,8 @@ void signTransactionWhenToAddressIsNull() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -304,7 +312,8 @@ void signTransactionWhenMissingValue() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -323,7 +332,8 @@ void signTransactionWhenValueIsNull() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand Down Expand Up @@ -351,7 +361,8 @@ void signTransactionWhenMissingGas() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -371,7 +382,8 @@ void signTransactionWhenGasIsNull() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -398,7 +410,8 @@ void signTransactionWhenMissingGasPrice() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -417,7 +430,8 @@ void signTransactionWhenGasPriceIsNull() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand Down Expand Up @@ -445,7 +459,8 @@ void signSendTransactionWhenMissingData() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -464,7 +479,8 @@ void signSendTransaction() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand All @@ -483,7 +499,8 @@ void signSendTransactionWithPrivacyGroupId() {
request.ethNode(sendRawTransactionRequest), response.ethNode(sendRawTransactionResponse));

sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransactionRequest), response.web3Signer(sendRawTransactionResponse));
request.web3Signer(sendTransactionRequest),
response.web3Signer(sendRawTransactionResponse));

verifyEthNodeReceived(sendRawTransactionRequest);
}
Expand Down Expand Up @@ -693,7 +710,8 @@ void invalidParamsResponseWhenBothPrivateForAndPrivacyGroupAreUsed() {
final PrivateTransaction transactionWithBothPrivateFromAndPrivacyGroupId =
transactionBuilder.withPrivacyGroupId(PRIVACY_GROUP_ID).build();
sendPostRequestAndVerifyResponse(
request.web3Signer(sendTransaction.request(transactionWithBothPrivateFromAndPrivacyGroupId)),
request.web3Signer(
sendTransaction.request(transactionWithBothPrivateFromAndPrivacyGroupId)),
response.web3Signer(INVALID_PARAMS));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
*/
package tech.pegasys.web3signer.core.service.jsonrpc;

import io.vertx.core.json.DecodeException;
import io.vertx.core.json.JsonObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.utils.Base64String;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import tech.pegasys.web3signer.core.Eth1Runner;
import tech.pegasys.web3signer.core.service.jsonrpc.handlers.sendtransaction.transaction.TransactionFactory;

import java.math.BigInteger;
import java.util.Optional;

import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import io.vertx.core.json.DecodeException;
import io.vertx.core.json.JsonObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.web3j.utils.Base64String;

public class EeaSendTransactionJsonParametersTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
*/
package tech.pegasys.web3signer.core.service.jsonrpc;

import io.vertx.core.json.JsonObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;

import tech.pegasys.web3signer.core.Eth1Runner;
import tech.pegasys.web3signer.core.service.jsonrpc.handlers.sendtransaction.transaction.TransactionFactory;

import java.math.BigInteger;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;
import io.vertx.core.json.JsonObject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class EthSendTransactionJsonParametersTest {

Expand Down

0 comments on commit 70482fc

Please sign in to comment.