Skip to content

Commit

Permalink
adjust manifest upload tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aomerk committed Jul 21, 2023
1 parent 976b9b7 commit ca4bc65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions cli/commands/publish/upload.manifest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ describe("uploadManifest", () => {
} as any
const mockAddToIpfs = jest.fn()
const mockAgentName = "agentName"
const mockAgentDisplayName = "agent name"
const mockDescription = "some description"
const mockLongDescription = "some long description"
const mockAgentId = "0xagentId"
const mockVersion = "0.1"
const mockDocumentation = "README.md"
const mockRepository = "github.com/myrepository"
const mockLicenseUrl = "github.com/myrepository"
const mockPromoUrl = "github.com/myrepository"
const mockImageRef = "123abc"
const mockPrivateKey = "0xabcd"
const mockCliVersion = "0.2"
Expand Down Expand Up @@ -56,7 +60,8 @@ describe("uploadManifest", () => {

beforeAll(() => {
uploadManifest = provideUploadManifest(
mockFilesystem, mockAddToIpfs, mockAgentName, mockDescription, mockAgentId, mockVersion, mockDocumentation, mockRepository, mockCliVersion, mockChainIds, mockChainSettings
mockFilesystem, mockAddToIpfs, mockAgentName, mockAgentDisplayName,
mockDescription, mockLongDescription, mockAgentId, mockVersion, mockDocumentation, mockRepository, mockLicenseUrl, mockPromoUrl, mockCliVersion, mockChainIds, mockChainSettings
)
})

Expand Down Expand Up @@ -103,14 +108,18 @@ describe("uploadManifest", () => {
const mockManifest = {
from: new Wallet(mockPrivateKey).address,
name: mockAgentName,
displayName: mockAgentDisplayName,
description: mockDescription,
longDescription: mockLongDescription,
agentId: mockAgentName,
agentIdHash: mockAgentId,
version: mockVersion,
timestamp: systemTime.toUTCString(),
imageReference: mockImageRef,
documentation: mockDocumentationRef,
repository: mockRepository,
licenseUrl: mockLicenseUrl,
promoUrl: mockPromoUrl,
chainIds: mockChainIds,
publishedFrom: `Forta CLI ${mockCliVersion}`,
chainSettings: formattedMockChainSettings
Expand All @@ -129,7 +138,7 @@ describe("uploadManifest", () => {
expect(mockFilesystem.readFileSync).toHaveBeenCalledWith(mockDocumentation, 'utf8')
expect(mockAddToIpfs).toHaveBeenCalledTimes(2)
expect(mockAddToIpfs).toHaveBeenNthCalledWith(1, mockDocumentationFile)
const signingKey = new ethers.utils.SigningKey(mockPrivateKey)
const signingKey = new ethers.utils.SigningKey(mockPrivateKey)
const signature = ethers.utils.joinSignature(signingKey.signDigest(keccak256(JSON.stringify(mockManifest))))
expect(mockAddToIpfs).toHaveBeenNthCalledWith(2, JSON.stringify({ manifest: mockManifest, signature }))
jest.useRealTimers()
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/publish/upload.manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export default function provideUploadManifest(
from: new Wallet(privateKey).address,
name: agentName,
displayName: agentDisplayName,
longDescription: longDescription,
description,
longDescription: longDescription,
agentId: agentName,
agentIdHash: agentId,
version,
Expand Down

0 comments on commit ca4bc65

Please sign in to comment.