Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4133 from LiskHQ/4132-fix_peer_db_def
Browse files Browse the repository at this point in the history
Fix peer db def - Closes #4132
  • Loading branch information
shuse2 authored Aug 23, 2019
2 parents bf123c8 + 64ae906 commit 2c4fad8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ const {
},
} = require('../../../../../components/storage');

const defaultCreateValues = {};
const defaultCreateValues = {
os: null,
version: null,
broadhash: null,
height: 1,
protocolVersion: null,
};

const readOnlyFields = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Peer', () => {
let invalidOptions;
let validOptions;
let validPeer;
let incompletePeer;
let invalidPeer;
let storage;

Expand Down Expand Up @@ -142,6 +143,12 @@ describe('Peer', () => {
height: 6857664,
};

incompletePeer = {
ip: '100.187.70.20',
wsPort: 7001,
state: 1,
};

invalidPeer = {
ip: 'a.b.c.d',
wsPort: 7001,
Expand Down Expand Up @@ -316,6 +323,20 @@ describe('Peer', () => {
expect(result).to.be.eql(validPeer);
});

it('should create a peer object successfully with incomplete peer', async () => {
await storage.entities.Peer.create(incompletePeer);
const result = await storage.entities.Peer.getOne({ ip: validPeer.ip });
delete result.id;
expect(result).to.be.eql({
...incompletePeer,
os: null,
version: null,
broadhash: null,
height: 1,
protocolVersion: null,
});
});

it('should skip if any invalid attribute is provided');

it('should reject with invalid data provided', async () =>
Expand Down

0 comments on commit 2c4fad8

Please sign in to comment.