use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.
the class FcBlsVerifyAcceptanceTest method receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint.
@Test
void receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint() {
startSigner(new SignerConfigurationBuilder().withMode("filecoin").build());
final ValueNode id = JsonNodeFactory.instance.numberNode(1);
final ObjectMapper mapper = JsonMapper.builder().build();
final FilecoinSignature filecoinSignature = new FilecoinSignature(FcJsonRpc.BLS_VALUE, expectedSignature.getSignatureData().toBytesCompressed().toBase64String());
final JsonNode params = mapper.convertValue(List.of(identifier.encode(network), dataString, filecoinSignature), JsonNode.class);
final Request request = new Request("2.0", "Filecoin.WalletVerify", params, id);
final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
assertThat(response.body().jsonPath().getBoolean("result")).isEqualTo(true);
}
use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.
the class FcSecpSigningAcceptanceTest method receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint.
@Test
void receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint() throws URISyntaxException {
final String keyPath = new File(Resources.getResource("secp256k1/wallet.json").toURI()).getAbsolutePath();
final Path keyConfigFile = testDirectory.resolve("arbitrary_secp.yaml");
metadataFileHelpers.createKeyStoreYamlFileAt(keyConfigFile, Path.of(keyPath), "pass", KeyType.SECP256K1);
setupFilecoinSigner();
final ValueNode id = JsonNodeFactory.instance.numberNode(1);
final ObjectMapper mapper = JsonMapper.builder().build();
final Map<String, String> metaData = Map.of("type", "unknown");
final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.MAINNET), dataString, metaData), JsonNode.class);
final Request request = new Request("2.0", "Filecoin.WalletSign", params, id);
final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
final Map<String, Object> result = response.body().jsonPath().get("result");
assertThat(result.get("Type")).isEqualTo(1);
assertThat(result.get("Data")).isEqualTo(expectedBase64Signature);
}
use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.
the class FcBlsSigningAcceptanceTest method receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint.
@Test
void receiveASignatureWhenSubmitSigningRequestToFilecoinEndpoint() {
final String configFilename = publicKey.toString().substring(2);
final Path keyConfigFile = testDirectory.resolve(configFilename + ".yaml");
metadataFileHelpers.createUnencryptedYamlFileAt(keyConfigFile, PRIVATE_KEY, KeyType.BLS);
setupFilecoinSigner();
final ValueNode id = JsonNodeFactory.instance.numberNode(1);
final ObjectMapper mapper = JsonMapper.builder().build();
final Map<String, String> metaData = Map.of("type", "message", "extra", DATA.toBase64String());
final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.MAINNET), CID.toBase64String(), metaData), JsonNode.class);
final Request request = new Request("2.0", "Filecoin.WalletSign", params, id);
final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
final BlsArtifactSignature expectedSignature = signatureGenerator.sign(CID);
final Map<String, Object> result = response.body().jsonPath().get("result");
assertThat(result.get("Type")).isEqualTo(2);
assertThat(result.get("Data")).isEqualTo(expectedSignature.getSignatureData().toBytesCompressed().toBase64String());
}
use of com.github.arteam.simplejsonrpc.core.domain.Request in project web3signer by ConsenSys.
the class FcSecpVerifyAcceptanceTest method receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint.
@Test
void receiveTrueResponseWhenSubmitValidVerifyRequestToFilecoinEndpoint() {
startSigner(new SignerConfigurationBuilder().withMode("filecoin").build());
final ValueNode id = JsonNodeFactory.instance.numberNode(1);
final ObjectMapper mapper = JsonMapper.builder().build();
final FilecoinSignature filecoinSignature = new FilecoinSignature(FcJsonRpc.SECP_VALUE, expectedBase64Signature);
final JsonNode params = mapper.convertValue(List.of(identifier.encode(FilecoinNetwork.TESTNET), dataString, filecoinSignature), JsonNode.class);
final Request request = new Request("2.0", "Filecoin.WalletVerify", params, id);
final Response response = given().baseUri(signer.getUrl()).body(request).post(JSON_RPC_PATH);
response.then().statusCode(200).contentType(ContentType.JSON).body("jsonrpc", equalTo("2.0"), "id", equalTo(id.asInt()));
assertThat(response.body().jsonPath().getBoolean("result")).isEqualTo(true);
}
Aggregations