Skip to content

Commit

Permalink
fix tests failing (yay CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
mleku committed Dec 10, 2024
1 parent 07c9968 commit 7921af4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 53 deletions.
9 changes: 1 addition & 8 deletions event/canonical.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package event

import (
"io"
"reflect"

"realy.lol/ec/schnorr"
"realy.lol/hex"
"realy.lol/json"
"realy.lol/kind"
Expand Down Expand Up @@ -55,12 +53,7 @@ var minimal = len(`[0,"0123456789abcdef0123456789abcdef",1733739427,0,[],""]`)
// form. Allocate an event.T before calling this.
func (ev *T) FromCanonical(b by) (rem by, err er) {
rem = b
end := len(rem) - schnorr.SignatureSize
if end < minimal {
err = io.EOF
return
}
id := Hash(rem[:end])
id := Hash(rem)
c := NewCanonical()
if rem, err = c.Unmarshal(rem); chk.E(err) {
return
Expand Down
4 changes: 4 additions & 0 deletions event/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ func (ev *T) MarshalCompact(dst by) (b by) {
}

func (ev *T) UnmarshalCompact(b by) (rem by, err er) {
rem = b
end := len(rem) - schnorr.SignatureSize
id := Hash(rem[:end])
if rem, err = ev.FromCanonical(b); chk.E(err) {
return
}
ev.Sig = rem[:schnorr.SignatureSize]
ev.ID = id
rem = rem[schnorr.SignatureSize:]
return
}
47 changes: 3 additions & 44 deletions lol/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/davecgh/go-spew/spew"
"github.com/fatih/color"
tsize "github.com/kopoli/go-terminal-size"

"realy.lol/atomic"
)
Expand Down Expand Up @@ -78,7 +77,6 @@ type (
)

var (
width = 80
// sep is just a convenient shortcut for this very longwinded expression
sep = string(os.PathSeparator)
// writer can be swapped out for any io.*writer* that you want to use instead of
Expand Down Expand Up @@ -124,10 +122,6 @@ func init() {
// Main = &Logger{}
Main.Log, Main.Check, Main.Errorf = New(os.Stderr)
SetLoggers(Info)
// SetLoggers(Trace)
if s, err := tsize.GetSize(); err == nil {
width = s.Width - 4
}
}

func SetLoggers(level no) {
Expand Down Expand Up @@ -165,41 +159,6 @@ func JoinStrings(a ...any) (s string) {

var msgCol = color.New(color.FgBlue).Sprint

func BreakToWidth(s string) (out string) {
if len(s) < width {
return s
}
var ss []string
split := strings.Split(s, "\n")
for _, s := range split {
for len(s) > 0 {
if len(s) > width {
if strings.Contains(s[:width], ",") {
commas := strings.Split(s[:width], ",")
if len(commas) > 1 {
last := len(commas) - 1
ss = append(ss, strings.Join(commas[:last], ",")+",")
s = commas[last] + s[width:]
} else {
ss = append(ss, s[:width])
s = s[width:]
}
} else {
ss = append(ss, s[:width])
s = s[width:]
}
} else {
ss = append(ss, s)
s = s[:0]
ss = append(ss, "")
}
}
}
out = "\n" + strings.Join(ss, "\n")
strings.ReplaceAll(out, "\n\n", "\n")
return
}

func GetPrinter(l int32, writer io.Writer) LevelPrinter {
return LevelPrinter{
Ln: func(a ...interface{}) {
Expand All @@ -210,7 +169,7 @@ func GetPrinter(l int32, writer io.Writer) LevelPrinter {
"%s%s %s %s\n",
msgCol(Timestamper()),
LevelSpecs[l].Colorizer(LevelSpecs[l].Name),
BreakToWidth(JoinStrings(a...)),
JoinStrings(a...),
msgCol(GetLoc(2)),
)
},
Expand All @@ -222,7 +181,7 @@ func GetPrinter(l int32, writer io.Writer) LevelPrinter {
"%s%s %s %s\n",
msgCol(Timestamper()),
LevelSpecs[l].Colorizer(LevelSpecs[l].Name),
BreakToWidth(fmt.Sprintf(format, a...)),
fmt.Sprintf(format, a...),
msgCol(GetLoc(2)),
)
},
Expand All @@ -246,7 +205,7 @@ func GetPrinter(l int32, writer io.Writer) LevelPrinter {
"%s%s %s %s\n",
msgCol(Timestamper()),
LevelSpecs[l].Colorizer(LevelSpecs[l].Name),
BreakToWidth(closure()),
closure(),
msgCol(GetLoc(2)),
)
},
Expand Down
2 changes: 1 addition & 1 deletion realy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.3.4
v1.3.5

0 comments on commit 7921af4

Please sign in to comment.