Skip to content

Commit

Permalink
Merge branch 'v0.25-dev' into ci/disable-draft-runs
Browse files Browse the repository at this point in the history
  • Loading branch information
strophy authored Oct 4, 2023
2 parents bf4fa54 + f32d415 commit ef4e655
Show file tree
Hide file tree
Showing 26 changed files with 571 additions and 271 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ jobs:
target_wasm
unplugged_amd64
- name: Run Wallet functional tests
run: yarn workspace @dashevo/wallet-lib test:functional

- name: Run SDK functional tests
run: yarn workspace dash test:functional

- name: Run test suite
run: yarn test:suite

Expand Down Expand Up @@ -289,6 +295,12 @@ jobs:
target_wasm
unplugged_amd64
- name: Run Wallet functional tests in browsers
run: yarn workspace @dashevo/wallet-lib test:browsers:functional

- name: Run SDK functional tests in browsers
run: yarn workspace dash test:browsers:functional

- name: Run test suite in browsers
run: yarn test:suite:browsers

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/js-dash-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ jobs:
secrets: inherit
with:
package: 'dash'
start-local-network: true
install-browsers: true
2 changes: 1 addition & 1 deletion .github/workflows/wallet-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ jobs:
secrets: inherit
with:
package: '@dashevo/wallet-lib'
start-local-network: true

install-browsers: true
65 changes: 0 additions & 65 deletions packages/js-dash-sdk/karma.conf.js

This file was deleted.

16 changes: 16 additions & 0 deletions packages/js-dash-sdk/karma/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const options = require('./options');

module.exports = (config) => {
config.set({
...options,
logLevel: config.LOG_INFO,
files: [
'../src/**/*.spec.ts',
'../src/test/karma/bootstrap.ts',
],
preprocessors: {
'../src/**/*.spec.ts': ['webpack'],
'../src/test/karma/bootstrap.ts': ['webpack'],
},
});
};
16 changes: 16 additions & 0 deletions packages/js-dash-sdk/karma/karma.functional.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const options = require('./options');

module.exports = (config) => {
config.set({
...options,
logLevel: config.LOG_INFO,
files: [
'../src/test/karma/bootstrap.ts',
'../tests/functional/sdk.js',
],
preprocessors: {
'../src/test/karma/bootstrap.ts': ['webpack'],
'../tests/functional/sdk.js': ['webpack'],
},
});
};
57 changes: 57 additions & 0 deletions packages/js-dash-sdk/karma/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* eslint-disable import/no-extraneous-dependencies */
const webpack = require('webpack');
const dotenvSafe = require('dotenv-safe');

const karmaMocha = require('karma-mocha');
const karmaMochaReporter = require('karma-mocha-reporter');
const karmaChai = require('karma-chai');
const karmaChromeLauncher = require('karma-chrome-launcher');
const karmaWebpack = require('karma-webpack');
const webpackBaseConfig = require('../webpack.base.config');

let env = {};
if (process.env.LOAD_ENV) {
const dotenvResult = dotenvSafe.config();
if (dotenvResult.error) {
throw dotenvResult.error;
}
env = dotenvResult.parsed;
}

