Search in sources :

Example 6 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.

the class EntityHandlerTest method retrieve_validator_system_entity_on_genesis.

@Test
public void retrieve_validator_system_entity_on_genesis() throws Exception {
    // Arrange
    start();
    // Act
    var request = new EntityRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).entityIdentifier(coreModelMapper.entityIdentifierValidatorSystem(selfKey()));
    var response = handleRequestWithExpectedResponse(sut, request, EntityResponse.class);
    // Assert
    var stateAccumulator = response.getStateIdentifier().getTransactionAccumulator();
    var genesisAccumulator = genesis.getProof().getAccumulatorState().getAccumulatorHash().asBytes();
    assertThat(stateAccumulator).isEqualTo(Bytes.toHexString(genesisAccumulator));
    assertThat(response.getDataObjects()).hasOnlyElementsOfTypes(ValidatorBFTData.class, ValidatorData.class);
    assertThat(response.getBalances()).containsExactly(coreModelMapper.nativeTokenAmount(getStakeAmount().toSubunits()));
}
Also used : EntityRequest(com.radixdlt.api.core.openapitools.model.EntityRequest) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 7 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.

the class KeySignHandlerTest method sign_should_work_on_correct_transaction.

@Test
public void sign_should_work_on_correct_transaction() throws Exception {
    // Arrange
    start();
    // Act
    var from = REAddr.ofPubKeyAccount(selfKey());
    var other = PrivateKeys.ofNumeric(2);
    var to = REAddr.ofPubKeyAccount(other.getPublicKey());
    var unsignedTxn = buildUnsignedTxn(from, to);
    var request = new KeySignRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).publicKey(mapper.publicKey(selfKey())).unsignedTransaction(Bytes.toHexString(unsignedTxn));
    var response = sut.handleRequest(request);
    // Assert
    assertThat(Bytes.fromHexString(response.getSignedTransaction())).isNotNull();
}
Also used : NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) KeySignRequest(com.radixdlt.api.core.openapitools.model.KeySignRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 8 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.

the class KeySignHandlerTest method sign_should_fail_given_an_invalid_transaction.

@Test
public void sign_should_fail_given_an_invalid_transaction() throws Exception {
    // Arrange
    start();
    // Act
    var request = new KeySignRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).publicKey(mapper.publicKey(selfKey())).unsignedTransaction("badbadbadbad");
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(InvalidTransactionError.class);
}
Also used : NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) KeySignRequest(com.radixdlt.api.core.openapitools.model.KeySignRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 9 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.

the class MempoolTransactionHandlerTest method retrieving_invalid_hash_should_throw.

@Test
public void retrieving_invalid_hash_should_throw() throws Exception {
    // Arrange
    start();
    // Act
    var request = new MempoolTransactionRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).transactionIdentifier(new TransactionIdentifier().hash("badbad"));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(InvalidTransactionHashError.class);
}
Also used : MempoolTransactionRequest(com.radixdlt.api.core.openapitools.model.MempoolTransactionRequest) TransactionIdentifier(com.radixdlt.api.core.openapitools.model.TransactionIdentifier) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Example 10 with NetworkIdentifier

use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.

the class TransactionsHandlerTest method retrieving_illegal_state_version_should_throw_exception.

@Test
public void retrieving_illegal_state_version_should_throw_exception() throws Exception {
    // Arrange
    start();
    // Act
    var request = new CommittedTransactionsRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).limit(1L).stateIdentifier(new PartialStateIdentifier().stateVersion(-1L));
    var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
    // Assert
    assertThat(response.getDetails()).isInstanceOf(InvalidPartialStateIdentifierError.class);
}
Also used : PartialStateIdentifier(com.radixdlt.api.core.openapitools.model.PartialStateIdentifier) NetworkIdentifier(com.radixdlt.api.core.openapitools.model.NetworkIdentifier) CommittedTransactionsRequest(com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest) ApiTest(com.radixdlt.api.ApiTest) Test(org.junit.Test)

Aggregations

NetworkIdentifier (com.radixdlt.api.core.openapitools.model.NetworkIdentifier)32 ApiTest (com.radixdlt.api.ApiTest)29 Test (org.junit.Test)29 EntityRequest (com.radixdlt.api.core.openapitools.model.EntityRequest)11 CommittedTransactionsRequest (com.radixdlt.api.core.openapitools.model.CommittedTransactionsRequest)4 PartialStateIdentifier (com.radixdlt.api.core.openapitools.model.PartialStateIdentifier)4 KeySignRequest (com.radixdlt.api.core.openapitools.model.KeySignRequest)3 Operation (com.radixdlt.api.core.openapitools.model.Operation)3 ConstructionBuildRequest (com.radixdlt.api.core.openapitools.model.ConstructionBuildRequest)2 ConstructionDeriveRequest (com.radixdlt.api.core.openapitools.model.ConstructionDeriveRequest)2 ConstructionFinalizeRequest (com.radixdlt.api.core.openapitools.model.ConstructionFinalizeRequest)2 ConstructionHashRequest (com.radixdlt.api.core.openapitools.model.ConstructionHashRequest)2 ConstructionParseRequest (com.radixdlt.api.core.openapitools.model.ConstructionParseRequest)2 EngineStatusRequest (com.radixdlt.api.core.openapitools.model.EngineStatusRequest)2 EntityIdentifier (com.radixdlt.api.core.openapitools.model.EntityIdentifier)2 MempoolTransactionRequest (com.radixdlt.api.core.openapitools.model.MempoolTransactionRequest)2 OperationGroup (com.radixdlt.api.core.openapitools.model.OperationGroup)2 Signature (com.radixdlt.api.core.openapitools.model.Signature)2 Inject (com.google.inject.Inject)1 ConstructionParseHandler (com.radixdlt.api.core.handlers.ConstructionParseHandler)1