Skip to content

Commit 4b891f7

Browse files
committed
Update listActions2 to run without leaking async
1 parent 65f550b commit 4b891f7

File tree

2 files changed

+140
-178
lines changed

2 files changed

+140
-178
lines changed

test/utils/TestUtilsWalletStorage.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,19 @@ export abstract class TestUtilsWalletStorage {
438438
})
439439
}
440440

441+
static async createMySQLTestSetup2Wallet(args: {
442+
databaseName: string
443+
mockData: MockData
444+
chain?: sdk.Chain
445+
rootKeyHex?: string
446+
}): Promise<TestWallet<TestSetup2>> {
447+
return await this.createKnexTestSetup2Wallet({
448+
...args,
449+
dropAll: true,
450+
knex: _tu.createLocalMySQL(args.databaseName)
451+
})
452+
}
453+
441454
static async createSQLiteTestWallet(args: {
442455
filePath?: string
443456
databaseName: string
@@ -475,6 +488,7 @@ export abstract class TestUtilsWalletStorage {
475488

476489
static async createSQLiteTestSetup2Wallet(args: {
477490
databaseName: string
491+
mockData: MockData
478492
chain?: sdk.Chain
479493
rootKeyHex?: string
480494
}): Promise<TestWallet<TestSetup2>> {
@@ -521,13 +535,14 @@ export abstract class TestUtilsWalletStorage {
521535
static async createKnexTestSetup2Wallet(args: {
522536
knex: Knex<any, any[]>
523537
databaseName: string
538+
mockData: MockData
524539
chain?: sdk.Chain
525540
rootKeyHex?: string
526541
dropAll?: boolean
527542
}): Promise<TestWallet<TestSetup2>> {
528543
return await _tu.createKnexTestWalletWithSetup({
529544
...args,
530-
insertSetup: _tu.createTestSetup2
545+
insertSetup: async (storage: StorageKnex, identityKey: string) => { return _tu.createTestSetup2(storage, identityKey, args.mockData) }
531546
})
532547
}
533548

@@ -1145,7 +1160,7 @@ export abstract class TestUtilsWalletStorage {
11451160

11461161
static async createTestSetup2(
11471162
storage: StorageProvider,
1148-
u1IdentityKey: string,
1163+
identityKey: string,
11491164
mockData: MockData = { actions: [] }
11501165
): Promise<TestSetup2> {
11511166
if (!mockData || !mockData.actions) {
@@ -1157,7 +1172,7 @@ export abstract class TestUtilsWalletStorage {
11571172
const outputMap: Record<string, any> = {}
11581173

11591174
// only one user
1160-
const user = await _tu.insertTestUser(storage, u1IdentityKey)
1175+
const user = await _tu.insertTestUser(storage, identityKey)
11611176

11621177
// First create your output that represent your inputs
11631178
for (const action of mockData.actions) {
@@ -1328,7 +1343,7 @@ export abstract class TestUtilsWalletStorage {
13281343
}
13291344
}
13301345

1331-
return {}
1346+
return mockData
13321347
}
13331348

13341349
static mockPostServicesAsSuccess(ctxs: TestWalletOnly[]): void {
@@ -1411,7 +1426,7 @@ export interface MockData {
14111426
actions: WalletAction[]
14121427
}
14131428

1414-
export interface TestSetup2 {}
1429+
export interface TestSetup2 extends MockData {}
14151430

14161431
export interface TestWallet<T> extends TestWalletOnly {
14171432
activeStorage: StorageKnex
@@ -1446,6 +1461,7 @@ async function insertEmptySetup(
14461461
return {}
14471462
}
14481463

1464+
export type TestSetup2Wallet = TestWallet<TestSetup2>
14491465
export type TestSetup1Wallet = TestWallet<TestSetup1>
14501466
export type TestWalletNoSetup = TestWallet<{}>
14511467

0 commit comments

Comments
 (0)