Skip to content

Commit

Permalink
Merge branch 'main' into feat/algod-node-install
Browse files Browse the repository at this point in the history
  • Loading branch information
HashMapsData2Value committed Nov 25, 2024
2 parents 415ea46 + a6c55e6 commit 85f7966
Showing 12 changed files with 116 additions and 59 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.3.2
github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b
github.com/charmbracelet/x/exp/golden v0.0.0-20241022174419-46d9bb99a691
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
6 changes: 4 additions & 2 deletions ui/pages/accounts/accounts_test.go
Original file line number Diff line number Diff line change
@@ -2,14 +2,15 @@ package accounts

import (
"bytes"
"testing"
"time"

"github.com/algorandfoundation/hack-tui/api"
"github.com/algorandfoundation/hack-tui/internal"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/exp/golden"
"github.com/charmbracelet/x/exp/teatest"
"testing"
"time"
)

func Test_Snapshot(t *testing.T) {
@@ -22,6 +23,7 @@ func Test_Snapshot(t *testing.T) {
Admin: false,
Watching: false,
})
model, _ = model.HandleMessage(tea.WindowSizeMsg{Width: 80, Height: 40})
got := ansi.Strip(model.View())
golden.RequireEqual(t, []byte(got))
})
66 changes: 40 additions & 26 deletions ui/pages/accounts/testdata/Test_Snapshot/Visible.golden
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@























╭──────────────────────────────────────────╮
──────────────────┤ (g)enerate | (a)ccounts | (k)eys | (t)xn ├──────────────────
╰──────────────────────────────────────────╯
╭──Accounts────────────────────────────────────────────────────────────────────╮
│ Account Keys Status Expires Balance │
│────────────────────────────────────────────────────────────────────── │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰────( (g)enerate )─────────────────────────| (a)ccounts | (k)eys | (t)xn |────╯
12 changes: 12 additions & 0 deletions ui/protocol_test.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,12 @@ import (
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/exp/golden"
"github.com/charmbracelet/x/exp/teatest"

"github.com/algorandfoundation/hack-tui/internal"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/exp/golden"
"github.com/charmbracelet/x/exp/teatest"
)

var protocolViewSnapshots = map[string]ProtocolViewModel{
@@ -155,5 +161,11 @@ func Test_ProtocolMessages(t *testing.T) {
Runes: []rune("ctrl+c"),
})

// Send quit key
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("ctrl+c"),
})

tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second))
}
4 changes: 2 additions & 2 deletions ui/status.go
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ func (m StatusViewModel) View() string {
roundTime = "--"
}
beginning = style.Blue.Render(" Round time: ") + roundTime
end = fmt.Sprintf("%d KB/s ", m.Data.Metrics.TX/1024) + style.Green.Render("TX ")
end = getBitRate(m.Data.Metrics.TX) + style.Green.Render("TX ")
middle = strings.Repeat(" ", max(0, size-(lipgloss.Width(beginning)+lipgloss.Width(end)+2)))

row2 := lipgloss.JoinHorizontal(lipgloss.Left, beginning, middle, end)
@@ -101,7 +101,7 @@ func (m StatusViewModel) View() string {
tps = "--"
}
beginning = style.Blue.Render(" TPS: ") + tps
end = fmt.Sprintf("%d KB/s ", m.Data.Metrics.RX/1024) + style.Green.Render("RX ")
end = getBitRate(m.Data.Metrics.RX) + style.Green.Render("RX ")
middle = strings.Repeat(" ", max(0, size-(lipgloss.Width(beginning)+lipgloss.Width(end)+2)))

row3 := lipgloss.JoinHorizontal(lipgloss.Left, beginning, middle, end)
19 changes: 19 additions & 0 deletions ui/status_test.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ import (
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/exp/golden"
"github.com/charmbracelet/x/exp/teatest"
)

@@ -111,6 +113,23 @@ func Test_StatusMessages(t *testing.T) {
)

<<<<<<< HEAD

Check failure on line 115 in ui/status_test.go

GitHub Actions / build

expected statement, found '<<'
<<<<<<< HEAD
=======
// Send the state
tm.Send(state)

// Send hide key
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("h"),
})

// Send quit key
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("ctrl+c"),
})
>>>>>>> main
// Send quit msg
tm.Send(tea.QuitMsg{})
=======
46 changes: 22 additions & 24 deletions ui/testdata/Test_ErrorSnapshot/Visible.golden
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@










a test error










╭───────╮
───────────────────────────────────┤ Error ├───────────────────────────────────
╰───────╯
╭──System Error──────────────────────────╮
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ a test error │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
╰─────────( Waiting for recovery... )────╯
4 changes: 4 additions & 0 deletions ui/testdata/Test_ProtocolSnapshot/NoVoteOrUpgrade.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<<<<<<< HEAD
╭──────────────────────────────────────────────────────────────────────────────╮
=======
╭──Protocol────────────────────────────────────────────────────────────────────╮
>>>>>>> main
│ Node: v0.0.0-test │
│ │
│ Network: test-v1 │
4 changes: 4 additions & 0 deletions ui/testdata/Test_ProtocolSnapshot/NoVoteOrUpgradeSmall.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<<<<<<< HEAD
╭──────────────────────────────────────────────────────────────────────────────╮
=======
╭──Protocol────────────────────────────────────────────────────────────────────╮
>>>>>>> main
│ Node: v0.0.0-test │
│ Network: test-v1 │
│ Protocol Voting: false │
4 changes: 4 additions & 0 deletions ui/testdata/Test_ProtocolSnapshot/Visible.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<<<<<<< HEAD
╭──────────────────────────────────────────────────────────────────────────────╮
=======
╭──Protocol────────────────────────────────────────────────────────────────────╮
>>>>>>> main
│ Node: v0.0.0-test [UPDATE AVAILABLE] │
│ │
│ Network: test-v1 │
2 changes: 1 addition & 1 deletion ui/testdata/Test_ProtocolSnapshot/VisibleSmall.golden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
╭──────────────────────────────────────────────────────────────────────────────╮
╭──Protocol────────────────────────────────────────────────────────────────────╮
│ Node: v0.0.0-test │
│ Network: test-v1 │
│ Protocol Voting: true │
6 changes: 3 additions & 3 deletions ui/testdata/Test_StatusSnapshot/Syncing.golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
╭────────────────────────────────────────────────────────────────────────────────────────╮
╭──Status────────────────────────────────────────────────────────────────────────────────╮
│ Latest Round: 1337 SYNCING │
│ │
│ -- 0 round average -- │
│ Round time: 0.00s 0 KB/s TX │
│ TPS: 0.00 0 KB/s RX │
│ Round time: -- 0 B/s TX │
│ TPS: -- 0 B/s RX │
╰────────────────────────────────────────────────────────────────────────────────────────╯

0 comments on commit 85f7966

Please sign in to comment.