Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@burstjs/core

Package Overview
Dependencies
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@burstjs/core - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

out/abstract/index.d.ts

12

package.json
{
"name": "@burstjs/core",
"version": "0.0.9",
"version": "0.0.10",
"description": "Burst-related functions and models for building Burstcoin applications.",

@@ -17,4 +17,4 @@ "contributors": [

"license": "GPL-3.0",
"main": "./out/src/index.js",
"typings": "./out/src/index.d.ts",
"main": "./out/index.js",
"typings": "./out/index.d.ts",
"private": false,

@@ -44,4 +44,4 @@ "jest": {

"dependencies": {
"@burstjs/crypto": "^0.0.9",
"@burstjs/http": "^0.0.9",
"@burstjs/crypto": "^0.0.10",
"@burstjs/http": "^0.0.10",
"bn.js": "^4.11.8"

@@ -54,3 +54,3 @@ },

},
"gitHead": "424eba9866f7bde74e3671aa22e2409778e6abf4",
"gitHead": "4bcd180f7f317736d2e36e9680355d0acab0b505",
"publishConfig": {

@@ -57,0 +57,0 @@ "access": "public"

@@ -1,3 +0,2 @@

import {HttpMock} from '@burstjs/http';
jest.mock('@burstjs/http');
import {HttpMockBuilder, Http} from '@burstjs/http';

@@ -12,4 +11,9 @@ import {BurstService} from '../../burstService';

beforeEach(() => {
HttpMock.reset();
let httpMock: Http;
afterEach(() => {
if (httpMock) {
// @ts-ignore
httpMock.reset();
}
});

@@ -20,6 +24,4 @@

it('should getBlockByTimestamp', async () => {
HttpMock.onGet().reply<any>(200, {timestamp: 1});
// must always be created after HttpMock
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetReply(200, {timestamp: 1}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const block = await getBlockByTimestamp(service)(1, false);

@@ -30,6 +32,4 @@ expect(block.timestamp).toBe(1);

it('should getBlockByHeight', async () => {
HttpMock.onGet().reply<any>(200, {height: 10});
// must always be created after HttpMock
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetReply(200, {height: 10}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const block = await getBlockByHeight(service)(10, false);

@@ -40,6 +40,4 @@ expect(block.height).toBe(10);

it('should getBlockById', async () => {
HttpMock.onGet().reply<any>(200, {block: '123abc'});
// must always be created after HttpMock
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetReply(200, {block: '123abc'}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const block = await getBlockById(service)('123abc', false);

@@ -51,5 +49,4 @@ expect(block.block).toBe('123abc');

it('should getBlockById fail', async () => {
HttpMock.onGet().error(500, 'Test Error');
// must always be created after HttpMock
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetThrowError(500, 'Test Error').build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
try {

@@ -69,5 +66,4 @@ await getBlockById(service)('123abc', false);

it('should getBlockId', async () => {
HttpMock.onGet().reply<any>(200, {block: 100});
// must always be created after HttpMock
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetReply(200, {block: 100}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);

@@ -74,0 +70,0 @@ const block = await getBlockId(service)(1);

@@ -1,3 +0,2 @@

jest.mock('@burstjs/http');
import {HttpMock} from '@burstjs/http';
import {HttpMockBuilder, Http} from '@burstjs/http';
import {BurstService} from '../../burstService';

@@ -13,4 +12,6 @@ import {broadcastTransaction, sendTextMessage} from '..';

let httpMock: Http;
let service: BurstService;
beforeEach(() => {
// HttpMock.reset();
jest.resetAllMocks();

@@ -30,11 +31,18 @@

HttpMock.onPost().reply(200, {
httpMock = HttpMockBuilder.create().onPostReply(200, {
unsignedTransactionBytes: 'unsignedHexMessage'
});
}).build();
service = new BurstService('baseUrl', 'relPath', httpMock);
});
afterEach(() => {
// @ts-ignore
httpMock.reset();
});
it('should sendTextMessage', async () => {
const service = new BurstService('localhost');
const {fullHash, transaction} = await sendTextMessage(service)(

@@ -62,3 +70,2 @@ 'Message Text',

const service = new BurstService('localhost');
try {

@@ -65,0 +72,0 @@

@@ -1,4 +0,2 @@

// IMPORTANT: mocking http at first
jest.mock('@burstjs/http');
import {HttpMock} from '@burstjs/http';
import {HttpMockBuilder, Http} from '@burstjs/http';
import {BurstService} from '../../burstService';

@@ -8,6 +6,12 @@ import {getBlockchainStatus} from '../network/getBlockchainStatus';

describe('Network Api', () => {
beforeEach(() => {
HttpMock.reset();
let httpMock: Http;
afterEach(() => {
if (httpMock) {
// @ts-ignore
httpMock.reset();
}
});

@@ -17,7 +21,9 @@

it('should getBlockchainStatus', async () => {
HttpMock.onGet().reply(200, {application: 'BRS', numberOfBlocks: 100});
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetReply(200, {
application: 'BRS',
numberOfBlocks: 100
}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const status = await getBlockchainStatus(service)();
console.log('status', status);
expect(status.application).toBe('BRS');

@@ -29,7 +35,5 @@ expect(status.numberOfBlocks).toBe(100);

it('should fail on getBlockchainStatus', async () => {
HttpMock.onGet().error(500, 'Internal Server Error');
try {
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetThrowError(500, 'Internal Server Error').build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
await getBlockchainStatus(service)();

@@ -46,9 +50,8 @@ expect(true).toBe('Exception expected');

HttpMock.onGet().reply(200, {
httpMock = HttpMockBuilder.create().onGetReply(200, {
application: 'BRS',
numberOfPeers: 100,
numberOfAccounts: 10,
});
const service = new BurstService('localhost');
}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const status = await getServerStatus(service)();

@@ -62,7 +65,5 @@ expect(status.application).toBe('BRS');

it('should fail on getNetworkState', async () => {
HttpMock.onGet().error(500, 'Internal Server Error');
try {
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetThrowError(500, 'Internal Server Error').build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
await getServerStatus(service)();

@@ -69,0 +70,0 @@ expect(true).toBe('Exception expected');

@@ -1,12 +0,15 @@

jest.mock('@burstjs/http');
import {HttpMock} from '@burstjs/http';
import {HttpMockBuilder, Http} from '@burstjs/http';
import {BurstService} from '../../burstService';
import {broadcastTransaction} from '../transaction/broadcastTransaction';
import {getTransaction} from '../transaction/getTransaction';
import {TransactionId} from '../../typings/transactionId';
describe('Transaction Api', () => {
beforeEach(() => {
HttpMock.reset();
let httpMock: Http;
afterEach(() => {
if (httpMock) {
// @ts-ignore
httpMock.reset();
}
});

@@ -16,6 +19,4 @@

it('should broadcastTransaction (generic)', async () => {
HttpMock.onPost().reply<TransactionId>(200, {fullHash: 'fullHash', transaction: 'transaction'});
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onPostReply(200, {fullHash: 'fullHash', transaction: 'transaction'}).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const status = await broadcastTransaction(service)('some_data');

@@ -30,8 +31,6 @@ expect(status.fullHash).toBe('fullHash');

it('should getTransaction', async () => {
HttpMock.onGet().reply(200, { id: 'transactionId', block: 'blockId' });
const service = new BurstService('localhost');
httpMock = HttpMockBuilder.create().onGetReply(200, { transaction: 'transactionId', block: 'blockId' }).build();
const service = new BurstService('baseUrl', 'relPath', httpMock);
const status = await getTransaction(service)('transactionId');
expect(status.id).toBe('transactionId');
expect(status.transaction).toBe('transactionId');
expect(status.block).toBe('blockId');

@@ -38,0 +37,0 @@ });

@@ -1,2 +0,2 @@

import {Http} from '@burstjs/http';
import {Http, HttpImpl} from '@burstjs/http';

@@ -38,5 +38,6 @@ /**

* @param relativePath The relative path will be prepended before each url created with toBRSEndpoint()
* @param httpClient {Http?} If passed an client instance, it will be used instead of default HttpImpl. Good for testing.
*/
constructor(baseUrl: string, relativePath: string = '') {
this._http = new Http(baseUrl);
constructor(baseUrl: string, relativePath: string = '', httpClient?: Http) {
this._http = httpClient ? httpClient : new HttpImpl(baseUrl);
this._relPath = relativePath.endsWith('/') ? relativePath.substr(0, relativePath.length - 1) : relativePath;

@@ -43,0 +44,0 @@ }

@@ -6,7 +6,5 @@ /** @module core */

export * from './typings/blockId';
export * from '../../crypto/typings/keys';
export * from './typings/burstNode';
export * from './typings/transaction';
export * from './suggestedFees';
export * from '../../crypto/src/burstUtil';
export * from './currency';

@@ -13,0 +11,0 @@ export * from './api';

@@ -6,3 +6,3 @@ /**

import { Keys } from '../../../crypto/typings/keys';
import { Keys } from '@burstjs/crypto';
import { Transaction } from './transaction';

@@ -49,2 +49,2 @@

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc