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 test for retrieving block by hash #110

Closed
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
41 changes: 41 additions & 0 deletions ts-tests/tests/test-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,45 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => {
expect(block.hash).to.not.equal(previousBlock.hash);
expect(block.parentHash).to.equal(previousBlock.hash);
});

step("retrieve block information by hash", async function () {
expect(firstBlockCreated).to.be.true;

const block_pre = await context.web3.eth.getBlock("latest");
const hash = block_pre.hash;
const block = await context.web3.eth.getBlock(hash);
expect(block).to.include({
author: "0x0000000000000000000000000000000000000000",
difficulty: "0",
extraData: "0x0000000000000000000000000000000000000000000000000000000000000000",
gasLimit: 0,
gasUsed: 0,
//hash: "0x14fe6f7c93597f79b901f8b5d7a84277a90915b8d355959b587e18de34f1dc17",
logsBloom:
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
number: 1,
//parentHash: "0x04540257811b46d103d9896e7807040e7de5080e285841c5430d1a81588a0ce4",
receiptsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
sha3Uncles: "0x0000000000000000000000000000000000000000000000000000000000000000",
size: 539,
stateRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
//timestamp: 1595012243836,
totalDifficulty: null,
//transactions: [],
transactionsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
//uncles: []
});
previousBlock = block;

expect(block.transactions).to.be.a("array").empty;
expect(block.uncles).to.be.a("array").empty;
expect((block as any).sealFields).to.eql([
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000",
]);
expect(block.hash).to.be.a("string").lengthOf(66);
expect(block.parentHash).to.be.a("string").lengthOf(66);
expect(block.timestamp).to.be.a("number");
});
});