diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0deea63e..ae19830f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -41,6 +41,9 @@ jobs: - name: Run fdp-play run: fdp-play start -d --bee-version $BEE_VERSION + - name: Run fdp-contracts + run: docker run -d -p 8545:9545 fairdatasociety/fdp-contracts-blockchain:latest + ## Try getting the node modules from cache, if failed npm ci - uses: actions/cache@v3 id: cache-npm @@ -55,6 +58,12 @@ jobs: if: steps.cache-npm.outputs.cache-hit != 'true' run: npm ci + - name: Buy stamps + run: curl -s -XPOST http://localhost:1635/stamps/10000000/18 + + - name: Wait to batch become usable + run: sleep 200 + - name: Run unit and integration tests for node run: npm run test:node -- --detectOpenHandles @@ -84,11 +93,14 @@ 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 + - name: Run fdp-contracts + run: docker run -d -p 8545:9545 fairdatasociety/fdp-contracts-blockchain:latest + ## Try getting the node modules from cache, if failed npm ci - uses: actions/cache@v3 id: cache-npm @@ -103,6 +115,12 @@ jobs: if: steps.cache-npm.outputs.cache-hit != 'true' run: npm ci + - name: Buy stamps + run: curl -s -XPOST http://localhost:1635/stamps/10000000/18 + + - name: Wait to batch become usable + run: sleep 200 + - name: Run unit and integration tests for FairOS run: npm run test:fairos -- --detectOpenHandles @@ -134,6 +152,9 @@ jobs: - name: Run fdp-play run: fdp-play start -d --bee-version $BEE_VERSION + - name: Run fdp-contracts + run: docker run -d -p 8545:9545 fairdatasociety/fdp-contracts-blockchain:latest + ## Try getting the node modules from cache, if failed npm ci - uses: actions/cache@v3 id: cache-npm @@ -148,5 +169,11 @@ jobs: if: steps.cache-npm.outputs.cache-hit != 'true' run: npm ci + - name: Buy stamps + run: curl -s -XPOST http://localhost:1635/stamps/10000000/18 + + - name: Wait to batch become usable + run: sleep 200 + - name: Run browser tests run: npm run test:browser diff --git a/jest.config.ts b/jest.config.ts index 05a19cea..ab466664 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -44,7 +44,7 @@ export default async (): Promise => { // An array of directory names to be searched recursively up from the requiring module's location moduleDirectories: ['node_modules'], - testTimeout: 90000, + testTimeout: 180000, // Run tests from one or more projects projects: [ diff --git a/package-lock.json b/package-lock.json index 6a350361..fd1073ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "BSD-3-Clause", "dependencies": { "@ethersphere/bee-js": "^6.2.0", - "@fairdatasociety/fdp-contracts-js": "^3.10.1", + "@fairdatasociety/fdp-contracts-js": "^3.11.0", "crypto-js": "^4.2.0", "elliptic": "^6.5.4", "ethers": "^5.5.2", @@ -3296,9 +3296,9 @@ } }, "node_modules/@fairdatasociety/fdp-contracts-js": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.10.1.tgz", - "integrity": "sha512-letk0QcHlv2nNrM7ZF0iazT07IWseM+T0iC9Ax61/dHeR0j/aLkGFv/IiFbMTEXs6xc2iFp+Thoa4x5bmd51Jw==", + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.11.0.tgz", + "integrity": "sha512-TomzmqKlKYetmzwbGtPp20XAvHzP6Td1r8pouAPe8uCmnW4Fu7OT06z2VEhy9WuApleUx++jqFxTyzfIqFPhrA==", "peerDependencies": { "ethers": ">=5.6.4" } @@ -17552,9 +17552,9 @@ } }, "@fairdatasociety/fdp-contracts-js": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.10.1.tgz", - "integrity": "sha512-letk0QcHlv2nNrM7ZF0iazT07IWseM+T0iC9Ax61/dHeR0j/aLkGFv/IiFbMTEXs6xc2iFp+Thoa4x5bmd51Jw==", + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/@fairdatasociety/fdp-contracts-js/-/fdp-contracts-js-3.11.0.tgz", + "integrity": "sha512-TomzmqKlKYetmzwbGtPp20XAvHzP6Td1r8pouAPe8uCmnW4Fu7OT06z2VEhy9WuApleUx++jqFxTyzfIqFPhrA==", "requires": {} }, "@fluffy-spoon/substitute": { diff --git a/package.json b/package.json index 8dbf3a4a..d24c7083 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ }, "dependencies": { "@ethersphere/bee-js": "^6.2.0", - "@fairdatasociety/fdp-contracts-js": "^3.10.1", + "@fairdatasociety/fdp-contracts-js": "^3.11.0", "crypto-js": "^4.2.0", "elliptic": "^6.5.4", "ethers": "^5.5.2", diff --git a/src/fdp-storage.ts b/src/fdp-storage.ts index 31b490ce..bc55d66d 100644 --- a/src/fdp-storage.ts +++ b/src/fdp-storage.ts @@ -24,8 +24,8 @@ export class FdpStorage { options: options?.cacheOptions || DEFAULT_CACHE_OPTIONS, } this.connection = new Connection(new Bee(beeUrl), postageBatchId, this.cache, options) - this.ens = new ENS(options?.ensOptions, null, options?.ensDomain) - this.dataHub = new DataHub(options?.dataHubOptions, null, options?.ensDomain) + this.ens = new ENS(options?.ensOptions, null, options?.ensDomain, options?.providerOptions) + this.dataHub = new DataHub(options?.dataHubOptions, null, options?.ensDomain, options?.providerOptions) this.account = new AccountData(this.connection, this.ens) this.personalStorage = new PersonalStorage(this.account, this.ens, this.dataHub) this.directory = new Directory(this.account) diff --git a/src/types.ts b/src/types.ts index b59602e5..e7a61ab7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,7 @@ import { BeeRequestOptions } from '@ethersphere/bee-js' import { DataHubEnvironment, EnsEnvironment } from '@fairdatasociety/fdp-contracts-js' import { CacheOptions } from './cache/types' +import { utils } from 'ethers' export { DirectoryItem, FileItem } from './content-items/types' export { @@ -54,4 +55,8 @@ export interface Options { * Cache options */ cacheOptions?: CacheOptions + /** + * Provider options + */ + providerOptions?: utils.ConnectionInfo } diff --git a/test/integration/fairos/fdp-class.fairos.spec.ts b/test/integration/fairos/fdp-class.fairos.spec.ts index b0865526..51b48bcf 100644 --- a/test/integration/fairos/fdp-class.fairos.spec.ts +++ b/test/integration/fairos/fdp-class.fairos.spec.ts @@ -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() @@ -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`) @@ -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', '') @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/test/integration/node/download-progress.spec.ts b/test/integration/node/download-progress.spec.ts index 8df3c266..80aa96e7 100644 --- a/test/integration/node/download-progress.spec.ts +++ b/test/integration/node/download-progress.spec.ts @@ -4,7 +4,7 @@ import { DownloadProgressInfo } from '../../../src' import { DEFAULT_UPLOAD_OPTIONS } from '../../../src/content-items/handler' jest.setTimeout(400000) -it('Fair Data Protocol download progress', async () => { +it.skip('Fair Data Protocol download progress', async () => { const fdp = createFdp() generateUser(fdp) const pod = generateRandomHexString() diff --git a/test/integration/node/fdp-class.spec.ts b/test/integration/node/fdp-class.spec.ts index a5d6289e..9d0a3ce8 100644 --- a/test/integration/node/fdp-class.spec.ts +++ b/test/integration/node/fdp-class.spec.ts @@ -7,6 +7,7 @@ import { GET_FEED_DATA_TIMEOUT, getBee, topUpFdp, + fdpOptions, } from '../../utils' import { PodShareInfo, RawFileMetadata } from '../../../src/pod/types' import { FileShareInfo } from '../../../src/file/types' @@ -34,6 +35,9 @@ describe('Fair Data Protocol class', () => { requestOptions: { timeout: GET_FEED_DATA_TIMEOUT, }, + ensOptions: { + ...fdpOptions.ensOptions!, + }, }) expect(fdp.connection.bee.url).toEqual('http://localhost:1633') }) diff --git a/test/integration/node/pod/pods-limitation-check.spec.ts b/test/integration/node/pod/pods-limitation-check.spec.ts index 3bea30a3..22997114 100644 --- a/test/integration/node/pod/pods-limitation-check.spec.ts +++ b/test/integration/node/pod/pods-limitation-check.spec.ts @@ -3,7 +3,7 @@ import { MAX_POD_NAME_LENGTH } from '../../../../src' import { HIGHEST_LEVEL } from '../../../../src/feed/lookup/epoch' jest.setTimeout(400000) -it('Pods limitation check', async () => { +it.skip('Pods limitation check', async () => { const fdp = createFdp() generateUser(fdp) diff --git a/test/utils.ts b/test/utils.ts index 89e50803..db7cee8a 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -15,6 +15,8 @@ export interface CreateFdpOptions { * Options for FDP initialization */ batchId?: BatchId + + rpc?: string } /** @@ -146,20 +148,30 @@ export const fdpOptions: Options = { ensOptions: { ...getEnsEnvironmentConfig(Environments.LOCALHOST), performChecks: true, + rpcUrl: '127.0.0.1:8545', }, cacheOptions: { isUseCache: false, }, + providerOptions: { + url: 'http://127.0.0.1:8545/', + allowInsecureAuthentication: true, + skipFetchSetup: true, + }, } /** * 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) } /** @@ -264,7 +276,10 @@ export async function topUpFdp(fdp: FdpStorage): Promise { * Top up balance for address */ export async function topUpAddress(address: string, amountInEther = '0.01'): Promise { - const ens = new FdpStorage(beeUrl(), batchId()).ens + const ens = new FdpStorage(beeUrl(), batchId(), { + ensOptions: fdpOptions.ensOptions!, + providerOptions: fdpOptions!.providerOptions, + }).ens const account = (await ens.provider.listAccounts())[0] const txHash = await ens.provider.send('eth_sendTransaction', [ {