Search in sources :

Example 1 with SwirldTransaction

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));
}
Also used : SwirldTransaction(com.swirlds.common.SwirldTransaction) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SwirldTransaction(com.swirlds.common.SwirldTransaction) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 2 with SwirldTransaction

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());
}
Also used : SwirldTransaction(com.swirlds.common.SwirldTransaction) AccountID(com.hederahashgraph.api.proto.java.AccountID) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SwirldTransaction(com.swirlds.common.SwirldTransaction) Test(org.junit.jupiter.api.Test)

Example 3 with SwirldTransaction

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);
}
Also used : SwirldTransaction(com.swirlds.common.SwirldTransaction) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SwirldTransaction(com.swirlds.common.SwirldTransaction) Test(org.junit.jupiter.api.Test)

Example 4 with SwirldTransaction

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());
}
Also used : SwirldTransaction(com.swirlds.common.SwirldTransaction) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SwirldTransaction(com.swirlds.common.SwirldTransaction) Test(org.junit.jupiter.api.Test)

Example 5 with SwirldTransaction

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));
}
Also used : SwirldTransaction(com.swirlds.common.SwirldTransaction) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) SwirldTransaction(com.swirlds.common.SwirldTransaction) Test(org.junit.jupiter.api.Test)

Aggregations

SwirldTransaction (com.swirlds.common.SwirldTransaction)8 Test (org.junit.jupiter.api.Test)8 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)7 Transaction (com.hederahashgraph.api.proto.java.Transaction)7 ByteString (com.google.protobuf.ByteString)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 HashMap (java.util.HashMap)1