From d3a2934e75c8dcef1123b03fb9e2336f93c8f53e Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Tue, 19 May 2020 17:02:01 +0800 Subject: [PATCH] chore: fix flaky test and stop running broken examples in ci --- web3.js/.travis.yml | 1 - web3.js/test/connection.test.js | 43 +++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/web3.js/.travis.yml b/web3.js/.travis.yml index cd367bdfee..3d290fb094 100644 --- a/web3.js/.travis.yml +++ b/web3.js/.travis.yml @@ -47,7 +47,6 @@ script: - examples/bpf-rust-noop/do.sh build - npm run localnet:update - npm run localnet:up - - npm run examples || true - npm run test:live - npm run localnet:down diff --git a/web3.js/test/connection.test.js b/web3.js/test/connection.test.js index d9558851eb..605d845177 100644 --- a/web3.js/test/connection.test.js +++ b/web3.js/test/connection.test.js @@ -1402,15 +1402,14 @@ test('transaction failure', async () => { return; } - const responseConfirmations = response.confirmations; - if (typeof responseConfirmations !== 'number') { - expect(typeof responseConfirmations).toEqual('number'); - return; - } - expect(response.err).toEqual(expectedErr); expect(response.slot).toBeGreaterThanOrEqual(0); - expect(responseConfirmations).toBeGreaterThan(0); + const responseConfirmations = response.confirmations; + if (typeof responseConfirmations === 'number') { + expect(responseConfirmations).toBeGreaterThan(0); + } else { + expect(responseConfirmations).toBeNull(); + } }); test('transaction', async () => { @@ -1600,15 +1599,14 @@ test('transaction', async () => { return; } - const responseConfirmations = response.confirmations; - if (typeof responseConfirmations !== 'number') { - expect(typeof responseConfirmations).toEqual('number'); - return; - } - expect(response.err).toBeNull(); expect(response.slot).toBeGreaterThanOrEqual(0); - expect(responseConfirmations).toBeGreaterThan(0); + const responseConfirmations = response.confirmations; + if (typeof responseConfirmations === 'number') { + expect(responseConfirmations).toBeGreaterThan(0); + } else { + expect(responseConfirmations).toBeNull(); + } const unprocessedSignature = '8WE5w4B7v59x6qjyC4FbG2FEKYKQfvsJwqSxNVmtMjT8TQ31hsZieDHcSgqzxiAoTL56n2w5TncjqEKjLhtF4Vk'; @@ -1658,15 +1656,18 @@ test('transaction', async () => { expect(firstResponse.slot).toBeGreaterThanOrEqual(response.slot); expect(firstResponse.err).toEqual(response.err); - if (typeof firstResponse.confirmations !== 'number') { - expect(typeof firstResponse.confirmations).toEqual('number'); - return; + const firstResponseConfirmations = firstResponse.confirmations; + if ( + typeof responseConfirmations === 'number' && + typeof firstResponseConfirmations === 'number' + ) { + expect(firstResponseConfirmations).toBeGreaterThanOrEqual( + responseConfirmations, + ); + } else { + expect(firstResponseConfirmations).toBeNull(); } - expect(firstResponse.confirmations).toBeGreaterThanOrEqual( - responseConfirmations, - ); - mockRpc.push([ url, {