-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: sharding tests refactor (#1883)
* sharding tests refactor * small fixes * adjust clusterID based on version * fix typo * fix dispatchEvent test * sharding unit tests * port adjustment * update unit tests * fix 1902 * adjust content topic tests * adjust metdata tests * small adjustments * fix * update resolveAutoshardingCluster version * skip autosharding tests for nwaku < 0.27.0 * skip autosharding tests for nwaku < 0.27.0
- Loading branch information
Showing
20 changed files
with
1,236 additions
and
242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Logger } from "@waku/utils"; | ||
|
||
import { DOCKER_IMAGE_NAME } from "../lib/service_node"; | ||
|
||
const log = new Logger("test:utils"); | ||
|
||
// Utility to add test conditions based on nwaku/go-waku versions | ||
export function isNwakuAtLeast(requiredVersion: string): boolean { | ||
const versionRegex = /(?:v)?(\d+\.\d+(?:\.\d+)?)/; | ||
const match = DOCKER_IMAGE_NAME.match(versionRegex); | ||
|
||
if (match) { | ||
const version = match[0].substring(1); // Remove the 'v' prefix | ||
return ( | ||
version.localeCompare(requiredVersion, undefined, { numeric: true }) >= 0 | ||
); | ||
} else { | ||
// If there is no match we assume that it's a version close to master so we return True | ||
return true; | ||
} | ||
} | ||
|
||
// Utility to resolve autosharding cluster ID | ||
export function resolveAutoshardingCluster(clusterId: number): number { | ||
if (isNwakuAtLeast("0.27.0")) { | ||
log.info(`Using clusterID ${clusterId} for autosharding`); | ||
return clusterId; | ||
} else { | ||
// for versions older than 0.27.0 the autosharding cluster was hardcoded to 1 | ||
// https://github.com/waku-org/nwaku/pull/2505 | ||
log.warn("Falling back to clusterID 1 for autosharding"); | ||
return 1; | ||
} | ||
} |
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
Oops, something went wrong.