From ef39538d2cf774e3e02414ba0559385f9aedd88e Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 7 Jul 2021 15:08:53 -1000 Subject: [PATCH 01/16] Add additional EIP-2930 and EIP-1559 tests --- test/e2e.method.signing.js | 93 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/test/e2e.method.signing.js b/test/e2e.method.signing.js index 2646fa04195..dd7f6308f0d 100644 --- a/test/e2e.method.signing.js +++ b/test/e2e.method.signing.js @@ -129,6 +129,99 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); + it('accounts.signTransaction, (EIP-2930, accessList specified)', function(done){ + const source = wallet[0].address; + const destination = wallet[1].address; + + const txObject = { + to: destination, + value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')), + gas: web3.utils.toHex(21000), + accessList: [] + }; + + web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey, async function(err, signed){ + const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction); + assert(receipt.status === true); + done(); + }); + }); + + it('accounts.signTransaction, (EIP-2930, type 1 specified)', function(done){ + const source = wallet[0].address; + const destination = wallet[1].address; + + const txObject = { + to: destination, + value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')), + gas: web3.utils.toHex(21000), + type: 1 + }; + + web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey, async function(err, signed){ + const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction); + assert(receipt.status === true); + done(); + }); + }); + + it('accounts.signTransaction, (EIP-1559, maxFeePerGas and maxPriorityFeePerGas specified)', function(done){ + const source = wallet[0].address; + const destination = wallet[1].address; + + const txObject = { + to: destination, + value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')), + gas: web3.utils.toHex(21000), + maxFeePerGas: '0x59682F00', // 1.5 Gwei + maxPriorityFeePerGas: '0x1DCD6500' // .5 Gwei + }; + + web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey, async function(err, signed){ + const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction); + assert(receipt.status === true); + done(); + }); + }); + + it('accounts.signTransaction, (EIP-1559, type 2 specified)', function(done){ + const source = wallet[0].address; + const destination = wallet[1].address; + + const txObject = { + to: destination, + value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')), + gas: web3.utils.toHex(21000), + type: 2 + }; + + web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey, async function(err, signed){ + const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction); + assert(receipt.status === true); + done(); + }); + }); + + it('accounts.signTransaction, (EIP-1559, maxFeePerGas and accessList specified)', function(done){ + const source = wallet[0].address; + const destination = wallet[1].address; + + const txObject = { + to: destination, + value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')), + gas: web3.utils.toHex(21000), + maxFeePerGas: '0x59682F00', // 1.5 Gwei + accessList: [] + }; + + web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey, async function(err, signed){ + const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction); + console.log(receipt); + assert(receipt.status === true); + done(); + }); + }); + it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(){ const source = wallet[0].address; const destination = wallet[1].address; From 6bd70cdfdd729563379a611dadf910e686c79e07 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Fri, 9 Jul 2021 19:54:44 -1000 Subject: [PATCH 02/16] Update gasPrice to geth default minimum --- test/e2e.contract.deploy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e.contract.deploy.js b/test/e2e.contract.deploy.js index 3301555887b..b31ddadfedf 100644 --- a/test/e2e.contract.deploy.js +++ b/test/e2e.contract.deploy.js @@ -19,19 +19,19 @@ describe('contract.deploy [ @E2E ]', function() { var basicOptions = { data: Basic.bytecode, - gasPrice: '1', + gasPrice: '0x3B9ACA00', gas: 4000000 }; var revertsOptions = { data: Reverts.bytecode, - gasPrice: '1', + gasPrice: '0x3B9ACA00', gas: 4000000 } var noBytecodeOptions = { data: '0x', - gasPrice: '1', + gasPrice: '0x3B9ACA00', gas: 4000000 } From 2a85305e7ebe5814af9976ede8721d80151235c6 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Tue, 13 Jul 2021 20:53:56 -1000 Subject: [PATCH 03/16] Replace hex number with number string --- test/e2e.contract.deploy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e.contract.deploy.js b/test/e2e.contract.deploy.js index b31ddadfedf..ff7c8291655 100644 --- a/test/e2e.contract.deploy.js +++ b/test/e2e.contract.deploy.js @@ -19,19 +19,19 @@ describe('contract.deploy [ @E2E ]', function() { var basicOptions = { data: Basic.bytecode, - gasPrice: '0x3B9ACA00', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 }; var revertsOptions = { data: Reverts.bytecode, - gasPrice: '0x3B9ACA00', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 } var noBytecodeOptions = { data: '0x', - gasPrice: '0x3B9ACA00', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 } From 44effcadb52d16cffe44d482e3e9aeddabccaa75 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Tue, 13 Jul 2021 20:54:36 -1000 Subject: [PATCH 04/16] Add test skip if using Ganache --- test/e2e.method.signing.js | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/e2e.method.signing.js b/test/e2e.method.signing.js index dd7f6308f0d..3d38104eb01 100644 --- a/test/e2e.method.signing.js +++ b/test/e2e.method.signing.js @@ -58,6 +58,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('sendSignedTransaction (accounts.signTransaction with signing options)', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -92,6 +95,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('sendSignedTransaction (accounts.signTransaction / without signing options)', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -112,6 +118,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction, (with callback, nonce not specified)', function(done){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -130,6 +139,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction, (EIP-2930, accessList specified)', function(done){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -148,6 +160,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction, (EIP-2930, type 1 specified)', function(done){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -166,6 +181,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction, (EIP-1559, maxFeePerGas and maxPriorityFeePerGas specified)', function(done){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -185,6 +203,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction, (EIP-1559, type 2 specified)', function(done){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -203,6 +224,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction, (EIP-1559, maxFeePerGas and accessList specified)', function(done){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -223,6 +247,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -248,6 +275,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction errors when chain specified without hardfork', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -271,6 +301,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction errors when hardfork specified without chain', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -294,6 +327,9 @@ describe('transaction and message signing [ @E2E ]', function() { }); it('accounts.signTransaction errors when tx signing is invalid', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + const source = wallet[0].address; const destination = wallet[1].address; @@ -319,6 +355,9 @@ describe('transaction and message signing [ @E2E ]', function() { }) it('accounts.signTransaction errors when no transaction is passed', async function(){ + // ganache does not support eth_signTransaction + if (process.env.GANACHE || global.window ) return + try { await web3.eth.accounts.signTransaction(undefined, wallet[0].privateKey); assert.fail() From e7c14d152c0e2ec3d2d7b7f819661fc7e557e6d7 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Tue, 13 Jul 2021 21:05:28 -1000 Subject: [PATCH 05/16] Add done function to ganache skip --- test/e2e.method.signing.js | 112 ++++++++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 32 deletions(-) diff --git a/test/e2e.method.signing.js b/test/e2e.method.signing.js index 3d38104eb01..b1050c18ed5 100644 --- a/test/e2e.method.signing.js +++ b/test/e2e.method.signing.js @@ -33,9 +33,12 @@ describe('transaction and message signing [ @E2E ]', function() { instance = await basic.deploy().send({from: accounts[0]}); }); - it('sendSignedTransaction (with eth.signTransaction)', async function(){ + it('sendSignedTransaction (with eth.signTransaction)', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const destination = wallet[1].address; const source = accounts[0]; // Unlocked geth-dev account @@ -57,9 +60,12 @@ describe('transaction and message signing [ @E2E ]', function() { assert(receipt.status === true); }); - it('sendSignedTransaction (accounts.signTransaction with signing options)', async function(){ + it('sendSignedTransaction (accounts.signTransaction with signing options)', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -94,9 +100,12 @@ describe('transaction and message signing [ @E2E ]', function() { assert(receipt.status === true); }); - it('sendSignedTransaction (accounts.signTransaction / without signing options)', async function(){ + it('sendSignedTransaction (accounts.signTransaction / without signing options)', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -117,9 +126,12 @@ describe('transaction and message signing [ @E2E ]', function() { assert(receipt.status === true); }); - it('accounts.signTransaction, (with callback, nonce not specified)', function(done){ + it('accounts.signTransaction, (with callback, nonce not specified)', function(donedone){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -138,9 +150,12 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-2930, accessList specified)', function(done){ + it('accounts.signTransaction, (EIP-2930, accessList specified)', function(donedone){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -159,9 +174,12 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-2930, type 1 specified)', function(done){ + it('accounts.signTransaction, (EIP-2930, type 1 specified)', function(donedone){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -180,9 +198,12 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-1559, maxFeePerGas and maxPriorityFeePerGas specified)', function(done){ + it('accounts.signTransaction, (EIP-1559, maxFeePerGas and maxPriorityFeePerGas specified)', function(donedone){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -202,9 +223,12 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-1559, type 2 specified)', function(done){ + it('accounts.signTransaction, (EIP-1559, type 2 specified)', function(donedone){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -223,9 +247,12 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-1559, maxFeePerGas and accessList specified)', function(done){ + it('accounts.signTransaction, (EIP-1559, maxFeePerGas and accessList specified)', function(donedone){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -246,9 +273,12 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(){ + it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -274,9 +304,12 @@ describe('transaction and message signing [ @E2E ]', function() { } }); - it('accounts.signTransaction errors when chain specified without hardfork', async function(){ + it('accounts.signTransaction errors when chain specified without hardfork', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -300,9 +333,12 @@ describe('transaction and message signing [ @E2E ]', function() { } }); - it('accounts.signTransaction errors when hardfork specified without chain', async function(){ + it('accounts.signTransaction errors when hardfork specified without chain', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -326,9 +362,12 @@ describe('transaction and message signing [ @E2E ]', function() { } }); - it('accounts.signTransaction errors when tx signing is invalid', async function(){ + it('accounts.signTransaction errors when tx signing is invalid', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const source = wallet[0].address; const destination = wallet[1].address; @@ -354,9 +393,12 @@ describe('transaction and message signing [ @E2E ]', function() { } }) - it('accounts.signTransaction errors when no transaction is passed', async function(){ + it('accounts.signTransaction errors when no transaction is passed', async function(done){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } try { await web3.eth.accounts.signTransaction(undefined, wallet[0].privateKey); @@ -495,9 +537,12 @@ describe('transaction and message signing [ @E2E ]', function() { }) }); - it('eth.personal.sign', async function(){ + it('eth.personal.sign', async function(done){ // ganache does not support eth_sign - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const message = 'hello'; @@ -509,10 +554,13 @@ describe('transaction and message signing [ @E2E ]', function() { const recovered = await web3.eth.personal.ecRecover(message, signature); assert.equal(accounts[1].toLowerCase(), recovered.toLowerCase()); - }); + })done; it('eth.accounts.sign', async function(){ - if (process.env.GANACHE || global.window ) return + if (process.env.GANACHE || global.window ) { + done(); + return + } const message = 'hello'; From 83a7fd81d6c0585ca383fc4becb13cffc567b45c Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Tue, 13 Jul 2021 21:13:09 -1000 Subject: [PATCH 06/16] Add done function to ganache skip --- test/e2e.method.signing.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/e2e.method.signing.js b/test/e2e.method.signing.js index b1050c18ed5..bbd6f76c16f 100644 --- a/test/e2e.method.signing.js +++ b/test/e2e.method.signing.js @@ -126,7 +126,7 @@ describe('transaction and message signing [ @E2E ]', function() { assert(receipt.status === true); }); - it('accounts.signTransaction, (with callback, nonce not specified)', function(donedone){ + it('accounts.signTransaction, (with callback, nonce not specified)', function(done){ // ganache does not support eth_signTransaction if (process.env.GANACHE || global.window ) { done(); @@ -150,7 +150,7 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-2930, accessList specified)', function(donedone){ + it('accounts.signTransaction, (EIP-2930, accessList specified)', function(done){ // ganache does not support eth_signTransaction if (process.env.GANACHE || global.window ) { done(); @@ -174,7 +174,7 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-2930, type 1 specified)', function(donedone){ + it('accounts.signTransaction, (EIP-2930, type 1 specified)', function(done){ // ganache does not support eth_signTransaction if (process.env.GANACHE || global.window ) { done(); @@ -198,7 +198,7 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-1559, maxFeePerGas and maxPriorityFeePerGas specified)', function(donedone){ + it('accounts.signTransaction, (EIP-1559, maxFeePerGas and maxPriorityFeePerGas specified)', function(done){ // ganache does not support eth_signTransaction if (process.env.GANACHE || global.window ) { done(); @@ -223,7 +223,7 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-1559, type 2 specified)', function(donedone){ + it('accounts.signTransaction, (EIP-1559, type 2 specified)', function(done){ // ganache does not support eth_signTransaction if (process.env.GANACHE || global.window ) { done(); @@ -247,7 +247,7 @@ describe('transaction and message signing [ @E2E ]', function() { }); }); - it('accounts.signTransaction, (EIP-1559, maxFeePerGas and accessList specified)', function(donedone){ + it('accounts.signTransaction, (EIP-1559, maxFeePerGas and accessList specified)', function(done){ // ganache does not support eth_signTransaction if (process.env.GANACHE || global.window ) { done(); @@ -554,9 +554,9 @@ describe('transaction and message signing [ @E2E ]', function() { const recovered = await web3.eth.personal.ecRecover(message, signature); assert.equal(accounts[1].toLowerCase(), recovered.toLowerCase()); - })done; + }); - it('eth.accounts.sign', async function(){ + it('eth.accounts.sign', async function(done){ if (process.env.GANACHE || global.window ) { done(); return From a1b683330ed9a4f850bf6bcf572de280b3ef2c73 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Tue, 13 Jul 2021 22:05:15 -1000 Subject: [PATCH 07/16] Update gasPrice params --- test/e2e.ens.js | 2 +- test/e2e.method.call.js | 4 +- test/e2e.method.send.js | 2 +- test/e2e.method.signing.js | 77 ++++++++++++-------------------------- 4 files changed, 27 insertions(+), 58 deletions(-) diff --git a/test/e2e.ens.js b/test/e2e.ens.js index 13b3cc4145d..d3c3eae6742 100644 --- a/test/e2e.ens.js +++ b/test/e2e.ens.js @@ -27,7 +27,7 @@ describe('ENS [ @E2E ]', function () { options = { from: account, gas: 4000000, - gasPrice: 1 + gasPrice: 1000000000 // Default gasPrice set by Geth } }); diff --git a/test/e2e.method.call.js b/test/e2e.method.call.js index c9641d13418..a9135c85f67 100644 --- a/test/e2e.method.call.js +++ b/test/e2e.method.call.js @@ -13,13 +13,13 @@ describe('method.call [ @E2E ]', function () { var basicOptions = { data: Basic.bytecode, - gasPrice: '1', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 }; var miscOptions = { data: Misc.bytecode, - gasPrice: '1', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 }; diff --git a/test/e2e.method.send.js b/test/e2e.method.send.js index b17fb403484..4a47d2a98cf 100644 --- a/test/e2e.method.send.js +++ b/test/e2e.method.send.js @@ -12,7 +12,7 @@ describe('method.send [ @E2E ]', function () { var basicOptions = { data: Basic.bytecode, - gasPrice: '1', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 }; diff --git a/test/e2e.method.signing.js b/test/e2e.method.signing.js index bbd6f76c16f..2e395a05a04 100644 --- a/test/e2e.method.signing.js +++ b/test/e2e.method.signing.js @@ -12,7 +12,7 @@ describe('transaction and message signing [ @E2E ]', function() { const basicOptions = { data: Basic.bytecode, - gasPrice: '1', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 4000000 }; @@ -33,12 +33,9 @@ describe('transaction and message signing [ @E2E ]', function() { instance = await basic.deploy().send({from: accounts[0]}); }); - it('sendSignedTransaction (with eth.signTransaction)', async function(done){ + it('sendSignedTransaction (with eth.signTransaction)', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const destination = wallet[1].address; const source = accounts[0]; // Unlocked geth-dev account @@ -51,7 +48,7 @@ describe('transaction and message signing [ @E2E ]', function() { from: source, value: web3.utils.toHex(web3.utils.toWei('0.1', 'ether')), gasLimit: web3.utils.toHex(21000), - gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')) + gasPrice: web3.utils.toHex('1000000000') }; const signed = await web3.eth.signTransaction(rawTx); @@ -60,12 +57,9 @@ describe('transaction and message signing [ @E2E ]', function() { assert(receipt.status === true); }); - it('sendSignedTransaction (accounts.signTransaction with signing options)', async function(done){ + it('sendSignedTransaction (accounts.signTransaction with signing options)', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const source = wallet[0].address; const destination = wallet[1].address; @@ -100,12 +94,9 @@ describe('transaction and message signing [ @E2E ]', function() { assert(receipt.status === true); }); - it('sendSignedTransaction (accounts.signTransaction / without signing options)', async function(done){ + it('sendSignedTransaction (accounts.signTransaction / without signing options)', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const source = wallet[0].address; const destination = wallet[1].address; @@ -267,18 +258,14 @@ describe('transaction and message signing [ @E2E ]', function() { web3.eth.accounts.signTransaction(txObject, wallet[0].privateKey, async function(err, signed){ const receipt = await web3.eth.sendSignedTransaction(signed.rawTransaction); - console.log(receipt); assert(receipt.status === true); done(); }); }); - it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(done){ + it('accounts.signTransaction errors when common, chain and hardfork all defined', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const source = wallet[0].address; const destination = wallet[1].address; @@ -304,12 +291,9 @@ describe('transaction and message signing [ @E2E ]', function() { } }); - it('accounts.signTransaction errors when chain specified without hardfork', async function(done){ + it('accounts.signTransaction errors when chain specified without hardfork', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const source = wallet[0].address; const destination = wallet[1].address; @@ -333,12 +317,9 @@ describe('transaction and message signing [ @E2E ]', function() { } }); - it('accounts.signTransaction errors when hardfork specified without chain', async function(done){ + it('accounts.signTransaction errors when hardfork specified without chain', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const source = wallet[0].address; const destination = wallet[1].address; @@ -362,12 +343,9 @@ describe('transaction and message signing [ @E2E ]', function() { } }); - it('accounts.signTransaction errors when tx signing is invalid', async function(done){ + it('accounts.signTransaction errors when tx signing is invalid', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const source = wallet[0].address; const destination = wallet[1].address; @@ -393,12 +371,9 @@ describe('transaction and message signing [ @E2E ]', function() { } }) - it('accounts.signTransaction errors when no transaction is passed', async function(done){ + it('accounts.signTransaction errors when no transaction is passed', async function(){ // ganache does not support eth_signTransaction - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return try { await web3.eth.accounts.signTransaction(undefined, wallet[0].privateKey); @@ -470,7 +445,7 @@ describe('transaction and message signing [ @E2E ]', function() { from: wallet[0], to: instance.options.address, data: data, - gasPrice: '1', + gasPrice: '1000000000', gas: 4000000 } @@ -537,12 +512,9 @@ describe('transaction and message signing [ @E2E ]', function() { }) }); - it('eth.personal.sign', async function(done){ + it('eth.personal.sign', async function(){ // ganache does not support eth_sign - if (process.env.GANACHE || global.window ) { - done(); - return - } + if (process.env.GANACHE || global.window ) return const message = 'hello'; @@ -556,11 +528,8 @@ describe('transaction and message signing [ @E2E ]', function() { assert.equal(accounts[1].toLowerCase(), recovered.toLowerCase()); }); - it('eth.accounts.sign', async function(done){ - if (process.env.GANACHE || global.window ) { - done(); - return - } + it('eth.accounts.sign', async function(){ + if (process.env.GANACHE || global.window ) return const message = 'hello'; From dd8c835deee786b91149f0f0e930abc38769f127 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 14 Jul 2021 09:28:37 -1000 Subject: [PATCH 08/16] Bump gasPrice to Geth default --- scripts/js/ens.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/js/ens.js b/scripts/js/ens.js index e9c7e4a965c..f119552056c 100644 --- a/scripts/js/ens.js +++ b/scripts/js/ens.js @@ -12,7 +12,7 @@ async function setupENS(web3) { const options = { bytecode: undefined, - gasPrice: '1', + gasPrice: '1000000000', // Default gasPrice set by Geth gas: 5500000 } From 8e82988740f7906582a42b41d669146d2d96a273 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Wed, 14 Jul 2021 09:53:40 -1000 Subject: [PATCH 09/16] Bump docker geth version to stable --- scripts/e2e.geth.automine.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/e2e.geth.automine.sh b/scripts/e2e.geth.automine.sh index 3612ef682db..0282d15d4e7 100755 --- a/scripts/e2e.geth.automine.sh +++ b/scripts/e2e.geth.automine.sh @@ -24,7 +24,7 @@ echo " " # Launch client w/ two unlocked accounts. # + accounts[0] default geth unlocked bal = ~infinity # + accounts[1] unlocked, signing password = 'left-hand-of-darkness' -geth-dev-assistant --period 2 --accounts 1 --tag 'v1.10.3' +geth-dev-assistant --period 2 --accounts 1 --tag 'stable' # Test GETH_AUTOMINE=true nyc --no-clean --silent _mocha -- \ From 9d0aa3e3cc4891c8a785ab2665c0de5a9a271980 Mon Sep 17 00:00:00 2001 From: jdevcs Date: Fri, 16 Jul 2021 20:00:51 +0200 Subject: [PATCH 10/16] Gas price type number for 1 Gwei --- scripts/js/ens.js | 2 +- test/e2e.contract.deploy.js | 6 +++--- test/e2e.method.call.js | 4 ++-- test/e2e.method.signing.js | 4 ++-- test/helpers/test.utils.js | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/js/ens.js b/scripts/js/ens.js index f119552056c..8fad5d4e446 100644 --- a/scripts/js/ens.js +++ b/scripts/js/ens.js @@ -12,7 +12,7 @@ async function setupENS(web3) { const options = { bytecode: undefined, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 5500000 } diff --git a/test/e2e.contract.deploy.js b/test/e2e.contract.deploy.js index ff7c8291655..51dd3868e50 100644 --- a/test/e2e.contract.deploy.js +++ b/test/e2e.contract.deploy.js @@ -19,19 +19,19 @@ describe('contract.deploy [ @E2E ]', function() { var basicOptions = { data: Basic.bytecode, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 }; var revertsOptions = { data: Reverts.bytecode, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 } var noBytecodeOptions = { data: '0x', - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 } diff --git a/test/e2e.method.call.js b/test/e2e.method.call.js index a9135c85f67..4aa67e719cd 100644 --- a/test/e2e.method.call.js +++ b/test/e2e.method.call.js @@ -13,13 +13,13 @@ describe('method.call [ @E2E ]', function () { var basicOptions = { data: Basic.bytecode, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 }; var miscOptions = { data: Misc.bytecode, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 }; diff --git a/test/e2e.method.signing.js b/test/e2e.method.signing.js index 2e395a05a04..4bfa2649812 100644 --- a/test/e2e.method.signing.js +++ b/test/e2e.method.signing.js @@ -12,7 +12,7 @@ describe('transaction and message signing [ @E2E ]', function() { const basicOptions = { data: Basic.bytecode, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 }; @@ -445,7 +445,7 @@ describe('transaction and message signing [ @E2E ]', function() { from: wallet[0], to: instance.options.address, data: data, - gasPrice: '1000000000', + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 } diff --git a/test/helpers/test.utils.js b/test/helpers/test.utils.js index 67922e03aff..f8e99d8bf6e 100644 --- a/test/helpers/test.utils.js +++ b/test/helpers/test.utils.js @@ -25,7 +25,7 @@ var mine = async function(web3, account) { await web3.eth.sendTransaction({ from: account, to: account, - gasPrice: '1', + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000, value: web3.utils.toWei('0', 'ether'), }); From 2015ad41ac4d88ba3b9b4c663f136b0a1716a71d Mon Sep 17 00:00:00 2001 From: jdevcs Date: Fri, 16 Jul 2021 20:01:44 +0200 Subject: [PATCH 11/16] gasPrice type and backfills timeout change --- test/e2e.contract.events.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e.contract.events.js b/test/e2e.contract.events.js index 2b51a570694..21ff0aecade 100644 --- a/test/e2e.contract.events.js +++ b/test/e2e.contract.events.js @@ -17,7 +17,7 @@ describe('contract.events [ @E2E ]', function() { var basicOptions = { data: Basic.bytecode, - gasPrice: '1', + gasPrice: 1000000000,// Default gasPrice set by Geth gas: 4000000 }; @@ -289,7 +289,7 @@ describe('contract.events [ @E2E ]', function() { let contract; const options = { - gasPrice: '1', + gasPrice: 1000000000,// Default gasPrice set by Geth gas: 4000000 }; @@ -336,7 +336,7 @@ describe('contract.events [ @E2E ]', function() { // and geth instamine's websockets connection is too fragile for the tests in this file. it('backfills missed events when auto-reconnecting', function(){ if(!process.env.GANACHE) return; - this.timeout(10000); + this.timeout(20000); let counter = 0; const acc = accounts[0]; From 45ab40c2fa1c7764b1c69f37763560c7f579b3b1 Mon Sep 17 00:00:00 2001 From: jdevcs Date: Fri, 16 Jul 2021 20:02:17 +0200 Subject: [PATCH 12/16] gasPrice type and test acct creation --- test/e2e.method.send.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/e2e.method.send.js b/test/e2e.method.send.js index 4a47d2a98cf..857a70361cf 100644 --- a/test/e2e.method.send.js +++ b/test/e2e.method.send.js @@ -12,14 +12,27 @@ describe('method.send [ @E2E ]', function () { var basicOptions = { data: Basic.bytecode, - gasPrice: '1000000000', // Default gasPrice set by Geth + gasPrice: 1000000000, // Default gasPrice set by Geth gas: 4000000 }; describe('http', function () { before(async function () { web3 = new Web3('http://localhost:8545'); + + + var testAcctPass = "left-hand-of-darkness"; + const account = await web3.eth.personal.newAccount(testAcctPass); + await web3.eth.personal.unlockAccount(account, testAcctPass, 1000000); + + const weiBalance = web3.utils.toWei('1000', 'ether'); accounts = await web3.eth.getAccounts(); + await web3.eth.sendTransaction({ + from: accounts[0], + to: account, + value: weiBalance + }); + basic = new web3.eth.Contract(Basic.abi, basicOptions); instance = await basic.deploy().send({from: accounts[0]}); From 13f3b7b984a1b30dc6c1d3aff01c03aadcd43b54 Mon Sep 17 00:00:00 2001 From: jdevcs Date: Mon, 19 Jul 2021 17:14:01 +0200 Subject: [PATCH 13/16] added nonce for geth auto nonce issue, removed auto acct creation --- test/e2e.method.send.js | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/test/e2e.method.send.js b/test/e2e.method.send.js index 857a70361cf..2af7e727df2 100644 --- a/test/e2e.method.send.js +++ b/test/e2e.method.send.js @@ -20,29 +20,20 @@ describe('method.send [ @E2E ]', function () { before(async function () { web3 = new Web3('http://localhost:8545'); - - var testAcctPass = "left-hand-of-darkness"; - const account = await web3.eth.personal.newAccount(testAcctPass); - await web3.eth.personal.unlockAccount(account, testAcctPass, 1000000); - - const weiBalance = web3.utils.toWei('1000', 'ether'); accounts = await web3.eth.getAccounts(); - await web3.eth.sendTransaction({ - from: accounts[0], - to: account, - value: weiBalance - }); - - basic = new web3.eth.Contract(Basic.abi, basicOptions); - instance = await basic.deploy().send({from: accounts[0]}); + + var nonceVal = await web3.eth.getTransactionCount(accounts[0]); + + instance = await basic.deploy().send({from: accounts[0], nonce: nonceVal}); }); it('returns a receipt', async function () { + var nonceVal = await web3.eth.getTransactionCount(accounts[0]); var receipt = await instance .methods .setValue('1') - .send({from: accounts[0]}); + .send({from: accounts[0], nonceVal}); assert(receipt.status === true); assert(web3.utils.isHexStrict(receipt.transactionHash)); @@ -50,10 +41,11 @@ describe('method.send [ @E2E ]', function () { it('errors on OOG', async function () { try { + var nonceVal = await web3.eth.getTransactionCount(accounts[0]); await instance .methods .setValue('1') - .send({from: accounts[0], gas: 100}); + .send({from: accounts[0], gas: 100, nonce: nonceVal}); assert.fail(); @@ -127,16 +119,19 @@ describe('method.send [ @E2E ]', function () { web3 = new Web3('ws://localhost:' + port); accounts = await web3.eth.getAccounts(); - + basic = new web3.eth.Contract(Basic.abi, basicOptions); - instance = await basic.deploy().send({from: accounts[0]}); + + var nonceVal = await web3.eth.getTransactionCount(accounts[0]); + instance = await basic.deploy().send({from: accounts[0], nonce: nonceVal }); }) it('returns a receipt', async function () { + var nonceVal = await web3.eth.getTransactionCount(accounts[0]); var receipt = await instance .methods .setValue('1') - .send({from: accounts[0]}); + .send({from: accounts[0], nonce: nonceVal}); assert(receipt.status === true); assert(web3.utils.isHexStrict(receipt.transactionHash)); @@ -144,10 +139,11 @@ describe('method.send [ @E2E ]', function () { it('errors on OOG', async function () { try { + var nonceVal = await web3.eth.getTransactionCount(accounts[0]); await instance .methods .setValue('1') - .send({from: accounts[0], gas: 100}); + .send({from: accounts[0], gas: 100, nonce: nonceVal}); assert.fail(); From 3cc1754c3f96872a893cb499d7068cb3adca8d6a Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 19 Jul 2021 10:19:02 -1000 Subject: [PATCH 14/16] Remove redundant London test. Add gasLimit field to London test --- test/eth.accounts.signTransaction.js | 35 +++++++--------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/test/eth.accounts.signTransaction.js b/test/eth.accounts.signTransaction.js index 132c773100d..f44d824b6f5 100644 --- a/test/eth.accounts.signTransaction.js +++ b/test/eth.accounts.signTransaction.js @@ -567,6 +567,7 @@ var tests = [ maxPriorityFeePerGas: '0x3B9ACA00', maxFeePerGas: '0xB2D05E00', gas: 27200, + gasLimit: '0x6A40', to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test value: "1000000000", @@ -588,29 +589,9 @@ var tests = [ transaction: { chainId: 1, nonce: 0, - gas: 27200, - to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', - toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test - value: "1000000000", - data: "", - common: commonLondon, - accessList: accessList - }, - // signature from eth_signTransaction - rawTransaction: "0x02f8ca0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a780a0e3a2e10c7d3af3407ec2d38c64788d6673926e9b28d6d2e7df3c94cdf0548233a00ad3e5faafaf3a9350ab16c1be0198ce9ff3c6bef0b91e05488d757f07de9557", - oldSignature: "0x02f8ca0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a780a0e3a2e10c7d3af3407ec2d38c64788d6673926e9b28d6d2e7df3c94cdf0548233a00ad3e5faafaf3a9350ab16c1be0198ce9ff3c6bef0b91e05488d757f07de9557", - transactionHash: "0xbc2c9edab3d4e3a795fa402b52d6149e874de15f0cc6c0858eb34e1fe1ef31fe", - messageHash: "0xa3a2cdc45e9cefb9a614ead90ce65f68bcf8a90dbe0ccbd84c1b62403bd05346" - }, - { - // test #26 - address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', - iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', - privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', - transaction: { - chainId: 1, - nonce: 0, - gas: 27200, + maxPriorityFeePerGas: '0x3B9ACA00', + maxFeePerGas: '0xB2D05E00', + gasLimit: '0x6A40', to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test value: "1000000000", @@ -618,10 +599,10 @@ var tests = [ common: commonLondon }, // signature from eth_signTransaction - rawTransaction: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833", - oldSignature: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833", - transactionHash: "0x488a813f2286f7c015947aa13133bdae49ec75ae1c8f5eba80034d71a038dca8", - messageHash: "0xcd6d6dee80ecc38f1b22f2d128bf6043dc41079fc913183a8995b5b3e187df61" + rawTransaction: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36", + oldSignature: "0x02f86e0180843b9aca0084b2d05e00826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0d1290a118d51918c1ca17e3af0267c45efcd745cf42e78eabc444c424d6bcf37a003c81e1fda169575023a94200ee034128747f91020e704abaee30dbcfc785c36", + transactionHash: "0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e", + messageHash: "0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b" }, ]; From 2c86b67eda1c9f56d3c8b925822548c15ef302c0 Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 19 Jul 2021 10:34:54 -1000 Subject: [PATCH 15/16] Add validation for tx.maxPriorityFeePerGas and tx.maxFeePerGas --- packages/web3-eth-accounts/src/index.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/web3-eth-accounts/src/index.js b/packages/web3-eth-accounts/src/index.js index 43f87bc5672..710b27983ba 100644 --- a/packages/web3-eth-accounts/src/index.js +++ b/packages/web3-eth-accounts/src/index.js @@ -297,14 +297,24 @@ function _validateTransactionForSigning(tx) { ); } - if (!tx.gas && !tx.gasLimit) { + if ( + (!tx.gas && !tx.gasLimit) && + (!tx.maxPriorityFeePerGas && !tx.maxFeePerGas) + ) { return new Error('"gas" is missing'); } - if (tx.nonce < 0 || - tx.gas < 0 || - tx.gasPrice < 0 || - tx.chainId < 0) { + if (tx.gas && tx.gasPrice) { + if (tx.gas < 0 || tx.gasPrice < 0) { + return new Error('Gas, gasPrice, nonce or chainId is lower than 0'); + } + } else { + if (tx.maxPriorityFeePerGas < 0 || tx.maxFeePerGas < 0) { + return new Error('maxPriorityFeePerGas or maxFeePerGas is lower than 0'); + } + } + + if (tx.nonce < 0 || tx.chainId < 0) { return new Error('Gas, gasPrice, nonce or chainId is lower than 0'); } From 3661734ded72babff30a1d4c08692c63fe3cfcac Mon Sep 17 00:00:00 2001 From: Wyatt Barnes Date: Mon, 19 Jul 2021 11:46:30 -1000 Subject: [PATCH 16/16] Add additional 1559 tests --- test/eth.accounts.signTransaction.js | 77 +++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/test/eth.accounts.signTransaction.js b/test/eth.accounts.signTransaction.js index f44d824b6f5..6d1331d9388 100644 --- a/test/eth.accounts.signTransaction.js +++ b/test/eth.accounts.signTransaction.js @@ -604,6 +604,51 @@ var tests = [ transactionHash: "0x82c19b39a6b7eaa0492863a8b236fad5018f267b4977c270ddd5228c4cbda60e", messageHash: "0xe3beea0918f445c21eb2f42e3cbc3c5d54321ec642f47d12c473b2765df97f2b" }, + { + // test #26 + address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', + iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', + privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', + transaction: { + chainId: 1, + nonce: 0, + gas: 27200, + gasLimit: '0x6A40', + to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', + toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test + value: "1000000000", + data: "", + common: commonLondon + }, + // signature from eth_signTransaction + rawTransaction: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833", + oldSignature: "0x02f86e0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080c080a0eb8ca6017e6926503ce11c404ba9b61f30d53ea934857e4f4489f43a6c189cf8a03655ba42b2fdcabdb3363cb39e7f672baa91455632e02bab27f92e1a275ca833", + transactionHash: "0x488a813f2286f7c015947aa13133bdae49ec75ae1c8f5eba80034d71a038dca8", + messageHash: "0xcd6d6dee80ecc38f1b22f2d128bf6043dc41079fc913183a8995b5b3e187df61" + }, + { + // test #27 + address: '0x2c7536E3605D9C16a7a3D7b1898e529396a65c23', + iban: 'XE0556YCRTEZ9JALZBSCXOK4UJ5F3HN03DV', + privateKey: '0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318', + transaction: { + chainId: 1, + nonce: 0, + gas: 27200, + gasLimit: '0x6A40', + to: '0xF0109fC8DF283027b6285cc889F5aA624EaC1F55', + toIban: 'XE04S1IRT2PR8A8422TPBL9SR6U0HODDCUT', // will be switched to "to" in the test + value: "1000000000", + data: "", + common: commonLondon, + accessList: accessList + }, + // signature from eth_signTransaction + rawTransaction: "0x02f8ca0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a780a0e3a2e10c7d3af3407ec2d38c64788d6673926e9b28d6d2e7df3c94cdf0548233a00ad3e5faafaf3a9350ab16c1be0198ce9ff3c6bef0b91e05488d757f07de9557", + oldSignature: "0x02f8ca0180843b9aca00843b9aca0e826a4094f0109fc8df283027b6285cc889f5aa624eac1f55843b9aca0080f85bf859940000000000000000000000000000000000000101f842a00000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000060a780a0e3a2e10c7d3af3407ec2d38c64788d6673926e9b28d6d2e7df3c94cdf0548233a00ad3e5faafaf3a9350ab16c1be0198ce9ff3c6bef0b91e05488d757f07de9557", + transactionHash: "0xbc2c9edab3d4e3a795fa402b52d6149e874de15f0cc6c0858eb34e1fe1ef31fe", + messageHash: "0xa3a2cdc45e9cefb9a614ead90ce65f68bcf8a90dbe0ccbd84c1b62403bd05346" + }, ]; describe("eth", function () { @@ -669,7 +714,21 @@ describe("eth", function () { }); it("signTransaction using the iban as \"to\" must compare to eth_signTransaction", function(done) { - var ethAccounts = new Accounts(); + var provider = new FakeHttpProvider(); + var web3 = new Web3(provider); + + provider.injectResult( + test.transaction.common.hardfork === 'london' ? + postEip1559Block: + preEip1559Block + ); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_getBlockByNumber'); + assert.deepEqual(payload.params, ['latest', false]); + }); + + var ethAccounts = new Accounts(web3); var testAccount = ethAccounts.privateKeyToAccount(test.privateKey); assert.equal(testAccount.address, test.address); @@ -914,7 +973,21 @@ describe("eth", function () { }); it("recoverTransaction, must recover signature", function(done) { - var ethAccounts = new Accounts(); + var provider = new FakeHttpProvider(); + var web3 = new Web3(provider); + + provider.injectResult( + test.transaction.common.hardfork === 'london' ? + postEip1559Block: + preEip1559Block + ); + provider.injectValidation(function (payload) { + assert.equal(payload.jsonrpc, '2.0'); + assert.equal(payload.method, 'eth_getBlockByNumber'); + assert.deepEqual(payload.params, ['latest', false]); + }); + + var ethAccounts = new Accounts(web3); var testAccount = ethAccounts.privateKeyToAccount(test.privateKey); assert.equal(testAccount.address, test.address);