Skip to content

Commit

Permalink
Merge pull request #112 from hyperledger/develop
Browse files Browse the repository at this point in the history
Support Iroha 1.1
  • Loading branch information
ERussel authored Sep 13, 2019
2 parents a210ae1 + ca2309d commit 103622e
Show file tree
Hide file tree
Showing 176 changed files with 3,229 additions and 661 deletions.
104 changes: 46 additions & 58 deletions Example/IrohaCommunication.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
enableAddressSanitizer = "YES"
enableASanStackUseAfterReturn = "YES"
enableUBSanitizer = "YES"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PODS:
- gRPC/Main (1.11.0):
- gRPC-Core (= 1.11.0)
- gRPC-RxLibrary (= 1.11.0)
- IrohaCommunication (3.2.0):
- IrohaCommunication (3.4.0):
- BoringSSL (= 10.0.3)
- gRPC-ProtoRPC (= 1.11.0)
- IrohaCrypto
Expand Down Expand Up @@ -62,7 +62,7 @@ SPEC CHECKSUMS:
gRPC-Core: 164639cd8ae18ca8b65477fafb2efbaecf4f181a
gRPC-ProtoRPC: bb5fddf3424aa4fad74d76736578a79fe40e244e
gRPC-RxLibrary: 26d53d1b1f306befd4ad4e15bd6de27839a82481
IrohaCommunication: 80d8be2565e5bbd3446bdc5d2bdfb0e0849606e8
IrohaCommunication: 1519ba62909b1d8283244a6b9098b330bae2beab
IrohaCrypto: 4eb85b5edbf7667b5ffcef1b5104357f18ca8e81
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
Expand Down
15 changes: 9 additions & 6 deletions IntegrationTests/IrohaContainer/IRBaseIrohaContainerTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
@import IrohaCommunication;
@import IrohaCrypto;

@interface IRBaseIrohaContainerTests : XCTestCase
NS_ASSUME_NONNULL_BEGIN

@property(strong, nonatomic)IRNetworkService * _Nonnull iroha;
@interface IRBaseIrohaContainerTests : XCTestCase

@property(strong, nonatomic)id<IRAccountId> _Nonnull adminAccountId;
@property(strong, nonatomic)id<IRPublicKeyProtocol> _Nonnull adminPublicKey;
@property(strong, nonatomic)id<IRSignatureCreatorProtocol> _Nonnull adminSigner;
@property(strong, nonatomic)id<IRDomain> _Nonnull domain;
@property (strong, nonatomic) IRNetworkService *iroha;
@property (strong, nonatomic) id<IRAccountId> adminAccountId;
@property (strong, nonatomic) id<IRPublicKeyProtocol> adminPublicKey;
@property (strong, nonatomic) id<IRSignatureCreatorProtocol> adminSigner;
@property (strong, nonatomic) id<IRDomain> domain;

@end

NS_ASSUME_NONNULL_END
10 changes: 5 additions & 5 deletions IntegrationTests/IrohaContainer/IRIrohaContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#import <Foundation/Foundation.h>
@import IrohaCommunication;

@interface IRIrohaContainer : NSObject

+ (nonnull instancetype)shared;
@interface IRIrohaContainer : NSObject

@property(nonatomic, readonly)IRNetworkService * _Nonnull iroha;
@property (nonatomic, readonly) IRNetworkService * _Nonnull iroha;

- (nullable NSError*)start;
- (nullable NSError*)stop;
+ (nonnull instancetype)shared;
- (nullable NSError *)start;
- (nullable NSError *)stop;

@end
33 changes: 18 additions & 15 deletions IntegrationTests/IrohaContainer/IRIrohaContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@

#import "IRIrohaContainer.h"

static NSString* const DOCKER_HOST = @"http://localhost:49721";
static NSString* const CONTAINER = @"iroha";
static NSString * const DOCKER_HOST = @"http://localhost:49721";
static NSString * const CONTAINER = @"iroha";

static NSString * IROHA_IP = @"127.0.0.1";
static NSString * IROHA_PORT = @"50051";
static NSString *IROHA_IP = @"127.0.0.1";
static NSString *IROHA_PORT = @"50051";

static NSUInteger CONNECTION_TRIES = 10;
static NSTimeInterval CONNECTION_TRY_DELAY = 1.0;


@interface IRIrohaContainer()

@property(strong, nonatomic)NSURLSession *session;
@property(strong, nonatomic)IRNetworkService *irohaService;
@property (strong, nonatomic) NSURLSession *session;
@property (strong, nonatomic) IRNetworkService *irohaService;

@end


@implementation IRIrohaContainer

#pragma mark - Initialization
Expand Down Expand Up @@ -55,9 +57,10 @@ + (nonnull instancetype)shared {
return sharedContainer;
}


#pragma mark - Interface

