-
Notifications
You must be signed in to change notification settings - Fork 87
feat(provider): align attributes schema with audit requirements #3284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Zblocker64
wants to merge
8
commits into
main
Choose a base branch
from
feat/provider-attributes-audit-schema
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ef530d5
feat(provider): align attributes schema with audit requirements
Zblocker64 2506e94
fix(provider): load local attributes schema in test env
Zblocker64 8e45e00
chore: code rabbit review
Zblocker64 6d919d5
fix(provider): load attributes schema via test bootstrap
Zblocker64 5cb7f61
fix(provider): use ram-before-interface GPU capability key
Zblocker64 575b704
fix(provider): expose discordUsername and fix GPU catalog key order
Zblocker64 a0f281c
chore: review
Zblocker64 162d6d0
Merge branch 'main' into feat/provider-attributes-audit-schema
Zblocker64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,121 @@ | ||
| import type { Provider } from "@akashnetwork/database/dbSchemas/akash"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { createProviderSeed } from "../../../test/seeders/provider.seeder"; | ||
| import { createProviderAttributesSchema } from "../../../test/seeders/provider-attributes-schema.seeder"; | ||
| import { mapProviderToList } from "./provider"; | ||
|
|
||
| const providerAttributeSchemaStub = createProviderAttributesSchema(); | ||
|
|
||
| function mapWithAttributes(attributes: Array<{ key: string; value: string }>) { | ||
| const provider = { | ||
| ...createProviderSeed({ isOnline: true, cosmosSdkVersion: "v0.45.9" }), | ||
| providerAttributes: attributes, | ||
| providerAttributeSignatures: [] | ||
| } as Provider; | ||
|
|
||
| return mapProviderToList(provider, providerAttributeSchemaStub, [], undefined); | ||
| } | ||
|
|
||
| describe(mapProviderToList.name, () => { | ||
| describe("discordUsername", () => { | ||
| it("maps discord-username from on-chain attributes", () => { | ||
| const mapped = mapWithAttributes([{ key: "discord-username", value: "provider_contact" }]); | ||
|
|
||
| expect(mapped.discordUsername).toBe("provider_contact"); | ||
| }); | ||
|
|
||
| it("is null when discord-username is absent", () => { | ||
| const mapped = mapWithAttributes([{ key: "host", value: "example.com" }]); | ||
|
|
||
| expect(mapped.discordUsername).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("locationRegion", () => { | ||
| it("maps location-region from on-chain attributes", () => { | ||
| const mapped = mapWithAttributes([{ key: "location-region", value: "na-us-west" }]); | ||
|
|
||
| expect(mapped.locationRegion).toBe("na-us-west"); | ||
| }); | ||
|
|
||
| it("is null when only legacy region is present", () => { | ||
| const mapped = mapWithAttributes([{ key: "region", value: "us-west" }]); | ||
|
|
||
| expect(mapped.locationRegion).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("featShm", () => { | ||
| it("is true when feat-shm is true", () => { | ||
| const mapped = mapWithAttributes([{ key: "feat-shm", value: "true" }]); | ||
|
|
||
| expect(mapped.featShm).toBe(true); | ||
| }); | ||
|
|
||
| it("is true when any storage class is ram", () => { | ||
| const mapped = mapWithAttributes([ | ||
| { key: "capabilities/storage/2/class", value: "ram" }, | ||
| { key: "capabilities/storage/2/persistent", value: "false" } | ||
| ]); | ||
|
|
||
| expect(mapped.featShm).toBe(true); | ||
| }); | ||
|
|
||
| it("is false when no shm signals are present", () => { | ||
| const mapped = mapWithAttributes([{ key: "capabilities/storage/1/class", value: "beta3" }]); | ||
|
|
||
| expect(mapped.featShm).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("hardwareShm", () => { | ||
| it("maps shm capability attributes from the schema", () => { | ||
| const mapped = mapWithAttributes([ | ||
| { key: "capabilities/storage/2/class", value: "ram" }, | ||
| { key: "capabilities/storage/2/persistent", value: "false" } | ||
| ]); | ||
|
|
||
| expect(mapped.hardwareShm).toEqual(["SHM storage class", "SHM non-persistent"]); | ||
| }); | ||
| }); | ||
|
|
||
| describe("hardwareGpuCapabilities", () => { | ||
| it("maps gpu capability attributes from the schema", () => { | ||
| const mapped = mapWithAttributes([{ key: "capabilities/gpu/vendor/nvidia/model/rtx4090", value: "true" }]); | ||
|
|
||
| expect(mapped.hardwareGpuCapabilities).toEqual(["nvidia rtx4090 24Gi pcie"]); | ||
| }); | ||
| }); | ||
|
|
||
| describe("featPersistentStorage", () => { | ||
| it("is true when feat-persistent-storage is true", () => { | ||
| const mapped = mapWithAttributes([{ key: "feat-persistent-storage", value: "true" }]); | ||
|
|
||
| expect(mapped.featPersistentStorage).toBe(true); | ||
| }); | ||
|
|
||
| it("is true when capabilities/storage/1/persistent is true", () => { | ||
| const mapped = mapWithAttributes([{ key: "capabilities/storage/1/persistent", value: "true" }]); | ||
|
|
||
| expect(mapped.featPersistentStorage).toBe(true); | ||
| }); | ||
|
|
||
| it("is true when persistent storage is declared on a non-default storage index", () => { | ||
| const mapped = mapWithAttributes([ | ||
| { key: "capabilities/storage/1/class", value: "beta3" }, | ||
| { key: "capabilities/storage/1/persistent", value: "false" }, | ||
| { key: "capabilities/storage/2/class", value: "beta2" }, | ||
| { key: "capabilities/storage/2/persistent", value: "true" } | ||
| ]); | ||
|
|
||
| expect(mapped.featPersistentStorage).toBe(true); | ||
| }); | ||
|
|
||
| it("is false when no persistent storage signals are present", () => { | ||
| const mapped = mapWithAttributes([{ key: "capabilities/storage/1/persistent", value: "false" }]); | ||
|
|
||
| expect(mapped.featPersistentStorage).toBe(false); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.