all: change format 0x%x
to %#x
(#25221)
This commit is contained in:
parent
953a29f5fd
commit
2697e44d81
@ -178,7 +178,7 @@ func (s *SecureChannelSession) mutuallyAuthenticate() error {
|
||||
return err
|
||||
}
|
||||
if response.Sw1 != 0x90 || response.Sw2 != 0x00 {
|
||||
return fmt.Errorf("got unexpected response from MUTUALLY_AUTHENTICATE: 0x%x%x", response.Sw1, response.Sw2)
|
||||
return fmt.Errorf("got unexpected response from MUTUALLY_AUTHENTICATE: %#x%x", response.Sw1, response.Sw2)
|
||||
}
|
||||
|
||||
if len(response.Data) != scSecretLength {
|
||||
@ -261,7 +261,7 @@ func (s *SecureChannelSession) transmitEncrypted(cla, ins, p1, p2 byte, data []b
|
||||
rapdu.deserialize(plainData)
|
||||
|
||||
if rapdu.Sw1 != sw1Ok {
|
||||
return nil, fmt.Errorf("unexpected response status Cla=0x%x, Ins=0x%x, Sw=0x%x%x", cla, ins, rapdu.Sw1, rapdu.Sw2)
|
||||
return nil, fmt.Errorf("unexpected response status Cla=%#x, Ins=%#x, Sw=%#x%x", cla, ins, rapdu.Sw1, rapdu.Sw2)
|
||||
}
|
||||
|
||||
return rapdu, nil
|
||||
|
@ -167,7 +167,7 @@ func transmit(card *pcsc.Card, command *commandAPDU) (*responseAPDU, error) {
|
||||
}
|
||||
|
||||
if response.Sw1 != sw1Ok {
|
||||
return nil, fmt.Errorf("unexpected insecure response status Cla=0x%x, Ins=0x%x, Sw=0x%x%x", command.Cla, command.Ins, response.Sw1, response.Sw2)
|
||||
return nil, fmt.Errorf("unexpected insecure response status Cla=%#x, Ins=%#x, Sw=%#x%x", command.Cla, command.Ins, response.Sw1, response.Sw2)
|
||||
}
|
||||
|
||||
return response, nil
|
||||
|
@ -496,10 +496,10 @@ func (s *Suite) snapGetAccountRange(t *utesting.T, tc *accRangeTest) error {
|
||||
}
|
||||
if len(hashes) > 0 {
|
||||
if exp, got := tc.expFirst, res.Accounts[0].Hash; exp != got {
|
||||
return fmt.Errorf("expected first account 0x%x, got 0x%x", exp, got)
|
||||
return fmt.Errorf("expected first account %#x, got %#x", exp, got)
|
||||
}
|
||||
if exp, got := tc.expLast, res.Accounts[len(res.Accounts)-1].Hash; exp != got {
|
||||
return fmt.Errorf("expected last account 0x%x, got 0x%x", exp, got)
|
||||
return fmt.Errorf("expected last account %#x, got %#x", exp, got)
|
||||
}
|
||||
}
|
||||
// Reconstruct a partial trie from the response and verify it
|
||||
|
@ -309,7 +309,7 @@ allocated bytes: %d
|
||||
`, initialGas-leftOverGas, stats.time, stats.allocs, stats.bytesAllocated)
|
||||
}
|
||||
if tracer == nil {
|
||||
fmt.Printf("0x%x\n", output)
|
||||
fmt.Printf("%#x\n", output)
|
||||
if err != nil {
|
||||
fmt.Printf(" error: %v\n", err)
|
||||
}
|
||||
|
@ -337,9 +337,9 @@ func checkStateContent(ctx *cli.Context) error {
|
||||
hasher.Read(got)
|
||||
if !bytes.Equal(k, got) {
|
||||
errs++
|
||||
fmt.Printf("Error at 0x%x\n", k)
|
||||
fmt.Printf(" Hash: 0x%x\n", got)
|
||||
fmt.Printf(" Data: 0x%x\n", v)
|
||||
fmt.Printf("Error at %#x\n", k)
|
||||
fmt.Printf(" Hash: %#x\n", got)
|
||||
fmt.Printf(" Data: %#x\n", v)
|
||||
}
|
||||
if time.Since(lastLog) > 8*time.Second {
|
||||
log.Info("Iterating the database", "at", fmt.Sprintf("%#x", k), "elapsed", common.PrettyDuration(time.Since(startTime)))
|
||||
@ -716,7 +716,7 @@ func showMetaData(ctx *cli.Context) error {
|
||||
if val == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return fmt.Sprintf("%d (0x%x)", *val, *val)
|
||||
return fmt.Sprintf("%d (%#x)", *val, *val)
|
||||
}
|
||||
data := [][]string{
|
||||
{"databaseVersion", pp(rawdb.ReadDatabaseVersion(db))},
|
||||
@ -726,7 +726,7 @@ func showMetaData(ctx *cli.Context) error {
|
||||
if b := rawdb.ReadHeadBlock(db); b != nil {
|
||||
data = append(data, []string{"headBlock.Hash", fmt.Sprintf("%v", b.Hash())})
|
||||
data = append(data, []string{"headBlock.Root", fmt.Sprintf("%v", b.Root())})
|
||||
data = append(data, []string{"headBlock.Number", fmt.Sprintf("%d (0x%x)", b.Number(), b.Number())})
|
||||
data = append(data, []string{"headBlock.Number", fmt.Sprintf("%d (%#x)", b.Number(), b.Number())})
|
||||
}
|
||||
if b := rawdb.ReadSkeletonSyncStatus(db); b != nil {
|
||||
data = append(data, []string{"SkeletonSyncStatus", string(b)})
|
||||
@ -734,7 +734,7 @@ func showMetaData(ctx *cli.Context) error {
|
||||
if h := rawdb.ReadHeadHeader(db); h != nil {
|
||||
data = append(data, []string{"headHeader.Hash", fmt.Sprintf("%v", h.Hash())})
|
||||
data = append(data, []string{"headHeader.Root", fmt.Sprintf("%v", h.Root)})
|
||||
data = append(data, []string{"headHeader.Number", fmt.Sprintf("%d (0x%x)", h.Number, h.Number)})
|
||||
data = append(data, []string{"headHeader.Number", fmt.Sprintf("%d (%#x)", h.Number, h.Number)})
|
||||
}
|
||||
data = append(data, [][]string{{"frozen", fmt.Sprintf("%d items", ancients)},
|
||||
{"lastPivotNumber", pp(rawdb.ReadLastPivotNumber(db))},
|
||||
|
@ -83,7 +83,7 @@ func main() {
|
||||
if err != nil {
|
||||
die(err)
|
||||
}
|
||||
fmt.Printf("0x%x\n", data)
|
||||
fmt.Printf("%#x\n", data)
|
||||
return
|
||||
} else {
|
||||
err := rlpToText(r, out)
|
||||
|
@ -43,7 +43,7 @@ func TestRoundtrip(t *testing.T) {
|
||||
t.Errorf("test %d: error %v", i, err)
|
||||
continue
|
||||
}
|
||||
have := fmt.Sprintf("0x%x", rlpBytes)
|
||||
have := fmt.Sprintf("%#x", rlpBytes)
|
||||
if have != want {
|
||||
t.Errorf("test %d: have\n%v\nwant:\n%v\n", i, have, want)
|
||||
}
|
||||
|
@ -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("%05x: %v 0x%x\n", it.PC(), it.Op(), it.Arg())
|
||||
fmt.Printf("%05x: %v %#x\n", it.PC(), it.Op(), it.Arg())
|
||||
} else {
|
||||
fmt.Printf("%05x: %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("%05x: %v 0x%x\n", it.PC(), it.Op(), it.Arg()))
|
||||
instrs = append(instrs, fmt.Sprintf("%05x: %v %#x\n", it.PC(), it.Op(), it.Arg()))
|
||||
} else {
|
||||
instrs = append(instrs, fmt.Sprintf("%05x: %v\n", it.PC(), it.Op()))
|
||||
}
|
||||
|
@ -2342,7 +2342,7 @@ func (bc *BlockChain) reportBlock(block *types.Block, receipts types.Receipts, e
|
||||
Chain config: %v
|
||||
|
||||
Number: %v
|
||||
Hash: 0x%x
|
||||
Hash: %#x
|
||||
%v
|
||||
|
||||
Error: %v
|
||||
|
@ -197,7 +197,7 @@ func printList(l types.DerivableList) {
|
||||
for i := 0; i < l.Len(); i++ {
|
||||
var buf bytes.Buffer
|
||||
l.EncodeIndex(i, &buf)
|
||||
fmt.Printf("\"0x%x\",\n", buf.Bytes())
|
||||
fmt.Printf("\"%#x\",\n", buf.Bytes())
|
||||
}
|
||||
fmt.Printf("},\n")
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ type JumpTable [256]*operation
|
||||
func validate(jt JumpTable) JumpTable {
|
||||
for i, op := range jt {
|
||||
if op == nil {
|
||||
panic(fmt.Sprintf("op 0x%x is not set", i))
|
||||
panic(fmt.Sprintf("op %#x is not set", i))
|
||||
}
|
||||
// The interpreter has an assumption that if the memorySize function is
|
||||
// set, then the dynamicGas function is also set. This is a somewhat
|
||||
|
@ -392,7 +392,7 @@ var opCodeToString = map[OpCode]string{
|
||||
func (op OpCode) String() string {
|
||||
str := opCodeToString[op]
|
||||
if len(str) == 0 {
|
||||
return fmt.Sprintf("opcode 0x%x not defined", int(op))
|
||||
return fmt.Sprintf("opcode %#x not defined", int(op))
|
||||
}
|
||||
|
||||
return str
|
||||
|
@ -503,7 +503,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()))
|
||||
}
|
||||
@ -511,7 +511,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{
|
||||
|
@ -316,7 +316,7 @@ func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
|
||||
if rlpBytes, err := rlp.EncodeToBytes(block); err != nil {
|
||||
blockRlp = err.Error() // Hacky, but hey, it works
|
||||
} else {
|
||||
blockRlp = fmt.Sprintf("0x%x", rlpBytes)
|
||||
blockRlp = fmt.Sprintf("%#x", rlpBytes)
|
||||
}
|
||||
if blockJSON, err = ethapi.RPCMarshalBlock(block, true, true, api.eth.APIBackend.ChainConfig()); err != nil {
|
||||
blockJSON = map[string]interface{}{"error": err.Error()}
|
||||
|
@ -213,7 +213,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)
|
||||
}
|
||||
|
@ -224,7 +224,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)
|
||||
}
|
||||
@ -346,11 +346,11 @@ func NewMarkdownLogger(cfg *Config, writer io.Writer) *mdLogger {
|
||||
func (t *mdLogger) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||
t.env = env
|
||||
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)
|
||||
}
|
||||
@ -387,7 +387,7 @@ func (t *mdLogger) CaptureFault(pc uint64, op vm.OpCode, gas, cost uint64, scope
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -1950,7 +1950,7 @@ func (api *DebugAPI) SeedHash(ctx context.Context, number uint64) (string, error
|
||||
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
|
||||
}
|
||||
|
||||
// ChaindbProperty returns leveldb properties of the key-value database.
|
||||
|
@ -55,7 +55,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[:])
|
||||
}
|
||||
|
||||
// String returns a printable representation of the nonce.
|
||||
@ -75,7 +75,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[:])
|
||||
}
|
||||
|
||||
// String returns a printable representation of the bloom filter.
|
||||
|
@ -659,7 +659,7 @@ func formatPrimitiveValue(encType string, encValue interface{}) (string, error)
|
||||
if b, err := parseInteger(encType, encValue); err != nil {
|
||||
return "", err
|
||||
} else {
|
||||
return fmt.Sprintf("%d (0x%x)", b, b), nil
|
||||
return fmt.Sprintf("%d (%#x)", b, b), nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("unhandled type %v", encType)
|
||||
|
@ -129,7 +129,7 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
|
||||
{
|
||||
Name: "Full message for signing",
|
||||
Typ: "hexdata",
|
||||
Value: fmt.Sprintf("0x%x", msg),
|
||||
Value: fmt.Sprintf("%#x", msg),
|
||||
},
|
||||
}
|
||||
req = &SignDataRequest{ContentType: mediaType, Rawdata: []byte(msg), Messages: messages, Hash: sighash}
|
||||
@ -161,7 +161,7 @@ func (api *SignerAPI) determineSignatureFormat(ctx context.Context, contentType
|
||||
{
|
||||
Name: "Clique header",
|
||||
Typ: "clique",
|
||||
Value: fmt.Sprintf("clique header %d [0x%x]", header.Number, header.Hash()),
|
||||
Value: fmt.Sprintf("clique header %d [%#x]", header.Number, header.Hash()),
|
||||
},
|
||||
}
|
||||
// Clique uses V on the form 0 or 1
|
||||
|
@ -185,7 +185,7 @@ func (f *fuzzer) fuzz() int {
|
||||
sort.Sort(vals)
|
||||
for _, kv := range vals {
|
||||
if f.debugging {
|
||||
fmt.Printf("{\"0x%x\" , \"0x%x\"} // stacktrie.Update\n", kv.k, kv.v)
|
||||
fmt.Printf("{\"%#x\" , \"%#x\"} // stacktrie.Update\n", kv.k, kv.v)
|
||||
}
|
||||
trieB.Update(kv.k, kv.v)
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ func runRandTest(rt randTest) error {
|
||||
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)
|
||||
|
@ -432,7 +432,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 New Issue
Block a user