-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add solana-test-validator.json
- Loading branch information
Showing
12 changed files
with
559 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ permissions: | |
contents: read | ||
packages: read | ||
|
||
env: | ||
BUILDKIT_PROGRESS: plain | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
|
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 |
---|---|---|
|
@@ -7,6 +7,9 @@ on: | |
permissions: | ||
contents: read | ||
|
||
env: | ||
BUILDKIT_PROGRESS: plain | ||
|
||
jobs: | ||
version: | ||
runs-on: ubuntu-latest | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,31 @@ | ||
{ | ||
"name": "@karfia/solana-test-validator", | ||
"version": "0.0.0", | ||
"private": false, | ||
"repository": { | ||
"url": "git+https://github.com/fuxingloh/karfia" | ||
}, | ||
"license": "MPL-2.0", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "jest" | ||
}, | ||
"lint-staged": { | ||
"*": [ | ||
"prettier --write --ignore-unknown" | ||
], | ||
"*.{ts,tsx}": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
] | ||
}, | ||
"jest": { | ||
"preset": "@workspace/jest-preset" | ||
}, | ||
"devDependencies": { | ||
"@workspace/jest-preset": "workspace:*", | ||
"@workspace/tsconfig": "workspace:*", | ||
"karfia-definition": "workspace:*", | ||
"karfia-testcontainers": "workspace:*" | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
definitions/solana-test-validator/solana-test-validator.json
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,33 @@ | ||
{ | ||
"$schema": "./node_modules/karfia-definition/index.json", | ||
"id": "solana:test-validator/solana-test-validator:1.17.26", | ||
"caip2": "solana:test-validator", | ||
"name": "Solana Test Validator", | ||
"containers": { | ||
"solana-test-validator": { | ||
"image": "ghcr.io/fuxingloh/solana-container:1.17.26", | ||
"source": "https://github.com/fuxingloh/solana-container", | ||
"resources": { | ||
"cpu": 0.25, | ||
"memory": 256 | ||
}, | ||
"endpoints": { | ||
"rpc": { | ||
"port": 8899, | ||
"protocol": "HTTP JSON-RPC 2.0", | ||
"probes": { | ||
"readiness": { | ||
"params": [], | ||
"method": "getBlockHeight", | ||
"match": { | ||
"result": { | ||
"type": "number" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
definitions/solana-test-validator/solana-test-validator.unit.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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals'; | ||
import { KarfiaAgentContainer, KarfiaTestContainer, KarfiaTestcontainers } from 'karfia-testcontainers'; | ||
|
||
import definition from './solana-test-validator.json'; | ||
|
||
describe('testcontainers', () => { | ||
let testcontainers: KarfiaTestcontainers; | ||
|
||
beforeAll(async () => { | ||
testcontainers = await KarfiaTestcontainers.start(definition); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testcontainers.stop(); | ||
}); | ||
|
||
describe('solana-test-validator', () => { | ||
let validator: KarfiaTestContainer; | ||
|
||
beforeAll(() => { | ||
validator = testcontainers.getContainer('solana-test-validator'); | ||
}); | ||
|
||
it('should rpc(getBlockHeight)', async () => { | ||
const response = await validator.rpc({ | ||
method: 'getBlockHeight', | ||
}); | ||
|
||
expect(response.status).toStrictEqual(200); | ||
|
||
expect(await response.json()).toMatchObject({ | ||
result: 0, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('karfia-agent', () => { | ||
let agent: KarfiaAgentContainer; | ||
|
||
beforeAll(() => { | ||
agent = testcontainers.getKarfiaAgent(); | ||
}); | ||
|
||
it('should get karfia-agent/deployment', async () => { | ||
const result = await agent.getDeployment(); | ||
expect(result).toMatchObject({ | ||
deploymentId: testcontainers.getDeploymentId(), | ||
definitionId: definition.id, | ||
caip2: definition.caip2, | ||
name: definition.name, | ||
}); | ||
}); | ||
|
||
it('should get karfia-agent/definition', async () => { | ||
const result = await agent.getDefinition(); | ||
const expected = { | ||
...definition, | ||
$schema: undefined, | ||
}; | ||
delete expected.$schema; | ||
expect(result).toMatchObject(expected); | ||
}); | ||
|
||
it('should get karfia-agent/probes/startup', async () => { | ||
const response = await agent.probe('startup'); | ||
expect(response.status).toStrictEqual(200); | ||
expect(await response.json()).toMatchObject({ | ||
ok: true, | ||
}); | ||
}); | ||
|
||
it('should get karfia-agent/probes/liveness', async () => { | ||
const response = await agent.probe('liveness'); | ||
expect(response.status).toStrictEqual(200); | ||
expect(await response.json()).toMatchObject({ | ||
ok: true, | ||
}); | ||
}); | ||
|
||
it('should get karfia-agent/probes/readiness', async () => { | ||
const response = await agent.probe('readiness'); | ||
expect(response.status).toStrictEqual(200); | ||
expect(await response.json()).toMatchObject({ | ||
containers: { | ||
'solana-test-validator': { | ||
ok: true, | ||
}, | ||
}, | ||
ok: true, | ||
}); | ||
}); | ||
}); | ||
}); |
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,3 @@ | ||
{ | ||
"extends": "@workspace/tsconfig" | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.