use of com.radixdlt.api.core.openapitools.model.ConstructionParseRequest 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.ConstructionParseRequest 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));
}
Aggregations