Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b677f785
Commit
b677f785
authored
Jun 12, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests; add method to generate empty block
parent
8f2abe78
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
14 deletions
+58
-14
txRunner.js
remix-lib/src/execution/txRunner.js
+1
-1
genesis.js
remix-simulator/src/genesis.js
+41
-0
provider.js
remix-simulator/src/provider.js
+6
-1
blocks.js
remix-simulator/test/blocks.js
+10
-12
No files found.
remix-lib/src/execution/txRunner.js
View file @
b677f785
...
...
@@ -14,7 +14,7 @@ class TxRunner {
this
.
runAsync
=
true
if
(
executionContext
.
isVM
())
{
//this.blockNumber = 1150000 // The VM is running in Homestead mode, which started at this block.
this
.
blockNumber
=
1
// The VM is running in Homestead mode, which started at this block.
this
.
blockNumber
=
2
// The VM is running in Homestead mode, which started at this block.
this
.
runAsync
=
false
// We have to run like this cause the VM Event Manager does not support running multiple txs at the same time.
}
this
.
pendingTxs
=
{}
...
...
remix-simulator/src/genesis.js
0 → 100644
View file @
b677f785
var
EthJSBlock
=
require
(
'ethereumjs-block'
)
var
RemixLib
=
require
(
'remix-lib'
)
var
executionContext
=
RemixLib
.
execution
.
executionContext
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
function
checkpointAndCommit
(
cb
)
{
if
(
executionContext
.
vm
().
stateManager
.
_checkpointCount
>
0
)
{
return
executionContext
.
vm
().
stateManager
.
commit
(()
=>
{
cb
()
})
}
executionContext
.
vm
().
stateManager
.
checkpoint
(()
=>
{
executionContext
.
vm
().
stateManager
.
commit
(()
=>
{
cb
()
})
})
}
function
generateBlock
()
{
var
block
=
new
EthJSBlock
({
header
:
{
timestamp
:
(
new
Date
().
getTime
()
/
1000
|
0
),
number
:
1
,
coinbase
:
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
difficulty
:
(
new
BN
(
'69762765929000'
,
10
)),
gasLimit
:
new
BN
(
'5000000'
).
imuln
(
1
)
},
transactions
:
[],
uncleHeaders
:
[]
})
checkpointAndCommit
(()
=>
{
executionContext
.
vm
().
runBlock
({
block
:
block
,
generate
:
true
,
skipBlockValidation
:
true
,
skipBalance
:
false
},
function
()
{
executionContext
.
addBlock
(
block
)
})
})
}
module
.
exports
=
generateBlock
\ No newline at end of file
remix-simulator/src/provider.js
View file @
b677f785
...
...
@@ -8,6 +8,8 @@ const Net = require('./methods/net.js')
const
Transactions
=
require
(
'./methods/transactions.js'
)
const
Whisper
=
require
(
'./methods/whisper.js'
)
const
generateBlock
=
require
(
'./genesis.js'
)
var
Provider
=
function
(
options
)
{
this
.
Accounts
=
new
Accounts
()
...
...
@@ -18,6 +20,8 @@ var Provider = function (options) {
this
.
methods
=
merge
(
this
.
methods
,
(
new
Net
()).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Transactions
(
this
.
Accounts
.
accounts
)).
methods
())
this
.
methods
=
merge
(
this
.
methods
,
(
new
Whisper
()).
methods
())
generateBlock
()
}
Provider
.
prototype
.
sendAsync
=
function
(
payload
,
callback
)
{
...
...
@@ -44,4 +48,4 @@ Provider.prototype.isConnected = function () {
return
true
}
module
.
exports
=
Provider
module
.
exports
=
Provider
\ No newline at end of file
remix-simulator/test/blocks.js
View file @
b677f785
...
...
@@ -16,22 +16,20 @@ describe('blocks', function () {
let
block
=
await
web3
.
eth
.
getBlock
(
1
)
let
expectedBlock
=
{
difficulty
:
'0'
,
extraData
:
'0x'
,
gasLimit
:
8
000000
,
difficulty
:
'
6976276592900
0'
,
extraData
:
'0x
0
'
,
gasLimit
:
5
000000
,
gasUsed
:
0
,
hash
:
'0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f'
,
logsBloom
:
'0x
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
'
,
hash
:
block
.
hash
.
toString
(
'hex'
)
,
logsBloom
:
'0x
e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331
'
,
miner
:
'0x0000000000000000000000000000000000000001'
,
mixHash
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
nonce
:
'0x0000000000000042'
,
number
:
0
,
nonce
:
'0x0000000000000000'
,
number
:
1
,
parentHash
:
'0x0000000000000000000000000000000000000000000000000000000000000000'
,
receiptsRoot
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
sha3Uncles
:
'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
,
size
:
504
,
stateRoot
:
'0x
b7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff
'
,
timestamp
:
0
,
size
:
163591
,
stateRoot
:
'0x
a633ca0e8f0ae4e86d4d572b048ea93d84eb4b11e2c988b48cb3a5f6f10b3c68
'
,
timestamp
:
block
.
timestamp
,
totalDifficulty
:
'0'
,
transactions
:
[],
transactionsRoot
:
'0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment