use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method failsOnInvalidSignedTxn.
@Test
void failsOnInvalidSignedTxn() {
// given:
SwirldTransaction platformTxn = new SwirldTransaction(NONSENSE);
// expect:
assertThrows(InvalidProtocolBufferException.class, () -> new PlatformTxnAccessor(platformTxn));
}
use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method getsCorrectLoggableFormWithSignedTransactionBytes.
@Test
void getsCorrectLoggableFormWithSignedTransactionBytes() throws Exception {
SignedTransaction signedTxn = SignedTransaction.newBuilder().setBodyBytes(someTxn.toByteString()).setSigMap(SignatureMap.newBuilder().addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(ByteString.copyFrom("UNREAL".getBytes())).setEd25519(ByteString.copyFrom("FAKE".getBytes())).build())).build();
Transaction txn = Transaction.newBuilder().setSignedTransactionBytes(signedTxn.toByteString()).build();
SwirldTransaction platformTxn = new SwirldTransaction(txn.toByteArray());
// when:
PlatformTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
Transaction signedTxn4Log = subject.getSignedTxnWrapper();
ByteString signedTxnBytes = signedTxn4Log.getSignedTransactionBytes();
Transaction asBodyBytes = signedTxn4Log.toBuilder().setSignedTransactionBytes(CommonUtils.extractTransactionBodyByteString(signedTxn4Log)).build();
// then:
assertEquals(signedTxnBytes, txn.getSignedTransactionBytes());
assertEquals(signedTxn.getBodyBytes(), asBodyBytes.getSignedTransactionBytes());
}
use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method usesBodyBytesCorrectly.
@Test
void usesBodyBytesCorrectly() throws Exception {
// given:
Transaction signedTxnWithBody = Transaction.newBuilder().setBodyBytes(someTxn.toByteString()).build();
SwirldTransaction platformTxn = new SwirldTransaction(signedTxnWithBody.toByteArray());
// when:
PlatformTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
// then:
assertEquals(someTxn, subject.getTxn());
assertThat(List.of(subject.getTxnBytes()), contains(someTxn.toByteArray()));
}
Aggregations