module.exports = {
frameworks: ['mocha', 'chai', 'webpack'],
webpack: {
...webpackBaseConfig,
mode: 'development',
plugins: [
...webpackBaseConfig.plugins,
new webpack.EnvironmentPlugin(
env,
),
],
},
reporters: ['mocha'],
port: 9876,
colors: true,
autoWatch: false,
browsers: ['chromeWithoutSecurity'],
singleRun: false,
concurrency: Infinity,
browserNoActivityTimeout: 7 * 60 * 1000, // 30000 default
browserDisconnectTimeout: 3 * 2000, // 2000 default
pingTimeout: 3 * 5000, // 5000 default
plugins: [
karmaMocha,
karmaMochaReporter,
karmaChai,
karmaChromeLauncher,
karmaWebpack,
],
customLaunchers: {
chromeWithoutSecurity: {
base: 'ChromeHeadless',
flags: ['--allow-insecure-localhost'],
displayName: 'Chrome w/o security',
},
},
};
7 changes: 4 additions & 3 deletions packages/js-dash-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"build:ts": "tsc -p tsconfig.build.json",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "yarn run test:types && yarn run test:unit && yarn run test:functional && yarn run test:browsers",
"test:browsers": "karma start ./karma.conf.js --single-run",
"test": "yarn run test:types && yarn run test:unit && yarn run test:browsers",
"test:browsers": "karma start ./karma/karma.conf.js --single-run",
"test:browsers:functional": "LOAD_ENV=true karma start ./karma/karma.functional.conf.js --single-run",
"test:unit": "ts-mocha -p tsconfig.mocha.json src/**/*.spec.ts",
"test:functional": "yarn run build && mocha --recursive tests/functional/**/*.js",
"test:functional": "yarn run build:ts && LOAD_ENV=true mocha --recursive tests/functional/**/*.js",
"test:types": "yarn pnpify tsd",
"prepublishOnly": "yarn run build",
"prepare": "yarn run build"
Expand Down
20 changes: 4 additions & 16 deletions packages/js-dash-sdk/src/SDK/Client/Platform/Fetcher/Fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,8 @@ class Fetcher {
public async fetchIdentity(id: Identifier): Promise<GetIdentityResponse> {
// Define query
const query = async (): Promise<GetIdentityResponse> => {
const result = await this.dapiClient.platform
.getIdentity(id);

// TODO(rs-drive-abci): Remove this when rs-drive-abci returns error instead of empty bytes
if (result.getIdentity().length === 0) {
throw new NotFoundError(`Identity with id "${id}" not found`);
}
return result;
const { platform } = this.dapiClient;
return platform.getIdentity(id);
};

// Define retry attempts.
Expand All @@ -120,14 +114,8 @@ class Fetcher {
public async fetchDataContract(id: Identifier): Promise<GetDataContractResponse> {
// Define query
const query = async (): Promise<GetDataContractResponse> => {
const result = await this.dapiClient.platform
.getDataContract(id);

// TODO(rs-drive-abci): Remove this when rs-drive-abci returns error instead of empty bytes
if (result.getDataContract().length === 0) {
throw new NotFoundError(`DataContract with id "${id}" not found`);
}
return result;
const { platform } = this.dapiClient;
return platform.getDataContract(id);
};

// Define retry attempts.
Expand Down
11 changes: 6 additions & 5 deletions packages/js-dash-sdk/src/SDK/Client/Platform/Platform.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { latestVersion as latestProtocolVersion } from '@dashevo/dpp/lib/version/protocolVersion';
// import { latestVersion as latestProtocolVersion }
// from '@dashevo/dpp/lib/version/protocolVersion';
import { Platform } from './index';
import 'mocha';
import Client from '../Client';

Check warning on line 6 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.spec.ts

View workflow job for this annotation

GitHub Actions / JS / Linting

Using exported name 'Client' as identifier for default export
Expand All @@ -19,7 +20,7 @@ describe('Dash - Platform', () => {
});

await platform.initialize();
expect(platform.dpp.getProtocolVersion()).to.equal(42);
// expect(platform.dpp.getProtocolVersion()).to.equal(42);
});

// TODO(versioning): obsolete now?
Expand All @@ -30,10 +31,10 @@ describe('Dash - Platform', () => {
});

// @ts-ignore
const testnetProtocolVersion = Platform.networkToProtocolVersion.get('testnet');
// const testnetProtocolVersion = Platform.networkToProtocolVersion.get('testnet');

await platform.initialize();
expect(platform.dpp.getProtocolVersion()).to.equal(testnetProtocolVersion);
// expect(platform.dpp.getProtocolVersion()).to.equal(testnetProtocolVersion);
});

// TODO(versioning): obsolete now?
Expand All @@ -44,6 +45,6 @@ describe('Dash - Platform', () => {
});

await platform.initialize();
expect(platform.dpp.getProtocolVersion()).to.equal(latestProtocolVersion);
// expect(platform.dpp.getProtocolVersion()).to.equal(latestProtocolVersion);
});
});
11 changes: 6 additions & 5 deletions packages/js-dash-sdk/src/test/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const dotenvSafe = require('dotenv-safe');
const path = require('path');

const dotenvSafe = require('dotenv-safe');
const sinon = require('sinon');
const sinonChai = require('sinon-chai');
const { use } = require('chai');
const dirtyChai = require('dirty-chai');
const chaiAsPromised = require('chai-as-promised');

dotenvSafe.config({
path: path.resolve(__dirname, '..', '..', '.env'),
});
if (process.env.LOAD_ENV === 'true') {
dotenvSafe.config({
path: path.resolve(__dirname, '..', '..', '.env'),
});
}

use(dirtyChai);
use(sinonChai);
Expand Down
Loading

0 comments on commit ef4e655

Please sign in to comment.