From 7921af4308fe1213cb193712f90bb9568943a176 Mon Sep 17 00:00:00 2001 From: mleku Date: Tue, 10 Dec 2024 21:03:45 +0000 Subject: [PATCH] fix tests failing (yay CI) --- event/canonical.go | 9 +-------- event/compact.go | 4 ++++ lol/log.go | 47 +++------------------------------------------- realy/version | 2 +- 4 files changed, 9 insertions(+), 53 deletions(-) diff --git a/event/canonical.go b/event/canonical.go index 81e15d3..21072fa 100644 --- a/event/canonical.go +++ b/event/canonical.go @@ -1,10 +1,8 @@ package event import ( - "io" "reflect" - "realy.lol/ec/schnorr" "realy.lol/hex" "realy.lol/json" "realy.lol/kind" @@ -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 diff --git a/event/compact.go b/event/compact.go index e5f4d53..f029c52 100644 --- a/event/compact.go +++ b/event/compact.go @@ -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 } diff --git a/lol/log.go b/lol/log.go index b94356e..ccef517 100644 --- a/lol/log.go +++ b/lol/log.go @@ -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" ) @@ -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 @@ -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) { @@ -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{}) { @@ -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)), ) }, @@ -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)), ) }, @@ -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)), ) }, diff --git a/realy/version b/realy/version index 2f93383..a3a007c 100644 --- a/realy/version +++ b/realy/version @@ -1 +1 @@ -v1.3.4 \ No newline at end of file +v1.3.5 \ No newline at end of file