diff --git a/package.json b/package.json index 8e2bf590f..8040e302d 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test": "npm run lint && npm run test:unit:cover && npm run test:integration:cover", "test:unit": "npm run build-tests && npm run mocha \"./dist/test/unit/**/*.test.js\"", "test:integration": "npm run build-tests && npm run mocha \"./dist/test/integration/**/*.test.js\"", - "test:integration:encryptFile": "npm run build-tests && npm run mocha ./dist/test/integration/encryptFile.test.js", + "test:integration:encryptDecryptDDO": "npm run build-tests && npm run mocha ./dist/test/integration/encryptDecryptDDO.test.js", "test:unit:cover": "nyc --report-dir coverage/unit npm run test:unit", "test:integration:cover": "nyc --report-dir coverage/integration --no-clean npm run test:integration", "logs": "./scripts/logs.sh" diff --git a/src/components/httpRoutes/index.ts b/src/components/httpRoutes/index.ts index b7affa590..896130d75 100644 --- a/src/components/httpRoutes/index.ts +++ b/src/components/httpRoutes/index.ts @@ -16,7 +16,8 @@ export * from './getOceanPeers.js' export const httpRoutes = express.Router() // P2P routes related -export const hasP2PInterface = await (await getConfiguration()).hasP2P +export const hasP2PInterface = (await (await getConfiguration())?.hasP2P) || false + export function sendMissingP2PResponse(res: Response) { res.status(400).send('Invalid or Non Existing P2P configuration') } diff --git a/src/test/integration/encryptDecryptDDO.test.ts b/src/test/integration/encryptDecryptDDO.test.ts index 0d5d33960..f0bcf2fbb 100644 --- a/src/test/integration/encryptDecryptDDO.test.ts +++ b/src/test/integration/encryptDecryptDDO.test.ts @@ -33,6 +33,7 @@ import { } from '../utils/utils.js' import { DecryptDDOCommand } from '../../@types/commands.js' import { EncryptMethod } from '../../@types/fileObject.js' +import { homedir } from 'os' describe('Should encrypt and decrypt DDO', () => { let database: Database @@ -63,20 +64,10 @@ describe('Should encrypt and decrypt DDO', () => { let previousConfiguration: OverrideEnvConfig[] before(async () => { - let artifactsAddresses = getOceanArtifactsAdressesByChainId(DEVELOPMENT_CHAIN_ID) - if (!artifactsAddresses) { - artifactsAddresses = getOceanArtifactsAdresses().development - } - provider = new JsonRpcProvider('http://127.0.0.1:8545') publisherAccount = (await provider.getSigner(0)) as Signer publisherAddress = await publisherAccount.getAddress() genericAsset = genericDDO - factoryContract = new ethers.Contract( - artifactsAddresses.ERC721Factory, - ERC721Factory.abi, - publisherAccount - ) previousConfiguration = await setupEnvironment( null, @@ -84,16 +75,29 @@ describe('Should encrypt and decrypt DDO', () => { [ ENVIRONMENT_VARIABLES.PRIVATE_KEY, ENVIRONMENT_VARIABLES.RPCS, - ENVIRONMENT_VARIABLES.AUTHORIZED_DECRYPTERS + ENVIRONMENT_VARIABLES.AUTHORIZED_DECRYPTERS, + ENVIRONMENT_VARIABLES.DB_URL, + ENVIRONMENT_VARIABLES.ADDRESS_FILE ], [ '0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58', JSON.stringify(mockSupportedNetworks), - JSON.stringify([publisherAddress]) + JSON.stringify([publisherAddress]), + 'http://localhost:8108/?apiKey=xyz', + `${homedir}/.ocean/ocean-contracts/artifacts/address.json` ] ) ) + let artifactsAddresses = getOceanArtifactsAdressesByChainId(DEVELOPMENT_CHAIN_ID) + if (!artifactsAddresses) { + artifactsAddresses = getOceanArtifactsAdresses().development + } + factoryContract = new ethers.Contract( + artifactsAddresses.ERC721Factory, + ERC721Factory.abi, + publisherAccount + ) const dbConfig = { url: 'http://localhost:8108/?apiKey=xyz' } diff --git a/src/test/utils/utils.ts b/src/test/utils/utils.ts index 8f626278a..e45826687 100644 --- a/src/test/utils/utils.ts +++ b/src/test/utils/utils.ts @@ -95,6 +95,7 @@ export async function setupEnvironment( CONFIG_LOGGER.debug('Overriding environment variable: ' + element.name) element.originalValue = process.env[element.name] // save original value process.env[element.name] = element.newValue + ENVIRONMENT_VARIABLES[element.name].value = element.newValue forceReload = true } })