Skip to content

Commit

Permalink
test: fairos tests fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomicvladan committed Mar 18, 2024
1 parent bcd79c4 commit 4a66298
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://docker.pkg.github.com -u ${GITHUB_ACTOR} --password-stdin
- name: Install fdp-play
run: npm install -g @fairdatasociety/fdp-play
run: npm install -g @fairdatasociety/fdp-play@3.0.0

- name: Run fdp-play
run: fdp-play start -d --fairos --fairos-image $FAIROS_IMAGE --bee-version $BEE_VERSION
Expand Down
27 changes: 15 additions & 12 deletions test/integration/fairos/fdp-class.fairos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { DEFAULT_DIRECTORY_PERMISSIONS, getDirectoryMode } from '../../../src/di
import { getIndexFileContent } from '../../../src/file/handler'

jest.setTimeout(400000)

const fdpOptions = { rpc: 'http://127.0.0.1:9545' }

describe('Fair Data Protocol with FairOS-dfs', () => {
beforeAll(async () => {
await waitFairOS()
Expand All @@ -18,7 +21,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {
describe('Account', () => {
it('should register in fdp and login in fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
await topUpFdp(fdp)
const nameHash = utils.namehash(`${user.username}.fds`)
Expand All @@ -35,7 +38,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should register in fairos and login in fdp', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser()
const nameHash = utils.namehash(`${user.username}.fds`)
const publicKey = Wallet.fromMnemonic(user.mnemonic).publicKey.replace('0x', '')
Expand All @@ -58,7 +61,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {
describe('Pod', () => {
it('should create pods in fdp and list them in fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const podName2 = generateRandomHexString()
Expand Down Expand Up @@ -86,7 +89,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should create pods in fairos and list them in fdp', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser()
const podName1 = generateRandomHexString()
const podName2 = generateRandomHexString()
Expand Down Expand Up @@ -126,7 +129,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should delete pod in fdp and it will disappear in fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()

Expand Down Expand Up @@ -193,7 +196,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {
describe('Directory', () => {
it('should create directories in fdp and list them in fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const directoryName1 = generateRandomHexString()
Expand Down Expand Up @@ -240,7 +243,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should create directories in fairos and list them in fdp', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const directoryName1 = generateRandomHexString()
Expand Down Expand Up @@ -284,7 +287,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should delete directory in fdp and it will disappear in fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const directoryName1 = generateRandomHexString()
Expand Down Expand Up @@ -349,7 +352,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {
describe('File', () => {
it('should upload file with fdp and it should available via fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const fileSizeBig = 5000015
Expand Down Expand Up @@ -378,7 +381,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should upload file with fairos and it should available via fdp', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const fileSizeBig = 5000015
Expand Down Expand Up @@ -424,7 +427,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {

it('should delete file in fdp and it will disappear in fairos', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const fileSizeBig = 1000015
Expand Down Expand Up @@ -493,7 +496,7 @@ describe('Fair Data Protocol with FairOS-dfs', () => {
describe('Metadata', () => {
it('should exists fields for file and directory in fairos and fdp', async () => {
const fairos = new FairOSApi()
const fdp = createFdp()
const fdp = createFdp(undefined, fdpOptions)
const user = generateUser(fdp)
const podName1 = generateRandomHexString()
const fileSizeBig = 1000015
Expand Down
10 changes: 8 additions & 2 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface CreateFdpOptions {
* Options for FDP initialization
*/
batchId?: BatchId

rpc?: string
}

/**
Expand Down Expand Up @@ -162,10 +164,14 @@ export const fdpOptions: Options = {
* Creates FDP instance with default configuration for testing
*/
export function createFdp(cacheOptions?: CacheOptions, options?: CreateFdpOptions): FdpStorage {
return new FdpStorage(beeUrl(), options?.batchId ?? batchId(), {
const fdpStorageOptions = {
...fdpOptions,
...(cacheOptions ? { cacheOptions } : undefined),
})
}
fdpStorageOptions.ensOptions!.rpcUrl = options?.rpc || fdpOptions.ensOptions!.rpcUrl!
fdpStorageOptions.providerOptions!.url = options?.rpc || fdpOptions.providerOptions!.url!

return new FdpStorage(beeUrl(), options?.batchId ?? batchId(), fdpStorageOptions)
}

/**
Expand Down

0 comments on commit 4a66298

Please sign in to comment.