Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for transactionPollingTimeout #3533

Merged
merged 6 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions docs/web3-eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,20 @@ Returns

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


-------
Example
-------

.. code-block:: javascript

web3.eth.transactionBlockTimeout;
> 50

// set the transaction block timeout
web3.eth.transactionBlockTimeout = 100;


------------------------------------------------------------------------------

.. _web3-module-transactionconfirmationblocks:
Expand All @@ -378,6 +392,20 @@ Returns

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


-------
Example
-------

.. code-block:: javascript

web3.eth.transactionConfirmationBlocks;
> 24

// set the transaction confirmations blocks
web3.eth.transactionConfirmationBlocks = 50;


------------------------------------------------------------------------------

.. _web3-module-transactionpollingtimeout:
Expand All @@ -398,6 +426,20 @@ Returns

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


-------
Example
-------

.. code-block:: javascript

web3.eth.transactionPollingTimeout;
> 750

// set the transaction polling timeout
web3.eth.transactionPollingTimeout = 1000;


------------------------------------------------------------------------------

.. _web3-module-handlerevert:
Expand All @@ -424,6 +466,20 @@ Returns

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


-------
Example
-------

.. code-block:: javascript

web3.eth.handlRevert;
> false

// turn revert handling on
web3.eth.handleRevert = true;


------------------------------------------------------------------------------

getProtocolVersion
Expand Down
38 changes: 38 additions & 0 deletions test/e2e.method.send.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,44 @@ describe('method.send [ @E2E ]', function () {
assert(receipt.status === false);
}
});

describe('transactionPollingTimeout', function(){
// Test requires a node auto mining at intervals
if(!process.env.GETH_AUTOMINE) return;

// Geth interval is 2s so these txs w/ .25s polling timeouts
// should error before a single block resolves.
it('is configurable for web3.eth methods', async function(){
web3.eth.transactionPollingTimeout = .25;

try {
await web3.eth.sendTransaction({
from: accounts[0],
to: accounts[1],
value: web3.utils.toWei('1', 'ether'),
gas: 21000,
gasPrice: 1
});
assert.fail();
} catch(err){
assert(err.message.includes('Transaction was not mined within 0.25 seconds'))
}
});

it('is configurable for contract methods', async function(){
web3.eth.transactionPollingTimeout = .25;

try {
await instance
.methods
.setValue('1')
.send({from: accounts[0]});
assert.fail();
} catch(err){
assert(err.message.includes('Transaction was not mined within 0.25 seconds'))
}
})
});
});

describe('ws', function () {
Expand Down