Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit a4a9c44

Browse files
fix: 🐛 cleanup all skipped tests
1 parent 28cec1e commit a4a9c44

File tree

6 files changed

+52
-23
lines changed

6 files changed

+52
-23
lines changed

envs/7.0.0.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CHAIN_IMAGE=polymeshassociation/polymesh:latest-develop-debian
2-
SUBQUERY_INDEXER_IMAGE=polymeshassociation/polymesh-subquery:v18.0.2-alpha.3
2+
SUBQUERY_INDEXER_IMAGE=polymeshassociation/polymesh-subquery:v18.0.2-alpha.4
33

44
SUBQUERY_QUERY_IMAGE=onfinality/subql-query:v2.11.0
55
REST_IMAGE=polymeshassociation/polymesh-rest-api:v7.0.0-alpha.5

src/__tests__/rest/compliance/fungible/tradeWithCompliance.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { ProcessMode, TxBase } from '~/rest/common';
99
import { blockedIdentityRequirements, complianceRequirementsParams } from '~/rest/compliance';
1010
import { Identity } from '~/rest/identities/interfaces';
1111
import { fungibleInstructionParams, venueParams } from '~/rest/settlements/params';
12+
import { awaitMiddlewareSyncedForRestApi } from '~/util';
1213

1314
const handles = ['issuer', 'blocked', 'investor'];
1415
let factory: TestFactory;
@@ -189,6 +190,9 @@ describe('Compliance Requirements for Fungible Assets', () => {
189190
expect(blockedReceiverInstruction).toEqual(
190191
assertTagPresent(expect, 'settlement.addAndAffirmWithMediators')
191192
);
193+
194+
await awaitMiddlewareSyncedForRestApi(investorInstruction, restClient);
195+
await awaitMiddlewareSyncedForRestApi(blockedReceiverInstruction, restClient);
192196
});
193197

