use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class ConstructionHashHandlerTest method invalid_hex_should_throw.
@Test
public void invalid_hex_should_throw() throws Exception {
// Arrange
start();
// Act
var request = new ConstructionHashRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).signedTransaction("this_is_not_hex");
var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
// Assert
assertThat(response.getDetails()).isInstanceOf(InvalidHexError.class);
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class ConstructionParseMessageTest method parsing_transaction_with_message_should_show_message.
@Test
public void parsing_transaction_with_message_should_show_message() throws Exception {
// Arrange
start();
// Act
var hex = "deadbeefdeadbeef";
var unsignedTxn = buildUnsignedTxnWithMessage(hex);
var request = new ConstructionParseRequest().signed(false).networkIdentifier(new NetworkIdentifier().network("localnet")).transaction(Bytes.toHexString(unsignedTxn));
var response = handleRequestWithExpectedResponse(sut, request, ConstructionParseResponse.class);
// Assert
assertThat(response.getMetadata()).isNotNull();
assertThat(response.getMetadata().getMessage()).isEqualTo(hex);
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class ConstructionParseTransferTest method parsing_transaction_with_transfer_should_have_proper_substates.
@Test
public void parsing_transaction_with_transfer_should_have_proper_substates() throws Exception {
// Arrange
start();
// Act
var accountAddress = REAddr.ofPubKeyAccount(self);
var otherAddress = REAddr.ofPubKeyAccount(PrivateKeys.ofNumeric(2).getPublicKey());
var unsignedTxn = buildUnsignedTransferTxn(accountAddress, otherAddress);
var request = new ConstructionParseRequest().signed(false).networkIdentifier(new NetworkIdentifier().network("localnet")).transaction(Bytes.toHexString(unsignedTxn));
var response = handleRequestWithExpectedResponse(sut, request, ConstructionParseResponse.class);
// Assert
assertThat(response.getMetadata()).isNotNull();
assertThat(response.getMetadata().getMessage()).isNull();
var feeValue = new BigInteger(response.getMetadata().getFee().getValue());
assertThat(feeValue).isGreaterThan(BigInteger.ZERO);
var entityHoldings = response.getOperationGroups().stream().flatMap(g -> g.getOperations().stream()).peek(op -> {
assertThat(op.getSubstate()).isNotNull();
assertThat(op.getSubstate().getSubstateIdentifier()).isNotNull();
assertThat(op.getAmount()).isNotNull();
assertThat(op.getAmount().getResourceIdentifier()).isEqualTo(coreModelMapper.nativeToken());
}).collect(Collectors.groupingBy(Operation::getEntityIdentifier, Collectors.mapping(op -> new BigInteger(op.getAmount().getValue()), Collectors.reducing(BigInteger.ZERO, BigInteger::add))));
var accountEntityIdentifier = coreModelMapper.entityIdentifier(accountAddress);
var otherEntityIdentifier = coreModelMapper.entityIdentifier(otherAddress);
var transferAmount = new BigInteger(transferAmount().toString());
var expectedChange = transferAmount.negate().subtract(feeValue);
assertThat(entityHoldings).containsExactlyInAnyOrderEntriesOf(Map.of(accountEntityIdentifier, expectedChange, otherEntityIdentifier, transferAmount));
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class TransactionsHandlerTest method retrieve_genesis_in_transaction_stream.
@Test
public void retrieve_genesis_in_transaction_stream() throws Exception {
// Arrange
start();
// Act
var request = new CommittedTransactionsRequest().networkIdentifier(new NetworkIdentifier().network("localnet")).limit(1L).stateIdentifier(new PartialStateIdentifier().stateVersion(0L));
var response = handleRequestWithExpectedResponse(sut, request, CommittedTransactionsResponse.class);
// Assert
assertThat(response.getTransactions()).hasSize(1);
var hex = response.getTransactions().get(0).getMetadata().getHex();
assertThat(hex).isEqualTo(Bytes.toHexString(genesis.getTxns().get(0).getPayload()));
}
use of com.radixdlt.api.core.openapitools.model.NetworkIdentifier in project radixdlt by radixdlt.
the class TransactionsHandlerTest method retrieving_past_last_state_version_should_throw_exception.
@Test
public void retrieving_past_last_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(2L));
var response = handleRequestWithExpectedResponse(sut, request, UnexpectedError.class);
// Assert
assertThat(response.getDetails()).isInstanceOf(StateIdentifierNotFoundError.class);
}
Aggregations