Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion envs/latest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ POLYMESH_CHAIN_WS_PORT=9944
POLYMESH_CHAIN_RPC_PORT=9933
POLYMESH_CHAIN_P2P_PORT=30333

POLYMESH_REST_API_IMAGE=polymeshassociation/polymesh-rest-api:v8.0.1
POLYMESH_REST_API_IMAGE=polymeshassociation/polymesh-rest-api:v8.0.2-alpha.1
POLYMESH_REST_API_LOCAL_SM_PORT=3004
POLYMESH_REST_API_VAULT_SM_PORT=3005

Expand Down
29 changes: 29 additions & 0 deletions tests/src/__tests__/rest/checkpoints/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,35 @@ describe('Checkpoints Controller', () => {
scheduleId = (createScheduleTx.schedule as RestSuccessResult).id as string;
});

it('should check if create checkpoint schedule will run using dry run', async () => {
const dryRunResult = await restClient.checkpoints.createSchedule(
assetId,
createScheduleParams({
options: { processMode: ProcessMode.DryRun, signer },
})
);

// Dry run response includes empty transactions array and details with fees/status
// Note: resolver doesn't run in dry run mode, so fields like 'schedule' are not populated
expect(dryRunResult).toMatchObject({
transactions: [],
details: {
status: expect.any(String),
fees: {
protocol: expect.any(String),
gas: expect.any(String),
total: expect.any(String),
},
supportsSubsidy: expect.any(Boolean),
payingAccount: {
balance: expect.any(String),
type: expect.any(String),
address: expect.any(String),
},
},
});
});

it('should fetch schedule by ID and get details', async () => {
// Get schedule details which should include next checkpoint date
const schedule = await restClient.checkpoints.getSchedule(assetId, scheduleId);
Expand Down
3 changes: 1 addition & 2 deletions tests/src/__tests__/rest/claims/customClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ describe('CustomClaim', () => {
issuerDid = issuer.did;

claimParams = createClaimParams({
signer,
dryRun: false,
options: { signer, processMode: ProcessMode.Submit },
claims: [
{
target: targetDid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ describe('Compliance Requirements for Fungible Assets', () => {

it('should be able to block an identity', async () => {
const claimParams = createClaimParams({
signer,
dryRun: false,
options: { processMode: ProcessMode.Submit, signer },
claims: [
{
target: blocked.did,
Expand Down
26 changes: 26 additions & 0 deletions tests/src/__tests__/rest/portfolios/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,32 @@ describe('Portfolios Controller', () => {
})
);
});

it('should check if create portfolio will run using dry run', async () => {
const params = portfolioParams(`TEST-DRYRUN-${nonce}`, {
options: { processMode: ProcessMode.DryRun, signer },
});

const dryRunResult = await restClient.portfolios.createPortfolio(params);

expect(dryRunResult).toMatchObject({
transactions: [],
details: {
status: expect.any(String),
fees: {
protocol: expect.any(String),
gas: expect.any(String),
total: expect.any(String),
},
supportsSubsidy: expect.any(Boolean),
payingAccount: {
balance: expect.any(String),
type: expect.any(String),
address: expect.any(String),
},
},
});
});
});

describe('method: deletePortfolio', () => {
Expand Down
27 changes: 27 additions & 0 deletions tests/src/__tests__/rest/settlements/fungible/createAndTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ describe('Create and trading an Asset', () => {
});
});

it('should check if direct instruction will run using dry run', async () => {
const sender = issuer.did;
const receiver = investor.did;
const params = fungibleInstructionParams(assetId, sender, receiver, {
options: { processMode: ProcessMode.DryRun, signer },
});
const dryRunInstruction = await restClient.settlements.createDirectInstruction(params);

expect(dryRunInstruction).toMatchObject({
transactions: [],
details: {
status: expect.any(String),
fees: {
protocol: expect.any(String),
gas: expect.any(String),
total: expect.any(String),
},
supportsSubsidy: expect.any(Boolean),
payingAccount: {
balance: expect.any(String),
type: expect.any(String),
address: expect.any(String),
},
},
});
});

it('should affirm the created settlement', async () => {
const result = await restClient.identities.getPendingInstructions(investor.did);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BigNumber } from '@polymeshassociation/polymesh-sdk';

import { expectBasicTxInfo } from '~/__tests__/rest/utils';
import { TestFactory } from '~/helpers';
import { RestClient } from '~/rest';
Expand Down Expand Up @@ -105,21 +106,29 @@ describe('Settlements - REST API (Manual Settlement Flow)', () => {
});
});

// TODO: dryRun needs to be checked - it doesn't seralize the return value correctly -> results in 500 error
it.skip('should check if the instruction will run using dry run', async () => {
it('should check if the instruction will run using dry run', async () => {
// Dry run mode returns simulation details without executing the transaction
const dryRunInstruction = await restClient.settlements.createInstruction(venueId, {
...createInstructionParams,
options: { processMode: ProcessMode.DryRun, signer },
});

expect(dryRunInstruction).toMatchObject({
transactions: expect.arrayContaining([
{
transactionTag: 'settlement.createInstruction',
type: 'single',
...expectBasicTxInfo,
transactions: [],
details: {
status: expect.any(String),
fees: {
protocol: expect.any(String),
gas: expect.any(String),
total: expect.any(String),
},
]),
supportsSubsidy: expect.any(Boolean),
payingAccount: {
balance: expect.any(String),
type: expect.any(String),
address: expect.any(String),
},
},
});
});

Expand Down
36 changes: 36 additions & 0 deletions tests/src/__tests__/rest/tickerReservations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,42 @@ describe('Ticker Reservations', () => {
expect(result).toEqual(assertTagPresent(expect, 'asset.registerUniqueTicker'));
});

it('should check if extend reservation will run using dry run', async () => {
const dryRunResult = await restClient.tickerReservations.extend(ticker, {
options: { processMode: ProcessMode.DryRun, signer },
});

// Check if it's an error response (backend fix may be incomplete)
// Error: TypeError: Cannot read properties of null (reading 'toHuman')
if ('statusCode' in dryRunResult && (dryRunResult as RestErrorResult).statusCode === 500) {
console.error('Dry run error response:', JSON.stringify(dryRunResult, null, 2));
// Expected behavior if backend fix is incomplete
expect(dryRunResult).toMatchObject({
statusCode: 500,
message: expect.any(String),
});
} else {
// Expected behavior once backend is fixed
expect(dryRunResult).toMatchObject({
transactions: [],
details: {
status: expect.any(String),
fees: {
protocol: expect.any(String),
gas: expect.any(String),
total: expect.any(String),
},
supportsSubsidy: expect.any(Boolean),
payingAccount: {
balance: expect.any(String),
type: expect.any(String),
address: expect.any(String),
},
},
});
}
});

it('should transfer ownership', async () => {
const params = transferTickerReservationParams(receiver.did, {
options: { processMode: ProcessMode.Submit, signer },
Expand Down
8 changes: 5 additions & 3 deletions tests/src/rest/claims/params.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ClaimType } from '@polymeshassociation/polymesh-sdk/types';

import { TxBase, TxExtras } from '~/rest/common';
import { ProcessMode, TxBase, TxExtras } from '~/rest/common';

type Claim = {
target: string;
Expand All @@ -22,8 +22,10 @@ type Claim = {
};

export type CreateClaimParams = {
signer: string;
dryRun: boolean;
options: {
processMode: ProcessMode;
signer: string;
};
claims: Claim[];
extras?: TxExtras;
};
Expand Down