@@ -13,7 +13,6 @@ import {
13
13
DEFAULT_FABRIC_2_AIO_IMAGE_NAME ,
14
14
DEFAULT_FABRIC_2_AIO_IMAGE_VERSION ,
15
15
FabricTestLedgerV1 ,
16
- GoIpfsTestContainer ,
17
16
} from "@hyperledger/cactus-test-tooling" ;
18
17
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory" ;
19
18
import {
@@ -35,14 +34,15 @@ import {
35
34
InvokeContractV1Request as BesuInvokeContractV1Request ,
36
35
} from "@hyperledger/cactus-plugin-ledger-connector-besu" ;
37
36
import { PluginRegistry } from "@hyperledger/cactus-core" ;
38
- import { PluginObjectStoreIpfs } from "@hyperledger/cactus-plugin-object-store-ipfs" ;
39
37
import AssetReferenceContractJson from "../../../solidity/asset-reference-contract/AssetReferenceContract.json" ;
40
38
import CBDCcontractJson from "../../../solidity/cbdc-erc-20/CBDCcontract.json" ;
41
39
import { IKeyPair } from "@hyperledger/cactus-plugin-satp-hermes" ;
42
40
import { FabricSatpGateway } from "../satp-extension/fabric-satp-gateway" ;
43
41
import { BesuSatpGateway } from "../satp-extension/besu-satp-gateway" ;
44
42
import { PluginImportType } from "@hyperledger/cactus-core-api" ;
45
43
import CryptoMaterial from "../../../crypto-material/crypto-material.json" ;
44
+ import { ClientHelper } from "../satp-extension/client-helper" ;
45
+ import { ServerHelper } from "../satp-extension/server-helper" ;
46
46
47
47
export interface ICbdcBridgingAppDummyInfrastructureOptions {
48
48
logLevel ?: LogLevelDesc ;
@@ -56,9 +56,6 @@ export class CbdcBridgingAppDummyInfrastructure {
56
56
57
57
private readonly besu : BesuTestLedger ;
58
58
private readonly fabric : FabricTestLedgerV1 ;
59
- private readonly ipfs : GoIpfsTestContainer ;
60
- private readonly ipfsParentPath : string ;
61
-
62
59
private readonly log : Logger ;
63
60
64
61
public get className ( ) : string {
@@ -78,8 +75,6 @@ export class CbdcBridgingAppDummyInfrastructure {
78
75
const level = this . options . logLevel || "INFO" ;
79
76
const label = this . className ;
80
77
81
- this . ipfsParentPath = `/${ uuidv4 ( ) } /${ uuidv4 ( ) } /` ;
82
-
83
78
this . log = LoggerProvider . getOrCreate ( { level, label } ) ;
84
79
85
80
this . besu = new BesuTestLedger ( {
@@ -97,10 +92,6 @@ export class CbdcBridgingAppDummyInfrastructure {
97
92
] ) ,
98
93
logLevel : level || "DEBUG" ,
99
94
} ) ;
100
-
101
- this . ipfs = new GoIpfsTestContainer ( {
102
- logLevel : level || "DEBUG" ,
103
- } ) ;
104
95
}
105
96
106
97
public get org1Env ( ) : NodeJS . ProcessEnv & DeploymentTargetOrgFabric2x {
@@ -140,11 +131,7 @@ export class CbdcBridgingAppDummyInfrastructure {
140
131
public async start ( ) : Promise < void > {
141
132
try {
142
133
this . log . info ( `Starting dummy infrastructure...` ) ;
143
- await Promise . all ( [
144
- this . besu . start ( ) ,
145
- this . fabric . start ( ) ,
146
- this . ipfs . start ( ) ,
147
- ] ) ;
134
+ await Promise . all ( [ this . besu . start ( ) , this . fabric . start ( ) ] ) ;
148
135
this . log . info ( `Started dummy infrastructure OK` ) ;
149
136
} catch ( ex ) {
150
137
this . log . error ( `Starting of dummy infrastructure crashed: ` , ex ) ;
@@ -158,7 +145,6 @@ export class CbdcBridgingAppDummyInfrastructure {
158
145
await Promise . all ( [
159
146
this . besu . stop ( ) . then ( ( ) => this . besu . destroy ( ) ) ,
160
147
this . fabric . stop ( ) . then ( ( ) => this . fabric . destroy ( ) ) ,
161
- this . ipfs . stop ( ) . then ( ( ) => this . ipfs . destroy ( ) ) ,
162
148
] ) ;
163
149
this . log . info ( `Stopped OK` ) ;
164
150
} catch ( ex ) {
@@ -285,61 +271,43 @@ export class CbdcBridgingAppDummyInfrastructure {
285
271
return besuConnector ;
286
272
}
287
273
288
- public async createIPFSConnector ( ) : Promise < PluginObjectStoreIpfs > {
289
- this . log . info ( `Creating Besu Connector...` ) ;
290
-
291
- const kuboRpcClientModule = await import ( "kubo-rpc-client" ) ;
292
- const ipfsClientOrOptions = kuboRpcClientModule . create ( {
293
- url : await this . ipfs . getApiUrl ( ) ,
294
- } ) ;
295
-
296
- return new PluginObjectStoreIpfs ( {
297
- parentDir : this . ipfsParentPath ,
298
- logLevel : this . options . logLevel ,
299
- instanceId : uuidv4 ( ) ,
300
- ipfsClientOrOptions,
301
- } ) ;
302
- }
303
-
304
274
public async createClientGateway (
305
275
nodeApiHost : string ,
306
276
keyPair : IKeyPair ,
307
- ipfsPath : string ,
308
277
) : Promise < FabricSatpGateway > {
309
278
this . log . info ( `Creating Source Gateway...` ) ;
310
279
const pluginSourceGateway = new FabricSatpGateway ( {
311
280
name : "cactus-plugin-source#satpGateway" ,
312
281
dltIDs : [ "DLT2" ] ,
313
282
instanceId : uuidv4 ( ) ,
314
283
keyPair : keyPair ,
315
- ipfsPath : ipfsPath ,
316
284
fabricPath : nodeApiHost ,
317
285
fabricSigningCredential : {
318
286
keychainId : CryptoMaterial . keychains . keychain1 . id ,
319
287
keychainRef : "bridge" ,
320
288
} ,
321
289
fabricChannelName : "mychannel" ,
322
290
fabricContractName : "asset-reference-contract" ,
291
+ clientHelper : new ClientHelper ( ) ,
292
+ serverHelper : new ServerHelper ( { } ) ,
323
293
} ) ;
324
294
325
- await pluginSourceGateway . database ?. migrate . rollback ( ) ;
326
- await pluginSourceGateway . database ?. migrate . latest ( ) ;
295
+ await pluginSourceGateway . localRepository ?. reset ( ) ;
296
+ await pluginSourceGateway . remoteRepository ?. reset ( ) ;
327
297
328
298
return pluginSourceGateway ;
329
299
}
330
300
331
301
public async createServerGateway (
332
302
nodeApiHost : string ,
333
303
keyPair : IKeyPair ,
334
- ipfsPath : string ,
335
304
) : Promise < BesuSatpGateway > {
336
305
this . log . info ( `Creating Recipient Gateway...` ) ;
337
306
const pluginRecipientGateway = new BesuSatpGateway ( {
338
307
name : "cactus-plugin-recipient#satpGateway" ,
339
308
dltIDs : [ "DLT1" ] ,
340
309
instanceId : uuidv4 ( ) ,
341
310
keyPair : keyPair ,
342
- ipfsPath : ipfsPath ,
343
311
besuPath : nodeApiHost ,
344
312
besuWeb3SigningCredential : {
345
313
ethAccount : CryptoMaterial . accounts [ "bridge" ] . ethAddress ,
@@ -348,10 +316,12 @@ export class CbdcBridgingAppDummyInfrastructure {
348
316
} ,
349
317
besuContractName : AssetReferenceContractJson . contractName ,
350
318
besuKeychainId : CryptoMaterial . keychains . keychain2 . id ,
319
+ clientHelper : new ClientHelper ( ) ,
320
+ serverHelper : new ServerHelper ( { } ) ,
351
321
} ) ;
352
322
353
- await pluginRecipientGateway . database ?. migrate . rollback ( ) ;
354
- await pluginRecipientGateway . database ?. migrate . latest ( ) ;
323
+ await pluginRecipientGateway . localRepository ?. reset ( ) ;
324
+ await pluginRecipientGateway . remoteRepository ?. reset ( ) ;
355
325
356
326
return pluginRecipientGateway ;
357
327
}
@@ -624,19 +594,28 @@ export class CbdcBridgingAppDummyInfrastructure {
624
594
// does the same thing, it just waits 10 seconds for good measure so there
625
595
// might not be a way for us to avoid doing this, but if there is a way we
626
596
// absolutely should not have timeouts like this, anywhere...
627
- await new Promise ( ( resolve ) => setTimeout ( resolve , 10000 ) ) ;
628
-
629
- await fabricApiClient . runTransactionV1 ( {
630
- contractName,
631
- channelName,
632
- params : [ "name1" , "symbol1" , "8" ] ,
633
- methodName : "Initialize" ,
634
- invocationType : FabricContractInvocationType . Send ,
635
- signingCredential : {
636
- keychainId : CryptoMaterial . keychains . keychain1 . id ,
637
- keychainRef : "userA" ,
638
- } ,
639
- } ) ;
597
+ let retries_2 = 0 ;
598
+ while ( retries_2 <= 5 ) {
599
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 10000 ) ) ;
600
+
601
+ await fabricApiClient
602
+ . runTransactionV1 ( {
603
+ contractName,
604
+ channelName,
605
+ params : [ "name1" , "symbol1" , "8" ] ,
606
+ methodName : "Initialize" ,
607
+ invocationType : FabricContractInvocationType . Send ,
608
+ signingCredential : {
609
+ keychainId : CryptoMaterial . keychains . keychain1 . id ,
610
+ keychainRef : "userA" ,
611
+ } ,
612
+ } )
613
+ . then ( ( ) => ( retries_2 = 6 ) )
614
+ . catch ( ( ) =>
615
+ console . log ( "trying to Initialize fabric contract again" ) ,
616
+ ) ;
617
+ retries_2 ++ ;
618
+ }
640
619
} )
641
620
. catch ( ( ) => console . log ( "trying to deploy fabric contract again" ) ) ;
642
621
retries ++ ;
0 commit comments