use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method hasSpanMap.
@Test
void hasSpanMap() throws InvalidProtocolBufferException {
// setup:
Transaction signedTxnWithBody = Transaction.newBuilder().setBodyBytes(someTxn.toByteString()).build();
SwirldTransaction platformTxn = new SwirldTransaction(signedTxnWithBody.toByteArray());
// given:
SignedTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
// expect:
assertThat(subject.getSpanMap(), instanceOf(HashMap.class));
}
use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method getsPayer.
@Test
void getsPayer() throws Exception {
// given:
AccountID payer = asAccount("0.0.2");
Transaction signedTxnWithBody = Transaction.newBuilder().setBodyBytes(someTxn.toByteString()).build();
SwirldTransaction platformTxn = new SwirldTransaction(signedTxnWithBody.toByteArray());
// when:
PlatformTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
// then:
assertEquals(payer, subject.getPayer());
}
use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method getsCorrectLoggableForm.
@Test
void getsCorrectLoggableForm() throws Exception {
Transaction signedTxnWithBody = Transaction.newBuilder().setBodyBytes(someTxn.toByteString()).setSigMap(SignatureMap.newBuilder().addSigPair(SignaturePair.newBuilder().setPubKeyPrefix(ByteString.copyFrom("UNREAL".getBytes())).setEd25519(ByteString.copyFrom("FAKE".getBytes())))).build();
SwirldTransaction platformTxn = new SwirldTransaction(signedTxnWithBody.toByteArray());
// when:
PlatformTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
Transaction signedTxn4Log = subject.getSignedTxnWrapper();
Transaction asBodyBytes = signedTxn4Log.toBuilder().setBodyBytes(CommonUtils.extractTransactionBodyByteString(signedTxn4Log)).build();
// then:
assertEquals(someTxn, CommonUtils.extractTransactionBody(signedTxn4Log));
assertEquals(signedTxnWithBody, asBodyBytes);
}
use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method sigMetaGetterSetterCheck.
@Test
void sigMetaGetterSetterCheck() throws InvalidProtocolBufferException {
// setup:
Transaction signedTxnWithBody = Transaction.newBuilder().setBodyBytes(someTxn.toByteString()).build();
SwirldTransaction platformTxn = new SwirldTransaction(signedTxnWithBody.toByteArray());
// given:
SignedTxnAccessor subject = new PlatformTxnAccessor(platformTxn);
// when:
subject.setSigMeta(RationalizedSigMeta.noneAvailable());
// then:
assertSame(RationalizedSigMeta.noneAvailable(), subject.getSigMeta());
}
use of com.swirlds.common.SwirldTransaction in project hedera-services by hashgraph.
the class PlatformTxnAccessorTest method failsOnInvalidTxn.
@Test
void failsOnInvalidTxn() {
// given:
Transaction signedNonsenseTxn = Transaction.newBuilder().setBodyBytes(ByteString.copyFrom(NONSENSE)).build();
// and:
SwirldTransaction platformTxn = new SwirldTransaction(signedNonsenseTxn.toByteArray());
// expect:
assertThrows(InvalidProtocolBufferException.class, () -> new PlatformTxnAccessor(platformTxn));
}
Aggregations