solidity compiler and contract metadocs integration
* common/compiler: solidity compiler + tests * rpc: eth_compilers, eth_compileSolidity + tests * fix natspec test using keystore API, notice exp dynamically changes addr, cleanup * resolver implements registrars and needs to create reg contract (temp) * xeth: solidity compiler. expose getter Solc() and paths setter SetSolc(solcPath) * ethereumApi: implement compiler related RPC calls using XEth - json struct tests * admin: make use of XEth.SetSolc to allow runtime setting of compiler paths * cli: command line flags solc to set custom solc bin path * js admin api with new features debug and contractInfo modules * wiki is the doc https://github.com/ethereum/go-ethereum/wiki/Contracts-and-Transactions
This commit is contained in:
@ -4,70 +4,65 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func makeUserdoc(desc string) []byte {
|
||||
func makeInfoDoc(desc string) []byte {
|
||||
return []byte(`
|
||||
{
|
||||
"source": "...",
|
||||
"source": "contract test { }",
|
||||
"language": "Solidity",
|
||||
"languageVersion": 1,
|
||||
"methods": {
|
||||
"multiply(uint256)": {
|
||||
"notice": "` + desc + `"
|
||||
"compilerVersion": "1",
|
||||
"userDoc": {
|
||||
"methods": {
|
||||
"multiply(uint256)": {
|
||||
"notice": "` + desc + `"
|
||||
},
|
||||
"balance(address)": {
|
||||
"notice": "` + "`(balanceInmGAV / 1000).fixed(0,3)`" + ` GAV is the total funds available to ` + "`who.address()`." + `"
|
||||
}
|
||||
},
|
||||
"balance(address)": {
|
||||
"notice": "` + "`(balanceInmGAV / 1000).fixed(0,3)`" + ` GAV is the total funds available to ` + "`who.address()`." + `"
|
||||
}
|
||||
"invariants": [
|
||||
{ "notice": "The sum total amount of GAV in the system is 1 million." }
|
||||
],
|
||||
"construction": [
|
||||
{ "notice": "Endows ` + "`message.caller.address()`" + ` with 1m GAV." }
|
||||
]
|
||||
},
|
||||
"invariants": [
|
||||
{ "notice": "The sum total amount of GAV in the system is 1 million." }
|
||||
],
|
||||
"construction": [
|
||||
{ "notice": "Endows ` + "`message.caller.address()`" + ` with 1m GAV." }
|
||||
]
|
||||
}
|
||||
`)
|
||||
"abiDefinition": [{
|
||||
"name": "multiply",
|
||||
"constant": false,
|
||||
"type": "function",
|
||||
"inputs": [{
|
||||
"name": "a",
|
||||
"type": "uint256"
|
||||
}],
|
||||
"outputs": [{
|
||||
"name": "d",
|
||||
"type": "uint256"
|
||||
}]
|
||||
}]
|
||||
}`)
|
||||
}
|
||||
|
||||
var data = "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a"
|
||||
|
||||
var tx = `
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "eth_call",
|
||||
"params": [{
|
||||
"to": "0x8521742d3f456bd237e312d6e30724960f72517a",
|
||||
"data": "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a"
|
||||
}],
|
||||
"id": 6
|
||||
}
|
||||
`
|
||||
|
||||
var abi = []byte(`
|
||||
[{
|
||||
"name": "multiply",
|
||||
"constant": false,
|
||||
"type": "function",
|
||||
"inputs": [{
|
||||
"name": "a",
|
||||
"type": "uint256"
|
||||
}],
|
||||
"outputs": [{
|
||||
"name": "d",
|
||||
"type": "uint256"
|
||||
}]
|
||||
}]
|
||||
`)
|
||||
|
||||
func TestNotice(t *testing.T) {
|
||||
|
||||
desc := "Will multiply `a` by 7 and return `a * 7`."
|
||||
expected := "Will multiply 122 by 7 and return 854."
|
||||
|
||||
userdoc := makeUserdoc(desc)
|
||||
|
||||
ns, err := NewWithDocs(abi, userdoc, tx)
|
||||
infodoc := makeInfoDoc(desc)
|
||||
ns, err := NewWithDocs(infodoc, tx, data)
|
||||
if err != nil {
|
||||
t.Errorf("New: error: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
notice, err := ns.Notice()
|
||||
@ -78,8 +73,6 @@ func TestNotice(t *testing.T) {
|
||||
|
||||
if notice != expected {
|
||||
t.Errorf("incorrect notice. expected %v, got %v", expected, notice)
|
||||
} else {
|
||||
t.Logf("returned notice \"%v\"", notice)
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,10 +80,10 @@ func TestNotice(t *testing.T) {
|
||||
func TestMissingMethod(t *testing.T) {
|
||||
|
||||
desc := "Will multiply `a` by 7 and return `a * 7`."
|
||||
userdoc := makeUserdoc(desc)
|
||||
expected := "natspec.js error evaluating expression: Natspec evaluation failed, method does not exist"
|
||||
|
||||
ns, err := NewWithDocs(abi, userdoc, tx)
|
||||
infodoc := makeInfoDoc(desc)
|
||||
ns, err := NewWithDocs(infodoc, tx, data)
|
||||
if err != nil {
|
||||
t.Errorf("New: error: %v", err)
|
||||
}
|
||||
@ -113,9 +106,8 @@ func TestInvalidDesc(t *testing.T) {
|
||||
desc := "Will multiply 122 by \"7\" and return 854."
|
||||
expected := "invalid character '7' after object key:value pair"
|
||||
|
||||
userdoc := makeUserdoc(desc)
|
||||
|
||||
_, err := NewWithDocs(abi, userdoc, tx)
|
||||
infodoc := makeInfoDoc(desc)
|
||||
_, err := NewWithDocs(infodoc, tx, data)
|
||||
if err == nil {
|
||||
t.Errorf("expected error, got nothing", err)
|
||||
} else {
|
||||
@ -131,9 +123,8 @@ func TestWrongInputParams(t *testing.T) {
|
||||
desc := "Will multiply `e` by 7 and return `a * 7`."
|
||||
expected := "natspec.js error evaluating expression: Natspec evaluation failed, wrong input params"
|
||||
|
||||
userdoc := makeUserdoc(desc)
|
||||
|
||||
ns, err := NewWithDocs(abi, userdoc, tx)
|
||||
infodoc := makeInfoDoc(desc)
|
||||
ns, err := NewWithDocs(infodoc, tx, data)
|
||||
if err != nil {
|
||||
t.Errorf("New: error: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user