mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
all: change format 0x%x to %#x (#25221)
This commit is contained in:
parent
47d27fed3b
commit
edace6ac6c
18 changed files with 831 additions and 29 deletions
|
|
@ -76,7 +76,7 @@ func runCmd(ctx *cli.Context) error {
|
|||
log.Root().SetHandler(glogger)
|
||||
logconfig := &vm.LogConfig{
|
||||
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
|
||||
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
|
||||
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -238,7 +238,7 @@ Gas used: %d
|
|||
if tracer != nil {
|
||||
tracer.CaptureEnd(ret, initialGas-leftOverGas, execTime, err)
|
||||
} else {
|
||||
fmt.Printf("0x%x\n", ret)
|
||||
fmt.Printf("%#x\n", ret)
|
||||
if err != nil {
|
||||
fmt.Printf(" error: %v\n", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func VerifyForkHashes(config *params.ChainConfig, header *types.Header, uncle bo
|
|||
// If the homestead reprice hash is set, validate it
|
||||
if config.EIP150Block != nil && config.EIP150Block.Cmp(header.Number) == 0 {
|
||||
if config.EIP150Hash != (common.Hash{}) && config.EIP150Hash != header.Hash() {
|
||||
return fmt.Errorf("homestead gas reprice fork: have 0x%x, want 0x%x", header.Hash(), config.EIP150Hash)
|
||||
return fmt.Errorf("homestead gas reprice fork: have %#x, want %#x", header.Hash(), config.EIP150Hash)
|
||||
}
|
||||
}
|
||||
// All ok, return
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ func PrintDisassembled(code string) error {
|
|||
it := NewInstructionIterator(script)
|
||||
for it.Next() {
|
||||
if it.Arg() != nil && 0 < len(it.Arg()) {
|
||||
fmt.Printf("%06v: %v 0x%x\n", it.PC(), it.Op(), it.Arg())
|
||||
fmt.Printf("%06v: %v %#x\n", it.PC(), it.Op(), it.Arg())
|
||||
} else {
|
||||
fmt.Printf("%06v: %v\n", it.PC(), it.Op())
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ func Disassemble(script []byte) ([]string, error) {
|
|||
it := NewInstructionIterator(script)
|
||||
for it.Next() {
|
||||
if it.Arg() != nil && 0 < len(it.Arg()) {
|
||||
instrs = append(instrs, fmt.Sprintf("%06v: %v 0x%x\n", it.PC(), it.Op(), it.Arg()))
|
||||
instrs = append(instrs, fmt.Sprintf("%06v: %v %#x\n", it.PC(), it.Op(), it.Arg()))
|
||||
} else {
|
||||
instrs = append(instrs, fmt.Sprintf("%06v: %v\n", it.PC(), it.Op()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2365,7 +2365,7 @@ func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, e
|
|||
Chain config: %v
|
||||
|
||||
Number: %v
|
||||
Hash: 0x%x
|
||||
Hash: %#x
|
||||
%v
|
||||
|
||||
Round: %v
|
||||
|
|
|
|||
|
|
@ -539,7 +539,7 @@ func (tx *Transaction) String() string {
|
|||
GasPrice: %#x
|
||||
GasLimit %#x
|
||||
Value: %#x
|
||||
Data: 0x%x
|
||||
Data: %#x
|
||||
V: %#x
|
||||
R: %#x
|
||||
S: %#x
|
||||
|
|
|
|||
|
|
@ -654,7 +654,7 @@ func TestCreate2Addreses(t *testing.T) {
|
|||
stack.push(big.NewInt(0)) // memstart
|
||||
stack.push(big.NewInt(0)) // value
|
||||
gas, _ := gasCreate2(params.GasTable{}, nil, nil, stack, nil, 0)
|
||||
fmt.Printf("Example %d\n* address `0x%x`\n* salt `0x%x`\n* init_code `0x%x`\n* gas (assuming no mem expansion): `%v`\n* result: `%s`\n\n", i,origin, salt, code, gas, address.String())
|
||||
fmt.Printf("Example %d\n* address `%#x`\n* salt `%#x`\n* init_code `%#x`\n* gas (assuming no mem expansion): `%v`\n* result: `%s`\n\n", i,origin, salt, code, gas, address.String())
|
||||
*/
|
||||
expected := common.BytesToAddress(common.FromHex(tt.expected))
|
||||
if !bytes.Equal(expected.Bytes(), address.Bytes()) {
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration
|
|||
l.output = output
|
||||
l.err = err
|
||||
if l.cfg.Debug {
|
||||
fmt.Printf("0x%x\n", output)
|
||||
fmt.Printf("%#x\n", output)
|
||||
if err != nil {
|
||||
fmt.Printf(" error: %v\n", err)
|
||||
}
|
||||
|
|
@ -305,11 +305,11 @@ func NewMarkdownLogger(cfg *LogConfig, writer io.Writer) *mdLogger {
|
|||
|
||||
func (t *mdLogger) CaptureStart(env *EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||
if !create {
|
||||
fmt.Fprintf(t.out, "From: `%v`\nTo: `%v`\nData: `0x%x`\nGas: `%d`\nValue `%v` wei\n",
|
||||
fmt.Fprintf(t.out, "From: `%v`\nTo: `%v`\nData: `%#x`\nGas: `%d`\nValue `%v` wei\n",
|
||||
from.String(), to.String(),
|
||||
input, gas, value)
|
||||
} else {
|
||||
fmt.Fprintf(t.out, "From: `%v`\nCreate at: `%v`\nData: `0x%x`\nGas: `%d`\nValue `%v` wei\n",
|
||||
fmt.Fprintf(t.out, "From: `%v`\nCreate at: `%v`\nData: `%#x`\nGas: `%d`\nValue `%v` wei\n",
|
||||
from.String(), to.String(),
|
||||
input, gas, value)
|
||||
}
|
||||
|
|
@ -346,7 +346,7 @@ func (t *mdLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost uint64
|
|||
}
|
||||
|
||||
func (t *mdLogger) CaptureEnd(output []byte, gasUsed uint64, tm time.Duration, err error) {
|
||||
fmt.Fprintf(t.out, "\nOutput: `0x%x`\nConsumed gas: `%d`\nError: `%v`\n",
|
||||
fmt.Fprintf(t.out, "\nOutput: `%#x`\nConsumed gas: `%d`\nError: `%v`\n",
|
||||
output, gasUsed, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ func TestEip2929Cases(t *testing.T) {
|
|||
it := asm.NewInstructionIterator(code)
|
||||
for it.Next() {
|
||||
if it.Arg() != nil && 0 < len(it.Arg()) {
|
||||
instrs = append(instrs, fmt.Sprintf("%v 0x%x", it.Op(), it.Arg()))
|
||||
instrs = append(instrs, fmt.Sprintf("%v %#x", it.Op(), it.Arg()))
|
||||
} else {
|
||||
instrs = append(instrs, fmt.Sprintf("%v", it.Op()))
|
||||
}
|
||||
|
|
@ -506,7 +506,7 @@ func TestEip2929Cases(t *testing.T) {
|
|||
ops := strings.Join(instrs, ", ")
|
||||
fmt.Printf("### Case %d\n\n", id)
|
||||
id++
|
||||
fmt.Printf("%v\n\nBytecode: \n```\n0x%x\n```\nOperations: \n```\n%v\n```\n\n",
|
||||
fmt.Printf("%v\n\nBytecode: \n```\n%#x\n```\nOperations: \n```\n%v\n```\n\n",
|
||||
comment,
|
||||
code, ops)
|
||||
Execute(code, nil, &Config{
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
package eth
|
||||
|
||||
import (
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/state"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
|
|
@ -84,7 +85,7 @@ func TestStorageRangeAt(t *testing.T) {
|
|||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(result, test.want) {
|
||||
t.Fatalf("wrong result for range 0x%x.., limit %d:\ngot %s\nwant %s",
|
||||
t.Fatalf("wrong result for range %#x.., limit %d:\ngot %s\nwant %s",
|
||||
test.start, test.limit, dumper.Sdump(result), dumper.Sdump(&test.want))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
|
|||
|
||||
// from, to block number
|
||||
var test1 FilterCriteria
|
||||
vector := fmt.Sprintf(`{"fromBlock":"0x%x","toBlock":"0x%x"}`, fromBlock, toBlock)
|
||||
vector := fmt.Sprintf(`{"fromBlock":"%#x","toBlock":"%#x"}`, fromBlock, toBlock)
|
||||
if err := json.Unmarshal([]byte(vector), &test1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3333,7 +3333,7 @@ func (api *PublicDebugAPI) SeedHash(ctx context.Context, number uint64) (string,
|
|||
if block == nil {
|
||||
return "", fmt.Errorf("block #%d not found", number)
|
||||
}
|
||||
return fmt.Sprintf("0x%x", ethash.SeedHash(number)), nil
|
||||
return fmt.Sprintf("%#x", ethash.SeedHash(number)), nil
|
||||
}
|
||||
|
||||
// PrivateDebugAPI is the collection of Ethereum APIs exposed over the private
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func (n *Nonce) GetBytes() []byte {
|
|||
|
||||
// GetHex retrieves the hex string representation of the block nonce.
|
||||
func (n *Nonce) GetHex() string {
|
||||
return fmt.Sprintf("0x%x", n.nonce[:])
|
||||
return fmt.Sprintf("%#x", n.nonce[:])
|
||||
}
|
||||
|
||||
// Bloom represents a 256 bit bloom filter.
|
||||
|
|
@ -56,7 +56,7 @@ func (b *Bloom) GetBytes() []byte {
|
|||
|
||||
// GetHex retrieves the hex string representation of the bloom filter.
|
||||
func (b *Bloom) GetHex() string {
|
||||
return fmt.Sprintf("0x%x", b.bloom[:])
|
||||
return fmt.Sprintf("%#x", b.bloom[:])
|
||||
}
|
||||
|
||||
// Header represents a block header in the Ethereum blockchain.
|
||||
|
|
|
|||
|
|
@ -56,14 +56,14 @@ var nodeDBKeyTests = []struct {
|
|||
func TestNodeDBKeys(t *testing.T) {
|
||||
for i, tt := range nodeDBKeyTests {
|
||||
if key := makeKey(tt.id, tt.field); !bytes.Equal(key, tt.key) {
|
||||
t.Errorf("make test %d: key mismatch: have 0x%x, want 0x%x", i, key, tt.key)
|
||||
t.Errorf("make test %d: key mismatch: have %#x, want %#x", i, key, tt.key)
|
||||
}
|
||||
id, field := splitKey(tt.key)
|
||||
if !bytes.Equal(id[:], tt.id[:]) {
|
||||
t.Errorf("split test %d: id mismatch: have 0x%x, want 0x%x", i, id, tt.id)
|
||||
t.Errorf("split test %d: id mismatch: have %#x, want %#x", i, id, tt.id)
|
||||
}
|
||||
if field != tt.field {
|
||||
t.Errorf("split test %d: field mismatch: have 0x%x, want 0x%x", i, field, tt.field)
|
||||
t.Errorf("split test %d: field mismatch: have %#x, want %#x", i, field, tt.field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,14 +56,14 @@ var nodeDBKeyTests = []struct {
|
|||
func TestNodeDBKeys(t *testing.T) {
|
||||
for i, tt := range nodeDBKeyTests {
|
||||
if key := makeKey(tt.id, tt.field); !bytes.Equal(key, tt.key) {
|
||||
t.Errorf("make test %d: key mismatch: have 0x%x, want 0x%x", i, key, tt.key)
|
||||
t.Errorf("make test %d: key mismatch: have %#x, want %#x", i, key, tt.key)
|
||||
}
|
||||
id, field := splitKey(tt.key)
|
||||
if !bytes.Equal(id[:], tt.id[:]) {
|
||||
t.Errorf("split test %d: id mismatch: have 0x%x, want 0x%x", i, id, tt.id)
|
||||
t.Errorf("split test %d: id mismatch: have %#x, want %#x", i, id, tt.id)
|
||||
}
|
||||
if field != tt.field {
|
||||
t.Errorf("split test %d: field mismatch: have 0x%x, want 0x%x", i, field, tt.field)
|
||||
t.Errorf("split test %d: field mismatch: have %#x, want %#x", i, field, tt.field)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ func (op ptrOp) genWrite(ctx *genContext, v string) string {
|
|||
|
||||
var b bytes.Buffer
|
||||
fmt.Fprintf(&b, "if %s == nil {\n", v)
|
||||
fmt.Fprintf(&b, " w.Write([]byte{0x%X})\n", op.nilValue)
|
||||
fmt.Fprintf(&b, " w.Write([]byte{%#X})\n", op.nilValue)
|
||||
fmt.Fprintf(&b, "} else {\n")
|
||||
fmt.Fprintf(&b, " %s", op.elem.genWrite(ctx, vv))
|
||||
fmt.Fprintf(&b, "}\n")
|
||||
|
|
|
|||
801
test.txt
Normal file
801
test.txt
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -88,6 +88,6 @@ func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
|
|||
} else {
|
||||
t.Log("EVM operation log:\n" + buf.String())
|
||||
}
|
||||
t.Logf("EVM output: 0x%x", tracer.Output())
|
||||
t.Logf("EVM output: %#x", tracer.Output())
|
||||
t.Logf("EVM error: %v", tracer.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ func runRandTest(rt randTest) bool {
|
|||
v := tr.Get(step.key)
|
||||
want := values[string(step.key)]
|
||||
if string(v) != want {
|
||||
rt[i].err = fmt.Errorf("mismatch for key 0x%x, got 0x%x want 0x%x", step.key, v, want)
|
||||
rt[i].err = fmt.Errorf("mismatch for key %#x, got %#x want %#x", step.key, v, want)
|
||||
}
|
||||
case opCommit:
|
||||
_, rt[i].err = tr.Commit(nil)
|
||||
|
|
|
|||
Loading…
Reference in a new issue