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

Reproduction case for 3379 #3394

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion scripts/e2e.geth.automine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 'stable'
geth-dev-assistant --period 20 --accounts 1 --tag 'stable'

# Test
GETH_AUTOMINE=true nyc --no-clean --silent _mocha -- \
Expand Down
34 changes: 33 additions & 1 deletion test/e2e.contract.events.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ var Parent = require('./sources/Parent');
var utils = require('./helpers/test.utils');
var Web3 = utils.getWeb3();

async function delay(secs=0){
return new Promise(resolve => setTimeout(() => resolve(), secs * 1000))
}

describe('contract.events [ @E2E ]', function() {
this.timeout(25000);
// `getPastEvents` not working with Geth instamine over websockets.
if (process.env.GETH_INSTAMINE) return;
//if (process.env.GETH_INSTAMINE) return;

var web3;
var accounts;
Expand All @@ -30,6 +35,33 @@ describe('contract.events [ @E2E ]', function() {
instance = await basic.deploy().send({from: accounts[0]});
});

it.only('subscribes to events from a block numbered less than 10', async function(){
// Only test geth, automining at 20s interval
if (!process.env.GETH_AUTOMINE) return;

return new Promise(async function(resolve){
web3.eth.subscribe('logs', {}, function(err, event){
assert(event.blockNumber < 10);

if (!err){
console.log(`EVENT --> ${JSON.stringify(event, null, ' ')}`);
resolve();
} else {
console.log("err:" + err);
reject();
}
});

const startingBlock = await web3.eth.getBlockNumber();
console.log(`startingBlock = ${startingBlock}`);

await instance
.methods
.firesEvent(accounts[0], 1)
.send({from: accounts[0]});
});
});

it('contract.getPastEvents', async function(){
await instance
.methods
Expand Down