mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
clef: added basic testscript
This commit is contained in:
parent
af32f63c8e
commit
dfeb434e92
1 changed files with 46 additions and 0 deletions
46
cmd/clef/tests/testsigner.js
Normal file
46
cmd/clef/tests/testsigner.js
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
// This file is a test-utility for testing clef-functionality
|
||||||
|
// Start geth with
|
||||||
|
//
|
||||||
|
// build/bin/geth --nodiscover --maxpeers 0 --signer http://localhost:8550 console --preload=cmd/clef/tests/testsigner.js
|
||||||
|
//
|
||||||
|
// and in the console simply invoke
|
||||||
|
//
|
||||||
|
// > test()
|
||||||
|
//
|
||||||
|
// You can reload the file via `reload()`
|
||||||
|
|
||||||
|
function reload(){
|
||||||
|
loadScript("./cmd/clef/tests/testsigner.js");
|
||||||
|
}
|
||||||
|
function init(){
|
||||||
|
accts = eth.accounts
|
||||||
|
console.log("Got accounts ", accts);
|
||||||
|
}
|
||||||
|
init()
|
||||||
|
function testTx(){
|
||||||
|
if( accts && accts.length > 0) {
|
||||||
|
var a = accts[0]
|
||||||
|
var r = eth.signTransaction({from: a, to: a, value: 1, nonce: 1, gas: 1, gasPrice: 1})
|
||||||
|
console.log("signing response", r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function testSignText(){
|
||||||
|
if( accts && accts.length > 0){
|
||||||
|
var a = accts[0]
|
||||||
|
var r = eth.sign(a, "0x68656c6c6f20776f726c64"); //hello world
|
||||||
|
console.log("signing response", r)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
function test(){
|
||||||
|
try{
|
||||||
|
testTx()
|
||||||
|
}catch(err){
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
testSignText()
|
||||||
|
}catch(err){
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue