mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
Changes added console.
This commit is contained in:
parent
bc15c48163
commit
b15708af5b
3 changed files with 31 additions and 3 deletions
|
|
@ -575,4 +575,4 @@ func (ethash *Ethash) APIs(chain consensus.ChainReader) []rpc.API {
|
||||||
// dataset.
|
// dataset.
|
||||||
func SeedHash(block uint64) []byte {
|
func SeedHash(block uint64) []byte {
|
||||||
return seedHash(block)
|
return seedHash(block)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -273,7 +273,7 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
|
||||||
// console's available modules.
|
// console's available modules.
|
||||||
func (c *Console) Welcome() {
|
func (c *Console) Welcome() {
|
||||||
// Print some generic XDC metadata
|
// Print some generic XDC metadata
|
||||||
fmt.Fprintf(c.printer, "Welcome to the XinFin JavaScript console!\n\n")
|
fmt.Fprintf(c.printer, "Welcome to the XDC JavaScript console!\n\n")
|
||||||
c.jsre.Run(`
|
c.jsre.Run(`
|
||||||
console.log("instance: " + web3.version.node);
|
console.log("instance: " + web3.version.node);
|
||||||
console.log("coinbase: " + eth.coinbase);
|
console.log("coinbase: " + eth.coinbase);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ package console
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -154,6 +155,33 @@ func (env *tester) Close(t *testing.T) {
|
||||||
os.RemoveAll(env.workspace)
|
os.RemoveAll(env.workspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that the node lists the correct welcome message, notably that it contains
|
||||||
|
// the instance name, coinbase account, block number, data directory and supported
|
||||||
|
// console modules.
|
||||||
|
func TestWelcome(t *testing.T) {
|
||||||
|
tester := newTester(t, nil)
|
||||||
|
defer tester.Close(t)
|
||||||
|
|
||||||
|
tester.console.Welcome()
|
||||||
|
|
||||||
|
output := tester.output.String()
|
||||||
|
if want := "Welcome"; !strings.Contains(output, want) {
|
||||||
|
t.Fatalf("console output missing welcome message: have\n%s\nwant also %s", output, want)
|
||||||
|
}
|
||||||
|
if want := fmt.Sprintf("instance: %s", testInstance); !strings.Contains(output, want) {
|
||||||
|
t.Fatalf("console output missing instance: have\n%s\nwant also %s", output, want)
|
||||||
|
}
|
||||||
|
if want := fmt.Sprintf("coinbase: %s", testAddress); !strings.Contains(output, want) {
|
||||||
|
t.Fatalf("console output missing coinbase: have\n%s\nwant also %s", output, want)
|
||||||
|
}
|
||||||
|
if want := "at block: 0"; !strings.Contains(output, want) {
|
||||||
|
t.Fatalf("console output missing sync status: have\n%s\nwant also %s", output, want)
|
||||||
|
}
|
||||||
|
if want := fmt.Sprintf("datadir: %s", tester.workspace); !strings.Contains(output, want) {
|
||||||
|
t.Fatalf("console output missing coinbase: have\n%s\nwant also %s", output, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tests that JavaScript statement evaluation works as intended.
|
// Tests that JavaScript statement evaluation works as intended.
|
||||||
func TestEvaluate(t *testing.T) {
|
func TestEvaluate(t *testing.T) {
|
||||||
tester := newTester(t, nil)
|
tester := newTester(t, nil)
|
||||||
|
|
@ -308,4 +336,4 @@ func TestIndenting(t *testing.T) {
|
||||||
t.Errorf("test %d: invalid indenting: have %d, want %d", i, counted, tt.expectedIndentCount)
|
t.Errorf("test %d: invalid indenting: have %d, want %d", i, counted, tt.expectedIndentCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue