Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #52 from ethereumjs/genesis-timestamp
Browse files Browse the repository at this point in the history
Add timestamp field to setGenesisParams()
  • Loading branch information
holgerd77 committed Sep 21, 2018
2 parents 99e9f9c + 807fbf2 commit 2bda290
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions header.js
Expand Up @@ -275,6 +275,7 @@ BlockHeader.prototype.isGenesis = function () {
* @method setGenesisParams
*/
BlockHeader.prototype.setGenesisParams = function () {
this.timestamp = this._common.genesis().timestamp
this.gasLimit = this._common.genesis().gasLimit
this.difficulty = this._common.genesis().difficulty
this.extraData = this._common.genesis().extraData
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -28,7 +28,7 @@
"homepage": "https://github.com/ethereumjs/ethereumjs-block#readme",
"dependencies": {
"async": "^2.0.1",
"ethereumjs-common": "^0.3.0",
"ethereumjs-common": "^0.5.0",
"ethereumjs-tx": "^1.2.2",
"ethereumjs-util": "^5.0.0",
"merkle-patricia-tree": "^2.1.2"
Expand Down
17 changes: 16 additions & 1 deletion tests/block.js
Expand Up @@ -73,6 +73,22 @@ tape('[Block]: block functions', function (t) {
st.end()
})

t.test('should test genesis hashes (ropsten)', function (st) {
var common = new Common('ropsten')
var genesisBlock = new Block(null, { common: common })
genesisBlock.setGenesisParams()
st.strictEqual(genesisBlock.hash().toString('hex'), common.genesis().hash.slice(2), 'genesis hash match')
st.end()
})

t.test('should test genesis hashes (rinkeby)', function (st) {
var common = new Common('rinkeby')
var genesisBlock = new Block(null, { common: common })
genesisBlock.setGenesisParams()
st.strictEqual(genesisBlock.hash().toString('hex'), common.genesis().hash.slice(2), 'genesis hash match')
st.end()
})

t.test('should test genesis parameters (ropsten)', function (st) {
var genesisBlock = new Block(null, { 'chain': 'ropsten' })
genesisBlock.setGenesisParams()
Expand All @@ -88,4 +104,3 @@ tape('[Block]: block functions', function (t) {
st.end()
})
})

0 comments on commit 2bda290

Please sign in to comment.