Skip to content

Commit

Permalink
Merge pull request #111 from ERussel/feature/update-1.1-fix
Browse files Browse the repository at this point in the history
Support Iroha 1.1.0
  • Loading branch information
unklayman authored Sep 12, 2019
2 parents 1987d04 + 448fe78 commit ca2309d
Show file tree
Hide file tree
Showing 157 changed files with 2,018 additions and 581 deletions.
24 changes: 22 additions & 2 deletions Example/IrohaCommunication.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
844761F1224A5133009ADC0E /* IRQueryResponseDeserializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 844761F0224A5133009ADC0E /* IRQueryResponseDeserializationTests.m */; };
8481A59122FD48800056D3D4 /* IRAssetPaginationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8481A59022FD48800056D3D4 /* IRAssetPaginationTests.m */; };
84D693FB22EDCDB10059C1FB /* IRAccountRestoreWithBatchTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D693FA22EDCDB10059C1FB /* IRAccountRestoreWithBatchTest.m */; };
8BA6158423255099002C33D8 /* IRGetAccountDetailTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BA6158323255099002C33D8 /* IRGetAccountDetailTest.m */; };
8BB6C2BF23164E04009B7AEA /* IRAccountDetailPaginationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6C2BE23164E04009B7AEA /* IRAccountDetailPaginationTests.m */; };
8BF9E1DE2321976F00A1257A /* IRGetAssetsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BF9E1DD2321976F00A1257A /* IRGetAssetsTest.m */; };
8CA1A478927FFA33BA30A5B4 /* Pods_IntegrationTestHost.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 175938D8DE70C85E0CEA25AF /* Pods_IntegrationTestHost.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -159,6 +162,9 @@
84EA860F14455E442B5C9B29 /* IrohaCommunication.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = IrohaCommunication.podspec; path = ../IrohaCommunication.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
86F19532265991B547599707 /* Pods-IrohaExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IrohaExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-IrohaExample/Pods-IrohaExample.release.xcconfig"; sourceTree = "<group>"; };
872B4DCAED8E7A58AFC8B200 /* Pods_UnitTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_UnitTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8BA6158323255099002C33D8 /* IRGetAccountDetailTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IRGetAccountDetailTest.m; sourceTree = "<group>"; };
8BB6C2BE23164E04009B7AEA /* IRAccountDetailPaginationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IRAccountDetailPaginationTests.m; sourceTree = "<group>"; };
8BF9E1DD2321976F00A1257A /* IRGetAssetsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IRGetAssetsTest.m; sourceTree = "<group>"; };
9CA67C26A81EB59902096272 /* Pods_IntegrationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IntegrationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B877F0064619F03D2B560C12 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
BE1A149366A65576BDC46228 /* Pods-IntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IntegrationTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-IntegrationTests/Pods-IntegrationTests.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -226,6 +232,7 @@
0200347621C853E2001A6A53 /* IRRolePermissionTests.m */,
021C24AE21DCDDE3005D5304 /* IRPaginationTests.m */,
8481A59022FD48800056D3D4 /* IRAssetPaginationTests.m */,
8BB6C2BE23164E04009B7AEA /* IRAccountDetailPaginationTests.m */,
021C24EF21DDF706005D5304 /* IRAccountAssetTests.m */,
);
name = Model;
Expand Down Expand Up @@ -262,17 +269,19 @@
02D656A121F12DC300AAA66A /* IRCreateDomainTest.m */,
02D656BD21F19F6B00AAA66A /* IRCreateRoleTest.m */,
84D693FA22EDCDB10059C1FB /* IRAccountRestoreWithBatchTest.m */,
8BF9E1DD2321976F00A1257A /* IRGetAssetsTest.m */,
8BA6158323255099002C33D8 /* IRGetAccountDetailTest.m */,
);
path = Scenarious;
sourceTree = "<group>";
};
02D656A921F12DC300AAA66A /* IrohaContainer */ = {
isa = PBXGroup;
children = (
02D656AA21F12DC300AAA66A /* IRBaseIrohaContainerTests.m */,
02D656AB21F12DC300AAA66A /* IRIrohaContainer.m */,
02D656AC21F12DC300AAA66A /* IRBaseIrohaContainerTests.h */,
02D656AA21F12DC300AAA66A /* IRBaseIrohaContainerTests.m */,
02D656AD21F12DC300AAA66A /* IRIrohaContainer.h */,
02D656AB21F12DC300AAA66A /* IRIrohaContainer.m */,
);
path = IrohaContainer;
sourceTree = "<group>";
Expand Down Expand Up @@ -552,6 +561,7 @@
TargetAttributes = {
021C844621ED12B40037F633 = {
DevelopmentTeam = YLWWUD25VZ;
LastSwiftMigration = 1020;
TestTargetID = 02ED8DC121EE8DD80068AF05;
};
02E31A2321DC050E00B33B66 = {
Expand Down Expand Up @@ -794,8 +804,10 @@
buildActionMask = 2147483647;
files = (
02D656B821F12DC300AAA66A /* IRIrohaContainer.m in Sources */,
8BF9E1DE2321976F00A1257A /* IRGetAssetsTest.m in Sources */,
02D656B021F12DC300AAA66A /* IRCreateDomainTest.m in Sources */,
02D656BF21F19F7500AAA66A /* IRCreateRoleTest.m in Sources */,
8BA6158423255099002C33D8 /* IRGetAccountDetailTest.m in Sources */,
02D656B721F12DC300AAA66A /* IRBaseIrohaContainerTests.m in Sources */,
84D693FB22EDCDB10059C1FB /* IRAccountRestoreWithBatchTest.m in Sources */,
02D656AF21F12DC300AAA66A /* IRCreateAccountTest.m in Sources */,
Expand Down Expand Up @@ -838,6 +850,7 @@
021C24E821DD3C90005D5304 /* IRQueryBuilderTests.m in Sources */,
0200347721C853E2001A6A53 /* IRRolePermissionTests.m in Sources */,
021C24F021DDF706005D5304 /* IRAccountAssetTests.m in Sources */,
8BB6C2BF23164E04009B7AEA /* IRAccountDetailPaginationTests.m in Sources */,
0200345E21C62D3F001A6A53 /* IRDomainTests.m in Sources */,
021C843D21EA6E950037F633 /* IRBlockQueryBuilderTests.m in Sources */,
0200345F21C62D3F001A6A53 /* IRAccountIdTests.m in Sources */,
Expand Down Expand Up @@ -906,6 +919,7 @@
baseConfigurationReference = BE1A149366A65576BDC46228 /* Pods-IntegrationTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = YLWWUD25VZ;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -919,8 +933,11 @@
);
INFOPLIST_FILE = "IntegrationTests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/IntegrationTestHost.app/IntegrationTestHost";
WRAPPER_EXTENSION = xctest;
};
Expand All @@ -931,6 +948,7 @@
baseConfigurationReference = 55D980CEB7E9C5BA9DA95FC2 /* Pods-IntegrationTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = YLWWUD25VZ;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -940,8 +958,10 @@
GCC_PREFIX_HEADER = "Tests/Tests-Prefix.pch";
INFOPLIST_FILE = "IntegrationTests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/IntegrationTestHost.app/IntegrationTestHost";
WRAPPER_EXTENSION = xctest;
};
Expand Down
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
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
Loading

0 comments on commit ca2309d

Please sign in to comment.