From 784c112af36996ba6c5636b8d06a95f2635eeb33 Mon Sep 17 00:00:00 2001 From: Maciej Hirsz <1096222+maciejhirsz@users.noreply.github.com> Date: Fri, 5 Oct 2018 17:08:27 +0200 Subject: [PATCH] Travis CI integration (#75) --- .travis.yml | 7 ++++ package.json | 2 +- packages/frontend/test/Connection.spec.ts | 40 +++++++++++------------ scripts/test-common.sh | 1 - scripts/test.sh | 1 + 5 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 .travis.yml delete mode 100755 scripts/test-common.sh create mode 100755 scripts/test.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6ee8d5b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +sudo: false + +language: node_js + +matrix: + include: + - node_js: "10" diff --git a/package.json b/package.json index 6a5a38b..be4c1bd 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,6 @@ "check:backend": "tsc -p packages/backend --noEmit", "build:common": "tsc -p packages/common", "check:common": "tsc -p packages/common --noEmit", - "test:common": "scripts/test-common.sh" + "test": "scripts/test.sh" } } diff --git a/packages/frontend/test/Connection.spec.ts b/packages/frontend/test/Connection.spec.ts index 7907169..c7e3da1 100644 --- a/packages/frontend/test/Connection.spec.ts +++ b/packages/frontend/test/Connection.spec.ts @@ -88,7 +88,7 @@ describe('Connection.ts', () => { test('handle Feed Version message state update', async () => { connection.handleMessages([ { - action: 0, + action: Actions.FeedVersion, payload: VERSION } ] as any as FeedMessage.Message[]) @@ -102,10 +102,10 @@ describe('Connection.ts', () => { connection.handleMessages([ { - action: 1, + action: Actions.BestBlock, payload: [1, time, 0], }, { - action: 1, + action: Actions.BestBlock, payload: [1, time, 123456789] } ] as any as FeedMessage.Message[]); @@ -124,8 +124,8 @@ describe('Connection.ts', () => { */ connection.handleMessages([ { - action: 2, - payload: [1, ['Sample Node', 'Sampling', '1.2.3', '0x123456789012345'], [12, 84, 38, 78], [1, 'aoaiuhsf9o2ih389r', 777, time, 829]], + action: Actions.AddedNode, + payload: [1, ['Sample Node', 'Sampling', '1.2.3', '0x123456789012345'], [12, 84], [[38], [78], [5]], [1, 'aoaiuhsf9o2ih389r', 777, time, 829]], } ] as any as FeedMessage.Message[]); @@ -147,8 +147,8 @@ describe('Connection.ts', () => { expect(firstNode.validator).toBe('0x123456789012345'); expect(firstNode.peers).toBe(12); expect(firstNode.txs).toBe(84); - expect(firstNode.mem).toBe(38); - expect(firstNode.cpu).toBe(78); + expect(firstNode.mem).toEqual([38]); + expect(firstNode.cpu).toEqual([78]); expect(firstNode.height).toBe(1); expect(firstNode.hash).toBe('aoaiuhsf9o2ih389r'); expect(firstNode.blockTime).toBe(777); @@ -165,7 +165,7 @@ describe('Connection.ts', () => { connection.handleMessages([ { - action: 0x04, + action: Actions.LocatedNode, payload: [1, 30.828, 101.4111, 'Kuala Lumpur'] } ] as any as FeedMessage.Message[]); @@ -188,7 +188,7 @@ describe('Connection.ts', () => { test('handle Time Sync message state update', () => { connection.handleMessages([ { - action: 0x07, + action: Actions.TimeSync, payload: time + 12345432 } ] as any as FeedMessage.Message[]); @@ -211,7 +211,7 @@ describe('Connection.ts', () => { */ connection.handleMessages([ { - action: 0x05, + action: Actions.ImportedBlock, payload: ["BBQ Birch", [1, 'ABCDEFGH12345678', 123, time, 48292010]], } ] as any as FeedMessage.Message[]); @@ -236,8 +236,8 @@ describe('Connection.ts', () => { validator: '0x123456789012345', peers: 12, txs: 84, - mem: 38, - cpu: 78, + mem: [38], + cpu: [78], height: 1, hash: 'aoaiuhsf9o2ih389r', blockTime: 777, @@ -255,7 +255,7 @@ describe('Connection.ts', () => { */ connection.handleMessages([ { - action: 3, + action: Actions.RemovedNode, payload: 1 } ] as any as FeedMessage.Message[]); @@ -269,10 +269,10 @@ describe('Connection.ts', () => { test('handle Added Chain message state update', () => { connection.handleMessages([ { - action: 8, + action: Actions.AddedChain, payload: ["BBQ Birch", 6], }, { - action: 8, + action: Actions.AddedChain, payload: ["Krumme Lanke", 57] } ] as any as FeedMessage.Message[]); @@ -302,7 +302,7 @@ describe('Connection.ts', () => { test('handle Subscribed To message state update', () => { connection.handleMessages([ { - action: 0x0A, + action: Actions.SubscribedTo, payload: 'BBQ Birch' } ] as any as FeedMessage.Message[]); @@ -312,7 +312,7 @@ describe('Connection.ts', () => { connection.handleMessages([ { - action: 0x0A, + action: Actions.SubscribedTo, payload: 'Krumme Lanke' } ] as any as FeedMessage.Message[]); @@ -324,7 +324,7 @@ describe('Connection.ts', () => { test('handle Unsubscribed From message state update', () => { connection.handleMessages([ { - action: 0x0B, + action: Actions.UnsubscribedFrom, payload: 'Krumme Lanke' } ] as any as FeedMessage.Message[]); @@ -337,10 +337,10 @@ describe('Connection.ts', () => { test('handle Removed Chain message state update', () => { connection.handleMessages([ { - action: 9, + action: Actions.RemovedChain, payload: 'BBQ Birch' }, { - action: 9, + action: Actions.RemovedChain, payload: 'Krumme Lanke' } ] as any as FeedMessage.Message[]); diff --git a/scripts/test-common.sh b/scripts/test-common.sh deleted file mode 100755 index 2de4396..0000000 --- a/scripts/test-common.sh +++ /dev/null @@ -1 +0,0 @@ -tsc -p packages/common && node packages/common/test | tap-spec diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..6b3c15b --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1 @@ +yarn && tsc -p packages/common && tsc -p packages/backend && node packages/common/test | tap-spec && cd packages/backend && yarn test && cd ../frontend && yarn test && cd ../../