Skip to content

Commit

Permalink
convert %#v/%v to %#x for hex output
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Apr 21, 2023
1 parent a79532b commit 4d37eff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions data/transactions/logic/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (cx *EvalContext) availableBox(name string, operation int, createSize uint6

dirty, ok := cx.available.boxes[boxRef{cx.appID, name}]
if !ok {
return nil, false, fmt.Errorf("invalid Box reference %v", name)
return nil, false, fmt.Errorf("invalid Box reference %#x", name)
}

// Since the box is in cx.available, we know this GetBox call is cheap. It
Expand Down Expand Up @@ -150,7 +150,7 @@ func opBoxExtract(cx *EvalContext) error {
return err
}
if !exists {
return fmt.Errorf("no such box %#v", name)
return fmt.Errorf("no such box %#x", name)
}

bytes, err := extractCarefully(contents, start, length)
Expand Down Expand Up @@ -178,7 +178,7 @@ func opBoxReplace(cx *EvalContext) error {
return err
}
if !exists {
return fmt.Errorf("no such box %#v", name)
return fmt.Errorf("no such box %#x", name)
}

bytes, err := replaceCarefully(contents, replacement, start)
Expand Down
2 changes: 1 addition & 1 deletion data/transactions/logic/box_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func TestBoxAvailability(t *testing.T) {
logic.TestApps(t, []string{
`byte "self"; int 64; box_create`,
`byte "B"; int 10; int 4; box_extract; byte 0x00000000; ==`,
}, nil, 8, ledger, logic.NewExpect(1, "invalid Box reference B"))
}, nil, 8, ledger, logic.NewExpect(1, "invalid Box reference 0x42"))

// B is available if indexed by 0 in tx[1].Boxes
group := logic.MakeSampleTxnGroup(logic.MakeSampleTxn(), txntest.Txn{
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/logic/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ func (l *Ledger) NewBox(appIdx basics.AppIndex, key string, value []byte, appAdd
}
if current, ok := params.boxMods[key]; ok {
if current != nil {
return fmt.Errorf("attempt to recreate %s", key)
return fmt.Errorf("attempt to recreate %#v", key)
}
} else if _, ok := params.boxes[key]; ok {
return fmt.Errorf("attempt to recreate %s", key)
return fmt.Errorf("attempt to recreate %#x", key)
}
params.boxMods[key] = value
l.applications[appIdx] = params
Expand Down
6 changes: 3 additions & 3 deletions ledger/eval/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (cs *roundCowState) NewBox(appIdx basics.AppIndex, key string, value []byte
return err
}
if exists {
return fmt.Errorf("attempt to recreate %s", key)
return fmt.Errorf("attempt to recreate %#x", key)
}

record, err := cs.Get(appAddr, false)
Expand Down Expand Up @@ -258,10 +258,10 @@ func (cs *roundCowState) SetBox(appIdx basics.AppIndex, key string, value []byte
return err
}
if !ok {
return fmt.Errorf("box %s does not exist for %d", key, appIdx)
return fmt.Errorf("box %#x does not exist for %d", key, appIdx)
}
if len(old) != len(value) {
return fmt.Errorf("box %s is wrong size old:%d != new:%d",
return fmt.Errorf("box %#x is wrong size old:%d != new:%d",
key, len(old), len(value))
}
return cs.kvPut(fullKey, value)
Expand Down

0 comments on commit 4d37eff

Please sign in to comment.