Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
22450c06
Commit
22450c06
authored
Apr 21, 2015
by
zelig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
js console: add cors domain optional argument to startRpc
parent
a3fb4198
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
admin.go
cmd/geth/admin.go
+10
-1
js_test.go
cmd/geth/js_test.go
+7
-7
No files found.
cmd/geth/admin.go
View file @
22450c06
...
@@ -209,10 +209,19 @@ func (js *jsre) startRPC(call otto.FunctionCall) otto.Value {
...
@@ -209,10 +209,19 @@ func (js *jsre) startRPC(call otto.FunctionCall) otto.Value {
return
otto
.
FalseValue
()
return
otto
.
FalseValue
()
}
}
var
corsDomain
string
if
len
(
call
.
ArgumentList
)
>
2
{
corsDomain
,
err
=
call
.
Argument
(
2
)
.
ToString
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
otto
.
FalseValue
()
}
}
config
:=
rpc
.
RpcConfig
{
config
:=
rpc
.
RpcConfig
{
ListenAddress
:
addr
,
ListenAddress
:
addr
,
ListenPort
:
uint
(
port
),
ListenPort
:
uint
(
port
),
// CorsDomain: ctx.GlobalString(RPCCORSDomainFlag.Name)
,
CorsDomain
:
corsDomain
,
}
}
xeth
:=
xeth
.
New
(
js
.
ethereum
,
nil
)
xeth
:=
xeth
.
New
(
js
.
ethereum
,
nil
)
...
...
cmd/geth/js_test.go
View file @
22450c06
...
@@ -3,16 +3,16 @@ package main
...
@@ -3,16 +3,16 @@ package main
import
(
import
(
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"path/filepath"
"os"
"os"
"path"
"path"
"path/filepath"
"testing"
"testing"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth"
"runtime"
"regexp"
"regexp"
"runtime"
"strconv"
"strconv"
)
)
...
@@ -70,8 +70,8 @@ func TestAccounts(t *testing.T) {
...
@@ -70,8 +70,8 @@ func TestAccounts(t *testing.T) {
t
.
Errorf
(
"address not hex: %q"
,
addr
)
t
.
Errorf
(
"address not hex: %q"
,
addr
)
}
}
checkEvalJSON
(
t
,
repl
,
`eth.accounts`
,
`["`
+
addr
+
`"]`
)
checkEvalJSON
(
t
,
repl
,
`eth.accounts`
,
`["`
+
addr
+
`"]`
)
checkEvalJSON
(
t
,
repl
,
`eth.coinbase`
,
`"`
+
addr
+
`"`
)
checkEvalJSON
(
t
,
repl
,
`eth.coinbase`
,
`"`
+
addr
+
`"`
)
}
}
func
TestBlockChain
(
t
*
testing
.
T
)
{
func
TestBlockChain
(
t
*
testing
.
T
)
{
...
@@ -97,13 +97,13 @@ func TestBlockChain(t *testing.T) {
...
@@ -97,13 +97,13 @@ func TestBlockChain(t *testing.T) {
tmpfile
:=
filepath
.
Join
(
tmp
,
"export.chain"
)
tmpfile
:=
filepath
.
Join
(
tmp
,
"export.chain"
)
tmpfileq
:=
strconv
.
Quote
(
tmpfile
)
tmpfileq
:=
strconv
.
Quote
(
tmpfile
)
checkEvalJSON
(
t
,
repl
,
`admin.export(`
+
tmpfileq
+
`)`
,
`true`
)
checkEvalJSON
(
t
,
repl
,
`admin.export(`
+
tmpfileq
+
`)`
,
`true`
)
if
_
,
err
:=
os
.
Stat
(
tmpfile
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
tmpfile
);
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// check import, verify that dumpBlock gives the same result.
// check import, verify that dumpBlock gives the same result.
checkEvalJSON
(
t
,
repl
,
`admin.import(`
+
tmpfileq
+
`)`
,
`true`
)
checkEvalJSON
(
t
,
repl
,
`admin.import(`
+
tmpfileq
+
`)`
,
`true`
)
checkEvalJSON
(
t
,
repl
,
`admin.debug.dumpBlock()`
,
beforeExport
)
checkEvalJSON
(
t
,
repl
,
`admin.debug.dumpBlock()`
,
beforeExport
)
}
}
...
@@ -129,7 +129,7 @@ func TestRPC(t *testing.T) {
...
@@ -129,7 +129,7 @@ func TestRPC(t *testing.T) {
}
}
func
checkEvalJSON
(
t
*
testing
.
T
,
re
*
jsre
,
expr
,
want
string
)
error
{
func
checkEvalJSON
(
t
*
testing
.
T
,
re
*
jsre
,
expr
,
want
string
)
error
{
val
,
err
:=
re
.
re
.
Run
(
"JSON.stringify("
+
expr
+
")"
)
val
,
err
:=
re
.
re
.
Run
(
"JSON.stringify("
+
expr
+
")"
)
if
err
==
nil
&&
val
.
String
()
!=
want
{
if
err
==
nil
&&
val
.
String
()
!=
want
{
err
=
fmt
.
Errorf
(
"Output mismatch for `%s`:
\n
got: %s
\n
want: %s"
,
expr
,
val
.
String
(),
want
)
err
=
fmt
.
Errorf
(
"Output mismatch for `%s`:
\n
got: %s
\n
want: %s"
,
expr
,
val
.
String
(),
want
)
}
}
...
...
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