194198
it('should be able to call affirm on instruction for both receivers', async () => {
@@ -249,8 +253,7 @@ describe('Compliance Requirements for Fungible Assets', () => {
249253
);
250254
});
251255

252-
// Failing due to historical settlements
253-
it.skip('should have affirmed the instruction for investor', async () => {
256+
it('should have affirmed the instruction for investor', async () => {
254257
const instruction = await restClient.settlements.getInstruction(investorInstructionId);
255258

256259
expect(instruction).toEqual(
@@ -260,8 +263,7 @@ describe('Compliance Requirements for Fungible Assets', () => {
260263
);
261264
});
262265

263-
// Failing due to historical settlements
264-
it.skip('should have failed the instruction for blocked did', async () => {
266+
it('should have failed the instruction for blocked did', async () => {
265267
const instruction = await restClient.settlements.getInstruction(blockedInstructionId);
266268

267269
expect(instruction).toEqual(

src/__tests__/rest/portfolios/transfers.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createAssetParams } from '~/rest/assets/params';
77
import { ProcessMode, TxBase } from '~/rest/common';
88
import { Identity } from '~/rest/identities/interfaces';
99
import { moveAssetParams, portfolioParams, setCustodianParams } from '~/rest/portfolios';
10-
import { randomNonce } from '~/util';
10+
import { awaitMiddlewareSyncedForRestApi, randomNonce } from '~/util';
1111

1212
const handles = ['issuer', 'custodian'];
1313
let factory: TestFactory;
@@ -128,6 +128,8 @@ describe('Portfolio Asset Transfers', () => {
128128

129129
expect(result).toEqual(assertTagPresent(expect, 'portfolio.movePortfolioFunds'));
130130

131+
await awaitMiddlewareSyncedForRestApi(result, restClient);
132+
131133
const portfolio = await restClient.portfolios.getPortfolio(issuer.did, custodyPortfolioId);
132134

133135
expect(portfolio).toEqual(
@@ -148,23 +150,40 @@ describe('Portfolio Asset Transfers', () => {
148150
);
149151
});
150152

151-
// TODO: this throws an internal server error "Error: Error in middleware V2 query: more than one row returned by a subquery used as an expression"
152-
it.skip("should have created transaction history for the asset's transfer", async () => {
153+
it("should have created transaction history for the asset's transfer", async () => {
153154
const result = await restClient.portfolios.getTransactionHistory(issuer.did, '0');
154155

155156
expect(result.results).toEqual(
156157
expect.arrayContaining([
157158
expect.objectContaining({
158-
asset: assetId,
159-
amount: '1000',
160-
from: custodyPortfolioId,
161-
to: '0',
159+
legs: [
160+
expect.objectContaining({
161+
asset: assetId,
162+
amount: '1000',
163+
from: {
164+
did: issuer.did,
165+
},
166+
to: {
167+
did: issuer.did,
168+
id: '1',
169+
},
170+
}),
171+
],
162172
}),
163173
expect.objectContaining({
164-
asset: assetId,
165-
amount: '1000',
166-
from: '0',
167-
to: custodyPortfolioId,
174+
legs: [
175+
expect.objectContaining({
176+
asset: assetId,
177+
amount: '1000',
178+
from: {
179+
did: issuer.did,
180+
id: '1',
181+
},
182+
to: {
183+
did: issuer.did,
184+
},
185+
}),
186+
],
168187
}),
169188
])
170189
);
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { Polymesh } from '@polymeshassociation/polymesh-sdk';
2+
import { FungibleAsset } from '@polymeshassociation/polymesh-sdk/types';
23

34
import { TestFactory } from '~/helpers';
45
import { Identity } from '~/rest/identities';
6+
import { createAsset } from '~/sdk/assets/createAsset';
57
import { manageClaims } from '~/sdk/identities/claims';
68

79
let factory: TestFactory;
@@ -10,19 +12,21 @@ const handles = ['claimTarget'];
1012
describe('manageClaims', () => {
1113
let sdk: Polymesh;
1214
let targetIdentity: Identity;
15+
let asset: FungibleAsset;
1316

1417
beforeAll(async () => {
1518
factory = await TestFactory.create({ handles });
1619
targetIdentity = factory.getSignerIdentity(handles[0]);
1720
sdk = factory.polymeshSdk;
21+
22+
asset = await createAsset(sdk, {});
1823
});
1924

2025
afterAll(async () => {
2126
await factory.close();
2227
});
2328

24-
// TODO, this case can be flakey
25-
it.skip('should execute manageClaims without errors', async () => {
26-
await expect(manageClaims(sdk, targetIdentity.did)).resolves.not.toThrow();
29+
it('should execute manageClaims without errors', async () => {
30+
await expect(manageClaims(sdk, targetIdentity.did, asset.id)).resolves.not.toThrow();
2731
});
2832
});

src/sdk/identities/claims.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import assert from 'node:assert';
1212
- Get claims targeting a given Identity
1313
- Get claims issued by given Identity
1414
*/
15-
export const manageClaims = async (sdk: Polymesh, targetDid: string): Promise<void> => {
15+
export const manageClaims = async (
16+
sdk: Polymesh,
17+
targetDid: string,
18+
assetId: string
19+
): Promise<void> => {
1620
const identity = await sdk.getSigningIdentity();
1721
assert(identity);
1822

@@ -27,8 +31,8 @@ export const manageClaims = async (sdk: Polymesh, targetDid: string): Promise<vo
2731
claim: {
2832
type: ClaimType.Accredited,
2933
scope: {
30-
type: ScopeType.Ticker,
31-
value: 'TICKER',
34+
type: ScopeType.Asset,
35+
value: assetId,
3236
},
3337
},
3438
},

src/sdk/identities/portfolios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const managePortfolios = async (sdk: Polymesh, asset: FungibleAsset): Pro
5454
assert(transferTx.isSuccess);
5555

5656
const customPortfolioBalanceAfter = await examplePortfolio.getAssetBalances({
57-
assets: [asset.id, 'TOKEN_2', 'TOKEN_3'],
57+
assets: [asset.id],
5858
});
5959

6060
const [{ total: tokensInCustomPortfolio }] = customPortfolioBalanceAfter;

0 commit comments

Comments
 (0)