Skip to content

Commit

Permalink
Merge pull request #958 from golemfactory/feature/JST-939/remove-hidd…
Browse files Browse the repository at this point in the history
…en-and-deprecated-elements

Remove hidden and deprecated elements
  • Loading branch information
mgordel authored Jun 6, 2024
2 parents b12d85d + eb3ba12 commit 9503c49
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 158 deletions.
10 changes: 0 additions & 10 deletions src/activity/activity.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
import { Logger } from "../shared/utils";
import { Agreement, ProviderInfo } from "../market/agreement";
import { EventEmitter } from "eventemitter3";
import { ExecutionOptions, ExeScriptExecutor } from "./exe-script-executor";
import { IActivityApi } from "./types";

/** @deprecated */
export interface ActivityEvents {
scriptSent: (details: { activityId: string; agreementId: string }) => void;
scriptExecuted: (details: { activityId: string; agreementId: string; success: boolean }) => void;
destroyed: (details: { id: string; agreementId: string }) => void;
}

export enum ActivityStateEnum {
New = "New",
Initialized = "Initialized",
Expand Down Expand Up @@ -38,8 +30,6 @@ export interface IActivityRepository {
* As part of a given activity, it is possible to execute exe script commands and capture their results.
*/
export class Activity {
public readonly events = new EventEmitter<ActivityEvents>();

/**
* @param id The ID of the activity in Yagna
* @param agreement The agreement that's related to this activity
Expand Down
22 changes: 0 additions & 22 deletions src/activity/script/command.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { ActivityApi } from "ya-ts-client";
import { StorageProvider } from "../../shared/storage";

// importing from '../activity' makes Result undefined
// this is likely due to some circular dependency
// temporarily importing from '../activity/results' to fix the issue
import { Result } from "../results";

const EMPTY_ERROR_RESULT = new Result({
Expand Down Expand Up @@ -63,18 +59,12 @@ export class Command<T = unknown> {
}
}

/**
* @hidden
*/
export class Deploy extends Command {
constructor(args?: Record<string, unknown>) {
super("deploy", args);
}
}

/**
* @hidden
*/
export class Start extends Command {
constructor(args?: Record<string, unknown>) {
super("start", args);
Expand All @@ -94,9 +84,6 @@ type CapturePart = { head: number } | { tail: number } | { headTail: number };

type CaptureFormat = "string" | "binary";

/**
* @hidden
*/
export class Run extends Command {
constructor(cmd: string, args?: string[] | null, env?: object | null, capture?: Capture) {
const captureOpt = capture || {
Expand All @@ -118,9 +105,6 @@ export class Terminate extends Command {
}
}

/**
* @hidden
*/
export class Transfer<T = unknown> extends Command<T> {
constructor(
protected from?: string,
Expand All @@ -131,9 +115,6 @@ export class Transfer<T = unknown> extends Command<T> {
}
}

/**
* @hidden
*/
export class UploadFile extends Transfer {
constructor(
private storageProvider: StorageProvider,
Expand Down Expand Up @@ -177,9 +158,6 @@ export class UploadData extends Transfer {
}
}

/**
* @hidden
*/
export class DownloadFile extends Transfer {
constructor(
private storageProvider: StorageProvider,
Expand Down
13 changes: 0 additions & 13 deletions src/activity/work/work.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,6 @@ export class WorkContext {
return this.runOneCommand(run, runOptions);
}

/** @deprecated Use {@link WorkContext.runAndStream} instead */
async spawn(commandLine: string, options?: Omit<CommandOptions, "capture">): Promise<RemoteProcess>;
/** @deprecated Use {@link WorkContext.runAndStream} instead */
async spawn(executable: string, args: string[], options?: CommandOptions): Promise<RemoteProcess>;
/** @deprecated Use {@link WorkContext.runAndStream} instead */
async spawn(exeOrCmd: string, argsOrOptions?: string[] | CommandOptions, options?: CommandOptions) {
if (Array.isArray(argsOrOptions)) {
return this.runAndStream(exeOrCmd, argsOrOptions, options);
} else {
return this.runAndStream(exeOrCmd, options);
}
}

/**
* Run an executable on provider and return {@link RemoteProcess} that will allow streaming
* that contain stdout and stderr as Readable
Expand Down
6 changes: 0 additions & 6 deletions src/payment/rejection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @hidden
*/
export enum RejectionReason {
UnsolicitedService = "UNSOLICITED_SERVICE",
BadService = "BAD_SERVICE",
Expand All @@ -15,9 +12,6 @@ export enum RejectionReason {
AgreementFinalized = "AGREEMENT_FINALIZED",
}

/**
* @hidden
*/
export interface Rejection {
rejectionReason: RejectionReason;
totalAmountAccepted: string;
Expand Down
87 changes: 0 additions & 87 deletions tests/mock/utils/logger.ts

This file was deleted.

9 changes: 1 addition & 8 deletions tests/unit/allocation.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { Allocation, GolemConfigError, GolemPaymentError, PaymentErrorCode, YagnaApi } from "../../src";
import { AllocationOptions } from "../../src/payment/allocation";
import { LoggerMock } from "../mock/utils/logger";
import { Allocation, GolemConfigError, YagnaApi } from "../../src";
import { anything, imock, instance, mock, reset, when } from "@johanblumenberg/ts-mockito";
import { PaymentApi } from "ya-ts-client";

const logger = new LoggerMock();
const account = { address: "test_address", platform: "test_platform" };

const mockYagna = mock(YagnaApi);
const mockPayment = mock(PaymentApi.RequestorService);
const mockAllocation = imock<PaymentApi.AllocationDTO>();

describe("Allocation", () => {
beforeEach(() => {
logger.clear();

reset(mockYagna);
reset(mockPayment);
reset(mockAllocation);
Expand Down
19 changes: 7 additions & 12 deletions tests/unit/ws-browser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { GolemInternalError, nullLogger, WebSocketBrowserStorageProvider, YagnaApi } from "../../src";
import { GolemInternalError, Logger, nullLogger, WebSocketBrowserStorageProvider, YagnaApi } from "../../src";
// .js added for ESM compatibility
import { encode, toObject } from "flatbuffers/js/flexbuffers.js";
import * as jsSha3 from "js-sha3";
import { TEST_IDENTITY } from "../fixtures";
import { GsbApi, IdentityApi } from "ya-ts-client";
import { LoggerMock } from "../mock/utils/logger";
import { anything, instance, mock, reset, resetCalls, verify, when } from "@johanblumenberg/ts-mockito";
import { anything, imock, instance, mock, reset, resetCalls, verify, when } from "@johanblumenberg/ts-mockito";

jest.mock("uuid", () => ({ v4: () => "uuid" }));

Expand All @@ -14,27 +13,25 @@ type UploadChunkChunk = { offset: number; content: Uint8Array };
const mockYagna = mock(YagnaApi);
const mockIdentity = mock(IdentityApi.DefaultService);
const mockGsb = mock(GsbApi.RequestorService);

const logger = imock<Logger>();
const yagnaApi = instance(mockYagna);

describe("WebSocketBrowserStorageProvider", () => {
let logger: LoggerMock;

const createProvider = () =>
new WebSocketBrowserStorageProvider(yagnaApi, {
logger,
logger: instance(logger),
});
let provider: WebSocketBrowserStorageProvider;

beforeEach(() => {
logger = new LoggerMock();
provider = createProvider();

jest.clearAllMocks();

reset(mockYagna);
reset(mockIdentity);
reset(mockGsb);
reset(logger);

when(mockYagna.yagnaOptions).thenReturn({
apiKey: "example-api-key",
Expand Down Expand Up @@ -157,7 +154,7 @@ describe("WebSocketBrowserStorageProvider", () => {
expect(spy1).toHaveBeenCalled();
});

it("should log invalid requests", async () => {
it("should not respond to invalid requests", async () => {
const data = {
id: "foo",
component: "Foo",
Expand All @@ -167,7 +164,6 @@ describe("WebSocketBrowserStorageProvider", () => {
const spy1 = jest.spyOn(provider as any, "respond").mockReturnThis();
socket.dispatchEvent(new MessageEvent("message", { data: encode(data).buffer }));
expect(spy1).not.toHaveBeenCalled();
await logger.expectToInclude("[WebSocketBrowserStorageProvider] Unsupported message in publishData(): Foo");
});
});
});
Expand Down Expand Up @@ -247,7 +243,7 @@ describe("WebSocketBrowserStorageProvider", () => {
expect(callback).toHaveBeenCalledWith(result);
});

it("should log invalid requests", async () => {
it("should not respond to invalid requests", async () => {
const callback = jest.fn();
const data = {
id: "foo",
Expand All @@ -260,7 +256,6 @@ describe("WebSocketBrowserStorageProvider", () => {
socket.dispatchEvent(new MessageEvent("message", { data: encode(data).buffer }));
expect(spy1).not.toHaveBeenCalled();
expect(spy2).not.toHaveBeenCalled();
await logger.expectToInclude("[WebSocketBrowserStorageProvider] Unsupported message in receiveData(): Foo");
});
});
});
Expand Down

0 comments on commit 9503c49

Please sign in to comment.