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
e0501a12
Commit
e0501a12
authored
Apr 28, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix remix-simulator tests
parent
7bb65899
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
61 deletions
+58
-61
debugger.ts
libs/remix-debug/test/debugger.ts
+42
-40
localDecoder.ts
libs/remix-debug/test/decoder/localDecoder.ts
+2
-2
mapping.ts
libs/remix-debug/test/decoder/stateTests/mapping.ts
+2
-2
vmCall.ts
libs/remix-debug/test/decoder/vmCall.ts
+6
-6
vmCall.ts
libs/remix-debug/test/vmCall.ts
+4
-4
util.ts
libs/remix-lib/src/util.ts
+2
-7
No files found.
libs/remix-debug/test/debugger.ts
View file @
e0501a12
...
@@ -148,48 +148,50 @@ contract Ballot {
...
@@ -148,48 +148,50 @@ contract Ballot {
winnerName_ = proposals[winningProposal()].name;
winnerName_ = proposals[winningProposal()].name;
}
}
}
}
`
`
;
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
(
async
()
=>
{
var
vm
=
vmCall
.
initVM
(
privateKey
)
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
output
=
compiler
.
compile
(
compilerInput
(
ballot
))
var
vm
=
await
vmCall
.
initVM
(
privateKey
)
output
=
JSON
.
parse
(
output
)
var
output
=
compiler
.
compile
(
compilerInput
(
ballot
))
var
web3VM
=
new
remixLib
.
vm
.
Web3VMProvider
()
output
=
JSON
.
parse
(
output
)
web3VM
.
setVM
(
vm
)
var
web3VM
=
new
remixLib
.
vm
.
Web3VMProvider
()
const
param
=
'0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000148656c6c6f20576f726c64210000000000000000000000000000000000000000'
web3VM
.
setVM
(
vm
)
vmCall
.
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
output
.
contracts
[
'test.sol'
][
'Ballot'
].
evm
.
bytecode
.
object
+
param
,
(
error
,
txHash
)
=>
{
const
param
=
'0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000148656c6c6f20576f726c64210000000000000000000000000000000000000000'
console
.
log
(
error
,
txHash
)
vmCall
.
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
output
.
contracts
[
'test.sol'
][
'Ballot'
].
evm
.
bytecode
.
object
+
param
,
(
error
,
txHash
)
=>
{
if
(
error
)
{
console
.
log
(
error
,
txHash
)
throw
error
if
(
error
)
{
}
else
{
throw
error
web3VM
.
eth
.
getTransaction
(
txHash
,
(
error
,
tx
)
=>
{
}
else
{
if
(
error
)
{
web3VM
.
eth
.
getTransaction
(
txHash
,
(
error
,
tx
)
=>
{
throw
error
if
(
error
)
{
}
else
{
var
debugManager
=
new
Debugger
({
compilationResult
:
function
()
{
return
{
data
:
output
}
},
web3
:
web3VM
})
debugManager
.
callTree
.
event
.
register
(
'callTreeReady'
,
()
=>
{
testDebugging
(
debugManager
)
})
debugManager
.
callTree
.
event
.
register
(
'callTreeNotReady'
,
(
error
)
=>
{
console
.
error
(
error
)
throw
error
})
debugManager
.
callTree
.
event
.
register
(
'callTreeBuildFailed'
,
(
error
)
=>
{
console
.
error
(
error
)
throw
error
throw
error
})
}
else
{
var
debugManager
=
new
Debugger
({
debugManager
.
debug
(
tx
)
compilationResult
:
function
()
{
}
return
{
data
:
output
}
})
},
}
web3
:
web3VM
})
})
debugManager
.
callTree
.
event
.
register
(
'callTreeReady'
,
()
=>
{
testDebugging
(
debugManager
)
})
debugManager
.
callTree
.
event
.
register
(
'callTreeNotReady'
,
(
error
)
=>
{
console
.
error
(
error
)
throw
error
})
debugManager
.
callTree
.
event
.
register
(
'callTreeBuildFailed'
,
(
error
)
=>
{
console
.
error
(
error
)
throw
error
})
debugManager
.
debug
(
tx
)
}
})
}
})
})()
function
testDebugging
(
debugManager
)
{
function
testDebugging
(
debugManager
)
{
// stack
// stack
...
...
libs/remix-debug/test/decoder/localDecoder.ts
View file @
e0501a12
...
@@ -12,9 +12,9 @@ var structArrayLocalTest = require('./localsTests/structArray')
...
@@ -12,9 +12,9 @@ var structArrayLocalTest = require('./localsTests/structArray')
var
compilerInput
=
require
(
'../helpers/compilerHelper'
).
compilerInput
var
compilerInput
=
require
(
'../helpers/compilerHelper'
).
compilerInput
tape
(
'solidity'
,
function
(
t
)
{
tape
(
'solidity'
,
function
(
t
)
{
t
.
test
(
'local decoder'
,
function
(
st
)
{
t
.
test
(
'local decoder'
,
async
function
(
st
)
{
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
vm
=
vmCall
.
initVM
(
st
,
privateKey
)
var
vm
=
await
vmCall
.
initVM
(
st
,
privateKey
)
test
(
st
,
vm
,
privateKey
)
test
(
st
,
vm
,
privateKey
)
})
})
})
})
...
...
libs/remix-debug/test/decoder/stateTests/mapping.ts
View file @
e0501a12
...
@@ -6,10 +6,10 @@ import { sendTx, initVM } from '../vmCall'
...
@@ -6,10 +6,10 @@ import { sendTx, initVM } from '../vmCall'
import
{
StorageResolver
}
from
'../../../src/storage/storageResolver'
import
{
StorageResolver
}
from
'../../../src/storage/storageResolver'
import
{
StorageViewer
}
from
'../../../src/storage/storageViewer'
import
{
StorageViewer
}
from
'../../../src/storage/storageViewer'
module
.
exports
=
function
testMappingStorage
(
st
,
cb
)
{
module
.
exports
=
async
function
testMappingStorage
(
st
,
cb
)
{
var
mappingStorage
=
require
(
'../contracts/mappingStorage'
)
var
mappingStorage
=
require
(
'../contracts/mappingStorage'
)
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
privateKey
=
Buffer
.
from
(
'dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a'
,
'hex'
)
var
vm
=
initVM
(
st
,
privateKey
)
var
vm
=
await
initVM
(
st
,
privateKey
)
var
output
=
compile
(
compilerInput
(
mappingStorage
.
contract
))
var
output
=
compile
(
compilerInput
(
mappingStorage
.
contract
))
output
=
JSON
.
parse
(
output
)
output
=
JSON
.
parse
(
output
)
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
output
.
contracts
[
'test.sol'
][
'SimpleMappingState'
].
evm
.
bytecode
.
object
,
function
(
error
,
txHash
)
{
sendTx
(
vm
,
{
nonce
:
0
,
privateKey
:
privateKey
},
null
,
0
,
output
.
contracts
[
'test.sol'
][
'SimpleMappingState'
].
evm
.
bytecode
.
object
,
function
(
error
,
txHash
)
{
...
...
libs/remix-debug/test/decoder/vmCall.ts
View file @
e0501a12
...
@@ -16,7 +16,7 @@ export function sendTx (vm, from, to, value, data, cb) {
...
@@ -16,7 +16,7 @@ export function sendTx (vm, from, to, value, data, cb) {
value
:
new
BN
(
value
,
10
),
value
:
new
BN
(
value
,
10
),
data
:
Buffer
.
from
(
data
,
'hex'
)
data
:
Buffer
.
from
(
data
,
'hex'
)
})
})
tx
.
sign
(
from
.
privateKey
)
tx
=
tx
.
sign
(
from
.
privateKey
)
var
block
=
Block
.
fromBlockData
({
var
block
=
Block
.
fromBlockData
({
header
:
{
header
:
{
...
@@ -39,9 +39,10 @@ export function sendTx (vm, from, to, value, data, cb) {
...
@@ -39,9 +39,10 @@ export function sendTx (vm, from, to, value, data, cb) {
}
}
}
}
function
createVm
(
hardfork
)
{
async
function
createVm
(
hardfork
)
{
const
common
=
new
Common
({
chain
:
'mainnet'
,
hardfork
})
const
common
=
new
Common
({
chain
:
'mainnet'
,
hardfork
})
const
vm
=
new
VM
({
common
})
const
vm
=
new
VM
({
common
})
await
vm
.
init
()
// vm.blockchain.validate = false
// vm.blockchain.validate = false
return
{
vm
,
stateManager
:
vm
.
stateManager
}
return
{
vm
,
stateManager
:
vm
.
stateManager
}
}
}
...
@@ -49,12 +50,11 @@ function createVm (hardfork) {
...
@@ -49,12 +50,11 @@ function createVm (hardfork) {
/*
/*
Init VM / Send Transaction
Init VM / Send Transaction
*/
*/
export
function
initVM
(
st
,
privateKey
)
{
export
async
function
initVM
(
st
,
privateKey
)
{
var
VM
=
createVm
(
'berlin'
)
var
VM
=
await
createVm
(
'berlin'
)
const
vm
=
VM
.
vm
const
vm
=
VM
.
vm
var
address
=
utileth
.
privateToAddress
(
privateKey
)
var
address
=
utileth
.
Address
.
fromPrivateKey
(
privateKey
)
vm
.
stateManager
.
getAccount
(
address
).
then
((
account
)
=>
{
vm
.
stateManager
.
getAccount
(
address
).
then
((
account
)
=>
{
account
.
balance
=
new
BN
(
'f00000000000000001'
,
16
)
account
.
balance
=
new
BN
(
'f00000000000000001'
,
16
)
vm
.
stateManager
.
putAccount
(
address
,
account
).
catch
((
error
)
=>
{
vm
.
stateManager
.
putAccount
(
address
,
account
).
catch
((
error
)
=>
{
...
...
libs/remix-debug/test/vmCall.ts
View file @
e0501a12
...
@@ -15,7 +15,7 @@ function sendTx (vm, from, to, value, data, cb) {
...
@@ -15,7 +15,7 @@ function sendTx (vm, from, to, value, data, cb) {
value
:
new
BN
(
value
,
10
),
value
:
new
BN
(
value
,
10
),
data
:
Buffer
.
from
(
data
,
'hex'
)
data
:
Buffer
.
from
(
data
,
'hex'
)
})
})
tx
.
sign
(
from
.
privateKey
)
tx
=
tx
.
sign
(
from
.
privateKey
)
var
block
=
Block
.
fromBlockData
({
var
block
=
Block
.
fromBlockData
({
header
:
{
header
:
{
...
@@ -36,12 +36,12 @@ function sendTx (vm, from, to, value, data, cb) {
...
@@ -36,12 +36,12 @@ function sendTx (vm, from, to, value, data, cb) {
/*
/*
Init VM / Send Transaction
Init VM / Send Transaction
*/
*/
function
initVM
(
privateKey
)
{
async
function
initVM
(
privateKey
)
{
var
address
=
utileth
.
privateToAddress
(
privateKey
)
var
address
=
utileth
.
Address
.
fromPrivateKey
(
privateKey
)
var
vm
=
new
VM
({
var
vm
=
new
VM
({
activatePrecompiles
:
true
activatePrecompiles
:
true
})
})
await
vm
.
init
()
vm
.
stateManager
.
getAccount
(
address
).
then
((
account
)
=>
{
vm
.
stateManager
.
getAccount
(
address
).
then
((
account
)
=>
{
account
.
balance
=
new
BN
(
'f00000000000000001'
,
16
)
account
.
balance
=
new
BN
(
'f00000000000000001'
,
16
)
vm
.
stateManager
.
putAccount
(
address
,
account
).
catch
((
error
)
=>
{
vm
.
stateManager
.
putAccount
(
address
,
account
).
catch
((
error
)
=>
{
...
...
libs/remix-lib/src/util.ts
View file @
e0501a12
'use strict'
'use strict'
import
{
BN
,
bufferToHex
,
keccak
,
setLengthLeft
,
intT
oBuffer
}
from
'ethereumjs-util'
import
{
BN
,
bufferToHex
,
keccak
,
setLengthLeft
,
t
oBuffer
}
from
'ethereumjs-util'
/*
/*
contains misc util: @TODO should be splitted
contains misc util: @TODO should be splitted
...
@@ -165,12 +165,7 @@ export function buildCallPath (index, rootCall) {
...
@@ -165,12 +165,7 @@ export function buildCallPath (index, rootCall) {
*/
*/
// eslint-disable-next-line camelcase
// eslint-disable-next-line camelcase
export
function
sha3_256
(
value
)
{
export
function
sha3_256
(
value
)
{
if
(
typeof
value
===
'string'
)
{
value
=
toBuffer
(
value
)
value
=
Buffer
.
from
(
value
.
replace
(
'0x'
,
''
),
'hex'
)
}
if
(
Number
.
isInteger
(
value
))
{
value
=
intToBuffer
(
value
)
}
const
retInBuffer
:
Buffer
=
keccak
(
setLengthLeft
(
value
,
32
))
const
retInBuffer
:
Buffer
=
keccak
(
setLengthLeft
(
value
,
32
))
return
bufferToHex
(
retInBuffer
)
return
bufferToHex
(
retInBuffer
)
}
}
...
...
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