From 3eff05a56e6de80cbf6fdda5c731b4ed3baa8d80 Mon Sep 17 00:00:00 2001 From: Ryan Ghods Date: Wed, 20 Nov 2019 20:59:27 -0800 Subject: [PATCH] chore: upgrade to ethereumjs-util 6.2.0 fix: failing test cases due toBuffer validating input as hex prefixed (Closes #619) --- package.json | 2 +- tests/api/bloom.js | 22 +++++++++++----------- tests/api/istanbul/eip-1884.js | 2 +- tests/api/istanbul/eip-2200.js | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index e331040dd8..280e80f949 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "ethereumjs-blockchain": "^4.0.2", "ethereumjs-common": "^1.3.2", "ethereumjs-tx": "^2.1.1", - "ethereumjs-util": "~6.1.0", + "ethereumjs-util": "^6.2.0", "fake-merkle-patricia-tree": "^1.0.1", "functional-red-black-tree": "^1.0.1", "merkle-patricia-tree": "^2.3.2", diff --git a/tests/api/bloom.js b/tests/api/bloom.js index bda51b5491..7cfee6213c 100644 --- a/tests/api/bloom.js +++ b/tests/api/bloom.js @@ -22,42 +22,42 @@ tape('bloom', (t) => { const vector = Buffer.from(hex, 'hex') const b = new Bloom(vector) - st.true(b.check(utils.toBuffer('value 1')), 'should contain string "value 1"') - st.true(b.check(utils.toBuffer('value 2')), 'should contain string "value 2"') + st.true(b.check(Buffer.from('value 1', 'utf8')), 'should contain string "value 1"') + st.true(b.check(Buffer.from('value 2', 'utf8')), 'should contain string "value 2"') st.end() }) t.test('check shouldnt be tautology', (st) => { const b = new Bloom() - st.false(b.check(utils.toBuffer('random value')), 'should not contain string "random value"') + st.false(b.check(Buffer.from('random value', 'utf8')), 'should not contain string "random value"') st.end() }) t.test('should correctly add value', (st) => { const b = new Bloom() - b.add(utils.toBuffer('value')) - let found = b.check(utils.toBuffer('value')) + b.add(Buffer.from('value', 'utf8')) + let found = b.check(Buffer.from('value', 'utf8')) st.true(found, 'should contain added value') st.end() }) t.test('should check multiple values', (st) => { const b = new Bloom() - b.add(utils.toBuffer('value 1')) - b.add(utils.toBuffer('value 2')) - let found = b.multiCheck([utils.toBuffer('value 1'), utils.toBuffer('value 2')]) + b.add(Buffer.from('value 1', 'utf8')) + b.add(Buffer.from('value 2', 'utf8')) + let found = b.multiCheck([Buffer.from('value 1'), Buffer.from('value 2')]) st.true(found, 'should contain both values') st.end() }) t.test('should or two filters', (st) => { const b1 = new Bloom() - b1.add(utils.toBuffer('value 1')) + b1.add(Buffer.from('value 1', 'utf8')) const b2 = new Bloom() - b2.add(utils.toBuffer('value 2')) + b2.add(Buffer.from('value 2', 'utf8')) b1.or(b2) - st.true(b1.check(utils.toBuffer('value 2')), 'should contain "value 2" after or') + st.true(b1.check(Buffer.from('value 2', 'utf-8')), 'should contain "value 2" after or') st.end() }) diff --git a/tests/api/istanbul/eip-1884.js b/tests/api/istanbul/eip-1884.js index a3720dbae0..9bed7877cf 100644 --- a/tests/api/istanbul/eip-1884.js +++ b/tests/api/istanbul/eip-1884.js @@ -25,7 +25,7 @@ tape('Istanbul: EIP-1884: SELFBALANCE', async (t) => { const common = new Common(testCase.chain, testCase.hardfork) const vm = new VM({ common }) const state = new PStateManager(vm.stateManager) - const account = createAccount('00', testCase.selfbalance) + const account = createAccount('0x00', testCase.selfbalance) await state.putAccount(addr, account) try { const res = await vm.runCode(runCodeArgs) diff --git a/tests/api/istanbul/eip-2200.js b/tests/api/istanbul/eip-2200.js index 840c3bf1a6..1cb085eda4 100644 --- a/tests/api/istanbul/eip-2200.js +++ b/tests/api/istanbul/eip-2200.js @@ -37,7 +37,7 @@ tape('Istanbul: EIP-2200: net-metering SSTORE', async (t) => { const vm = new VM({ common }) const state = new PStateManager(vm.stateManager) - const account = createAccount('00', '00') + const account = createAccount('0x00', '0x00') await state.putAccount(addr, account) await state.putContractCode(addr, Buffer.from(testCase.code, 'hex')) if (!testCase.original.isZero()) {