Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 816af22

Browse files
cgeweckeryanio
andauthored
Add tests for transactionPollingTimeout (#3533)
* Add tests for transactionPollingTimeout * Add examples of configuring method setting in docs Co-authored-by: Ryan Ghods <[email protected]>
1 parent a434ce1 commit 816af22

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

docs/web3-eth.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,20 @@ Returns
358358

359359
``number``: The current value of transactionBlockTimeout (default: 50)
360360

361+
362+
-------
363+
Example
364+
-------
365+
366+
.. code-block:: javascript
367+
368+
web3.eth.transactionBlockTimeout;
369+
> 50
370+
371+
// set the transaction block timeout
372+
web3.eth.transactionBlockTimeout = 100;
373+
374+
361375
------------------------------------------------------------------------------
362376

363377
.. _web3-module-transactionconfirmationblocks:
@@ -378,6 +392,20 @@ Returns
378392

379393
``number``: The current value of transactionConfirmationBlocks (default: 24)
380394

395+
396+
-------
397+
Example
398+
-------
399+
400+
.. code-block:: javascript
401+
402+
web3.eth.transactionConfirmationBlocks;
403+
> 24
404+
405+
// set the transaction confirmations blocks
406+
web3.eth.transactionConfirmationBlocks = 50;
407+
408+
381409
------------------------------------------------------------------------------
382410

383411
.. _web3-module-transactionpollingtimeout:
@@ -398,6 +426,20 @@ Returns
398426

399427
``number``: The current value of transactionPollingTimeout (default: 750)
400428

429+
430+
-------
431+
Example
432+
-------
433+
434+
.. code-block:: javascript
435+
436+
web3.eth.transactionPollingTimeout;
437+
> 750
438+
439+
// set the transaction polling timeout
440+
web3.eth.transactionPollingTimeout = 1000;
441+
442+
401443
------------------------------------------------------------------------------
402444

403445
.. _web3-module-handlerevert:
@@ -424,6 +466,20 @@ Returns
424466

425467
``boolean``: The current value of ``handleRevert`` (default: false)
426468

469+
470+
-------
471+
Example
472+
-------
473+
474+
.. code-block:: javascript
475+
476+
web3.eth.handlRevert;
477+
> false
478+
479+
// turn revert handling on
480+
web3.eth.handleRevert = true;
481+
482+
427483
------------------------------------------------------------------------------
428484

429485
getProtocolVersion

test/e2e.method.send.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,44 @@ describe('method.send [ @E2E ]', function () {
6565
assert(receipt.status === false);
6666
}
6767
});
68+
69+
describe('transactionPollingTimeout', function(){
70+
// Test requires a node auto mining at intervals
71+
if(!process.env.GETH_AUTOMINE) return;
72+
73+
// Geth interval is 2s so these txs w/ .25s polling timeouts
74+
// should error before a single block resolves.
75+
it('is configurable for web3.eth methods', async function(){
76+
web3.eth.transactionPollingTimeout = .25;
77+
78+
try {
79+
await web3.eth.sendTransaction({
80+
from: accounts[0],
81+
to: accounts[1],
82+
value: web3.utils.toWei('1', 'ether'),
83+
gas: 21000,
84+
gasPrice: 1
85+
});
86+
assert.fail();
87+
} catch(err){
88+
assert(err.message.includes('Transaction was not mined within 0.25 seconds'))
89+
}
90+
});
91+
92+
it('is configurable for contract methods', async function(){
93+
web3.eth.transactionPollingTimeout = .25;
94+
95+
try {
96+
await instance
97+
.methods
98+
.setValue('1')
99+
.send({from: accounts[0]});
100+
assert.fail();
101+
} catch(err){
102+
assert(err.message.includes('Transaction was not mined within 0.25 seconds'))
103+
}
104+
})
105+
});
68106
});
69107

70108
describe('ws', function () {

0 commit comments

Comments
 (0)