Skip to content

Commit

Permalink
Update ethereum version for correct transaction root calculation (#191)
Browse files Browse the repository at this point in the history
* Add uncles test

* Add transactions test

* Comment cleanup

* Update ethereum version

* Fix transactionRoot already hashed

* Fix all tests

Co-authored-by: tgmichel <telmo@purestake.com>
  • Loading branch information
sorpaas and tgmichel authored Nov 5, 2020
1 parent 80069ed commit 95aa393
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 57 deletions.
116 changes: 69 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions ts-tests/tests/test-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,17 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => {
extraData: "0x",
gasLimit: 0,
gasUsed: 0,
//hash: "0x14fe6f7c93597f79b901f8b5d7a84277a90915b8d355959b587e18de34f1dc17",
logsBloom:
"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x0000000000000000000000000000000000000000",
number: 0,
//parentHash: "0x2cc74f91423ba20e9bb0b2c7d8924eacd14bc98aa1daad078f8844e529221cde",
receiptsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 501,
stateRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
timestamp: 0,
totalDifficulty: null,
//transactions: [],
transactionsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
//uncles: []
});

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",
Expand All @@ -50,6 +43,20 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => {
expect(block.timestamp).to.be.a("number");
});

step("should have empty uncles and correct sha3Uncles", async function () {
const block = await context.web3.eth.getBlock(0);
expect(block.uncles).to.be.a("array").empty;
expect(block.sha3Uncles).to.equal("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347");
});

step("should have empty transactions and correct transactionRoot", async function () {
const block = await context.web3.eth.getBlock(0);
expect(block.transactions).to.be.a("array").empty;
expect(block).to.include({
transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
});
});

let firstBlockCreated = false;
step("should be at block 1 after block production", async function () {
this.timeout(15000);
Expand Down Expand Up @@ -85,7 +92,7 @@ describeWithFrontier("Frontier RPC (Block)", `simple-specs.json`, (context) => {
timestamp: 6,
totalDifficulty: null,
//transactions: [],
transactionsRoot: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
//uncles: []
});
previousBlock = block;
Expand Down
Loading

0 comments on commit 95aa393

Please sign in to comment.