- (nullable NSError*)start {
- (nullable NSError *)start {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

__block NSError *resultError;
Expand Down Expand Up @@ -98,7 +101,7 @@ - (nullable NSError*)start {
return resultError;
}

- (nullable NSError*)stop {
- (nullable NSError *)stop {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

__block NSError *resultError;
Expand Down Expand Up @@ -177,7 +180,7 @@ - (nonnull NSURLRequest*)createContainerStopRequest {

#pragma mark - Response

- (nullable NSError*)handleRestartResponse:(nonnull NSURLResponse *)response
- (nullable NSError *)handleRestartResponse:(nonnull NSURLResponse *)response
data:(nullable NSData *)data
receivedError:(nullable NSError *)receivedError {
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
Expand Down Expand Up @@ -206,10 +209,10 @@ - (nullable NSError*)handleRestartResponse:(nonnull NSURLResponse *)response
return [IRIrohaContainer errorForMessage:@"Unexpected response received during restart"];
}

- (nullable NSString*)handleTaskPreparationResponse:(nonnull NSURLResponse *)response
- (nullable NSString *)handleTaskPreparationResponse:(nonnull NSURLResponse *)response
data:(nullable NSData *)data
receivedError:(nullable NSError *)receivedError
resultError:(NSError*_Nullable*_Nullable)resultError {
resultError:(NSError *_Nullable*_Nullable)resultError {
if (data) {
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data
options:0
Expand All @@ -236,7 +239,7 @@ - (nullable NSString*)handleTaskPreparationResponse:(nonnull NSURLResponse *)res
}
}

- (nullable NSError*)handleTaskExecutionResponse:(nonnull NSURLResponse *)response
- (nullable NSError *)handleTaskExecutionResponse:(nonnull NSURLResponse *)response
data:(nullable NSData *)data
receivedError:(nullable NSError *)receivedError {
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
Expand Down Expand Up @@ -265,7 +268,7 @@ - (nullable NSError*)handleTaskExecutionResponse:(nonnull NSURLResponse *)respon
return [IRIrohaContainer errorForMessage:@"Unexpected response received on try to run iroha daemon"];
}

- (nullable NSError*)handleStopResponse:(nonnull NSURLResponse *)response
- (nullable NSError *)handleStopResponse:(nonnull NSURLResponse *)response
data:(nullable NSData *)data
receivedError:(nullable NSError *)receivedError {
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
Expand Down Expand Up @@ -309,7 +312,7 @@ - (BOOL)checkConnectivity {
dispatch_semaphore_signal(semaphore);

return nil;
}).onError(^IRPromise * _Nullable(NSError* error) {
}).onError(^IRPromise * _Nullable(NSError * error) {
dispatch_semaphore_signal(semaphore);

return nil;
Expand All @@ -322,7 +325,7 @@ - (BOOL)checkConnectivity {

#pragma mark - Helper

+ (nonnull NSError *)errorForMessage:(nonnull NSString*)message {
+ (nonnull NSError *)errorForMessage:(nonnull NSString *)message {
NSString *domain = [NSString stringWithFormat:@"co.jp.soramitsu.iroha.%@", NSStringFromClass([IRIrohaContainer class])];
return [NSError errorWithDomain:domain
code:0
Expand Down
50 changes: 25 additions & 25 deletions IntegrationTests/Scenarious/IRAccountRestoreWithBatchTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

@interface IRAccountRestoreWithBatchTest : IRBaseIrohaContainerTests

@property(strong, nonatomic)id<IRRoleName> userRole;
@property(strong, nonatomic)id<IRDomain> bankDomain;
@property(strong, nonatomic)id<IRDomain> recoveryDomain;
@property(strong, nonatomic)id<IRAccountId> recoveryAccount;
@property(strong, nonatomic)id<IRCryptoKeypairProtocol> recoveryKeypair;
@property(strong, nonatomic)id<IRSignatureCreatorProtocol> recoverySigner;
@property(strong, nonatomic)id<IRAccountId> clientAccount;
@property(strong, nonatomic)id<IRCryptoKeypairProtocol> clientKeypair;
@property(strong, nonatomic)id<IRSignatureCreatorProtocol> clientSigner;
@property (strong, nonatomic) id<IRRoleName> userRole;
@property (strong, nonatomic) id<IRDomain> bankDomain;
@property (strong, nonatomic) id<IRDomain> recoveryDomain;
@property (strong, nonatomic) id<IRAccountId> recoveryAccount;
@property (strong, nonatomic) id<IRCryptoKeypairProtocol> recoveryKeypair;
@property (strong, nonatomic) id<IRSignatureCreatorProtocol> recoverySigner;
@property (strong, nonatomic) id<IRAccountId> clientAccount;
@property (strong, nonatomic) id<IRCryptoKeypairProtocol> clientKeypair;
@property (strong, nonatomic) id<IRSignatureCreatorProtocol> clientSigner;

@end

Expand All @@ -43,35 +43,35 @@ - (void)testAccountRestoreScenarioWithoutBatch {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [self createAccounts];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [self grandClientToRecoveryPermissions];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [self grandRecoveryToAdminPermissions];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [self setupRecoveryAccount];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
[expectation fulfill];

return nil;
}).onError(^IRPromise* _Nullable (NSError* error) {
}).onError(^IRPromise* _Nullable (NSError * error) {
XCTFail(@"%@", error);

[expectation fulfill];
Expand All @@ -85,27 +85,27 @@ - (void)testAccountRestoreScenarioWithoutBatch {
- (void)testAccountRestoreScenarioWithBatch {
XCTestExpectation *expectation = [[XCTestExpectation alloc] init];

[self createDomains].onThen(^IRPromise* _Nullable (id result) {
[self createDomains].onThen(^IRPromise * _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [self createAccounts];
}).onThen(^IRPromise* _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:result
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [self sendRecoverySetupBatch];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
return [IRRepeatableStatusStream onTransactionStatus:IRTransactionStatusCommitted
withHash:[result objectAtIndex:0]
from:self.iroha];
}).onThen(^IRPromise* _Nullable (id result) {
}).onThen(^IRPromise * _Nullable (id result) {
[expectation fulfill];

return nil;
}).onError(^IRPromise* _Nullable (NSError* error) {
}).onError(^IRPromise * _Nullable (NSError *error) {
XCTFail(@"%@", error);

[expectation fulfill];
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/Scenarious/IRCreateAccountTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ - (void)testCreateAccount {
[expectation fulfill];

return nil;
}).onError(^IRPromise * _Nullable(NSError* error) {
}).onError(^IRPromise * _Nullable(NSError * error) {
XCTFail();
NSLog(@"%@",error);

Expand Down
5 changes: 5 additions & 0 deletions IntegrationTests/Scenarious/IRCreateAssetTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ - (void)testCreateAddSubtractQueryAsset {
withHash:result
from:self.iroha];
}).onThen(^IRPromise * _Nullable (id result) {
NSLog(@"%@", result);
IRQueryBuilder *queryBuilder = [IRQueryBuilder builderWithCreatorAccountId:self.adminAccountId];
queryBuilder = [queryBuilder getAccountAssets:self.adminAccountId];

Expand All @@ -79,6 +80,7 @@ - (void)testCreateAddSubtractQueryAsset {

return [self.iroha executeQueryRequest:request];
}).onThen(^IRPromise * _Nullable (id result) {
NSLog(@"%@", result);
if ([result conformsToProtocol:@protocol(IRAccountAssetsResponse)]) {
id<IRAccountAssetsResponse> accountAssetsResult = result;

Expand Down Expand Up @@ -112,6 +114,7 @@ - (void)testCreateAddSubtractQueryAsset {
return [IRPromise promiseWithResult:error];
}
}).onThen(^IRPromise * _Nullable (id result) {
NSLog(@"%@", result);
IRQueryBuilder *queryBuilder = [IRQueryBuilder builderWithCreatorAccountId:self.adminAccountId];
queryBuilder = [queryBuilder getAssetInfo:assetId];

Expand All @@ -126,6 +129,7 @@ - (void)testCreateAddSubtractQueryAsset {

return [self.iroha executeQueryRequest:request];
}).onThen(^IRPromise * _Nullable (id result) {
NSLog(@"%@", result);
if ([result conformsToProtocol:@protocol(IRAssetResponse)]) {
id<IRAssetResponse> assetResponse = result;

Expand All @@ -142,6 +146,7 @@ - (void)testCreateAddSubtractQueryAsset {
return [IRPromise promiseWithResult:error];
}
}).onThen(^IRPromise * _Nullable (id result) {
NSLog(@"%@", result);
[expectation fulfill];
return nil;
}).onError(^IRPromise * _Nullable (NSError *error) {
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/Scenarious/IRCreateDomainTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (void)testCreateDomain {
}).onThen(^IRPromise * _Nullable(id result) {
[expectation fulfill];
return nil;
}).onError(^IRPromise * _Nullable(NSError* error) {
}).onError(^IRPromise * _Nullable(NSError * error) {
NSLog(@"%@", error);
XCTFail();

Expand Down
10 changes: 7 additions & 3 deletions IntegrationTests/Scenarious/IRCreateRoleTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ - (void)testCreateRoleRejected {
return;
}

NSArray<id<IRRolePermission>>* permissions = @[[IRRolePermissionFactory canAddSignatory],
NSArray<id<IRRolePermission>>* permissions = @[
[IRRolePermissionFactory canAddSignatory],
[IRRolePermissionFactory canRemoveSignatory],
[IRRolePermissionFactory canSetQuorum]];
[IRRolePermissionFactory canSetQuorum]
];

IRTransactionBuilder *transactionBuilder = [IRTransactionBuilder builderWithCreatorAccountId:self.adminAccountId];
transactionBuilder = [transactionBuilder createRole:role permissions:permissions];
Expand All @@ -35,6 +37,8 @@ - (void)testCreateRoleRejected {
XCTFail();
return;
}

NSLog(@"%@", [[transaction transactionHashWithError:nil] toHexString]);

XCTestExpectation *expectation = [[XCTestExpectation alloc] init];

Expand All @@ -59,7 +63,7 @@ - (void)testCreateRoleRejected {
[expectation fulfill];

return nil;
}).onError(^IRPromise* _Nullable (NSError* error) {
}).onError(^IRPromise* _Nullable (NSError * error) {
XCTFail();
NSLog(@"%@",error);

Expand Down
Loading

0 comments on commit 103622e

Please sign in to comment.