Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Get logs returns correct response (#211)
Browse files Browse the repository at this point in the history
Add regression test to ensure that `eth_newFilter` and `eth_getLogs` returns properly formatted `id`, `logIndex`, and `transactionIndex`.
  • Loading branch information
eshaben authored and davidmurdoch committed Dec 18, 2018
1 parent 870a8a7 commit 45301c2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,40 @@ var tests = function(web3, EventTest) {
});
});

// NOTE! This test relies on the events triggered in the tests above.
it("should return logs with correctly formatted logIndex and transactionIndex", function(done) {
var provider = web3.currentProvider;

provider.send(
{
jsonrpc: "2.0",
method: "eth_getLogs",
params: [
{
fromBlock: "0x0",
toBlock: "latest",
topics: [
"0xc54307031d9aa93e0568c363be84a9400dce343fef6a2851d55662a6af1a29da",
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000006"
]
}
],
id: new Date().getTime()
},
function(err, result) {
if (err) {
return done(err);
}
const logIndex = result.result[0].logIndex;
const transactionIndex = result.result[0].transactionIndex;
assert.strictEqual(logIndex, "0x0");
assert.strictEqual(transactionIndex, "0x0");
done();
}
);
});

it("always returns a change for every new block subscription when instamining", function(done) {
var provider = web3.currentProvider;

Expand Down
28 changes: 28 additions & 0 deletions test/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,34 @@ const tests = function(web3) {
});
});

describe("eth_newFilter", function() {
it("creates a new filter and returns the correctly formatted result", function(done) {
var provider = web3.currentProvider;

provider.send(
{
jsonrpc: "2.0",
method: "eth_newFilter",
params: [
{
fromBlock: "0x0",
address: accounts[0],
topics: []
}
],
id: new Date().getTime()
},
function(err, result) {
if (err) {
return done(err);
}
assert.strictEqual(result.result, "0x1");
done();
}
);
});
});

describe("contract scenario", function() {
// These are expected to be run in order.
let initialTransactionHash;
Expand Down

0 comments on commit 45301c2

Please sign in to comment.