Skip to content

Commit

Permalink
Merge pull request #85 from hyperledger/feature/transaction_data
Browse files Browse the repository at this point in the history
Get protobuf encoded transaction data
  • Loading branch information
unklayman authored Feb 11, 2019
2 parents b7e1be2 + 3426871 commit f39a209
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IrohaCommunication.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'IrohaCommunication'
s.version = '3.0.1'
s.version = '3.0.2'
s.summary = 'Helper classes to use for communication with Iroha blockchain.'

s.homepage = 'https://github.com/hyperledger/iroha-ios'
Expand Down
8 changes: 8 additions & 0 deletions IrohaCommunication/Classes/Private/IRTransactionImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ - (nullable id)transform:(NSError*_Nullable*_Nullable)error {
return transaction;
}

#pragma mark - Transaction data

- (nullable NSData *)transactionData {
Transaction *transaction = [self transform:nil];

return transaction.data;
}

#pragma mark - Signable

- (nullable NSData*)transactionHashWithError:(NSError **)error {
Expand Down
1 change: 1 addition & 0 deletions IrohaCommunication/Classes/Public/Model/IRTransaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, IRTransactionBatchType) {
@property(nonatomic, readonly)NSArray<id<IRPeerSignature>>* _Nullable signatures;
@property(nonatomic, readonly)NSArray<NSData*>* _Nullable batchHashes;
@property(nonatomic, readonly)IRTransactionBatchType batchType;
@property(nonatomic, readonly)NSData* _Nullable transactionData;

- (nullable NSData*)transactionHashWithError:(NSError **)error;

Expand Down
12 changes: 12 additions & 0 deletions Tests/Transaction/IRTransactionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ - (void)testTransactionBuildWithAllCommandsAndSingleSignature {
usingPublicKey:resultSignature.publicKey];

XCTAssertTrue(verified);

NSData *transactionData = transaction.transactionData;

XCTAssertNotNil(transactionData);
}

- (void)testInitializationFromRawTransaction {
Expand Down Expand Up @@ -111,6 +115,10 @@ - (void)testInitializationFromRawTransaction {

XCTAssertEqualObjects(originalSignature.signature.rawData, restoredSignature.signature.rawData);
XCTAssertEqualObjects(originalSignature.publicKey.rawData, restoredSignature.publicKey.rawData);

NSData *transactionData = transaction.transactionData;

XCTAssertNotNil(transactionData);
}

- (void)testBatchInitialization {
Expand Down Expand Up @@ -147,6 +155,10 @@ - (void)testBatchInitialization {
XCTAssertNil(batchedTransaction.signatures);

XCTAssertEqualObjects([batchedTransaction batchHashWithError:nil], batchHash);

NSData *transactionData = transaction.transactionData;

XCTAssertNotNil(transactionData);
}

#pragma mark - Private
Expand Down

0 comments on commit f39a209

Please sign in to comment.