-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1003 from golemfactory/bugfix/JST-1011/demand-ref…
…reshing-with-wrong-expiration fix(market): fixed demand refresh logic that produced unusable counte…
- Loading branch information
Showing
20 changed files
with
246 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ const demand = new Demand( | |
properties: [], | ||
}, | ||
"erc20-holesky-tglm", | ||
30 * 60, | ||
), | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
src/market/demand/directors/basic-demand-director-config.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { BasicDemandDirectorConfig } from "./basic-demand-director-config"; | ||
|
||
describe("BasicDemandDirectorConfig", () => { | ||
test("should throw user error if expiration option is invalid", () => { | ||
expect(() => { | ||
new BasicDemandDirectorConfig({ | ||
expirationSec: -3, | ||
subnetTag: "public", | ||
}); | ||
}).toThrow("The demand expiration time has to be a positive integer"); | ||
test("it sets the subnet tag property", () => { | ||
const config = new BasicDemandDirectorConfig({ | ||
subnetTag: "public", | ||
}); | ||
|
||
expect(config.subnetTag).toBe("public"); | ||
}); | ||
}); |
11 changes: 1 addition & 10 deletions
11
src/market/demand/directors/basic-demand-director-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
import { BaseConfig } from "./base-config"; | ||
import { GolemConfigError } from "../../../shared/error/golem-error"; | ||
import * as EnvUtils from "../../../shared/utils/env"; | ||
|
||
export interface BasicDemandDirectorConfigOptions { | ||
expirationSec: number; | ||
/** Determines which subnet tag should be used for the offer/demand matching */ | ||
subnetTag: string; | ||
} | ||
|
||
export class BasicDemandDirectorConfig extends BaseConfig implements BasicDemandDirectorConfigOptions { | ||
public readonly expirationSec = 30 * 60; // 30 minutes | ||
public readonly subnetTag: string = EnvUtils.getYagnaSubnet(); | ||
|
||
constructor(options?: Partial<BasicDemandDirectorConfigOptions>) { | ||
super(); | ||
|
||
if (options?.expirationSec) { | ||
this.expirationSec = options.expirationSec; | ||
} | ||
if (options?.subnetTag) { | ||
this.subnetTag = options.subnetTag; | ||
} | ||
|
||
if (!this.isPositiveInt(this.expirationSec)) { | ||
throw new GolemConfigError("The demand expiration time has to be a positive integer"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.