Skip to content

Commit 4822c1e

Browse files
author
Tasos Bitsios
committed
fix: test
1 parent f6cd5a2 commit 4822c1e

File tree

7 files changed

+32
-24
lines changed

7 files changed

+32
-24
lines changed

ui/internal/test/state.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ import (
1212
func GetState(client api.ClientWithResponsesInterface) *algod.StateModel {
1313
sm := &algod.StateModel{
1414
Status: algod.Status{
15-
State: algod.StableState,
16-
Version: "v-test",
17-
Network: "v-test-network",
18-
UpgradeNextProtocolVoteBefore: 0,
19-
UpgradeVoteRounds: 0,
20-
UpgradeYesVotes: 0,
21-
UpgradeNoVotes: 0,
22-
UpgradeVotes: 0,
23-
UpgradeVotesRequired: 0,
24-
NeedsUpdate: false,
25-
LastRound: 0,
15+
State: algod.StableState,
16+
Version: "v-test",
17+
Network: "v-test-network",
18+
UpgradeVoteRounds: 0,
19+
UpgradeYesVotes: 0,
20+
UpgradeNoVotes: 0,
21+
UpgradeVotes: 0,
22+
UpgradeVotesRequired: 0,
23+
NeedsUpdate: false,
24+
LastRound: 0,
2625

2726
Client: client,
2827
HttpPkg: new(api.HttpPkg),

ui/protocol.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ func formatScheduledUpgrade(status algod.Status, metrics algod.Metrics) string {
7171
days := int(eta.Hours()) / 24
7272
str := "Scheduled"
7373
if days > 0 {
74-
str = str + fmt.Sprintf(" %d %s", days, plural("day", minutes))
74+
str = str + fmt.Sprintf(" %d %s", days, plural("day", days))
7575
}
7676
if hours > 0 {
77-
str = str + fmt.Sprintf(" %d %s", hours, plural("hour", minutes))
77+
str = str + fmt.Sprintf(" %d %s", hours, plural("hour", hours))
7878
}
7979
if days == 0 && minutes > 0 {
8080
str = str + fmt.Sprintf(" %d %s", minutes, plural("min", minutes))
@@ -93,7 +93,7 @@ func formatProtocolVote(status algod.Status, metrics algod.Metrics) string {
9393
}
9494

9595
totalVotesCast := status.UpgradeYesVotes + status.UpgradeNoVotes
96-
percentageProgress := 100 * totalVotesCast / status.UpgradeVotesRequired
96+
percentageProgress := 100 * totalVotesCast / status.UpgradeVoteRounds
9797
percentageYes := 100 * status.UpgradeYesVotes / totalVotesCast
9898

9999
label := "Yes"
@@ -110,7 +110,7 @@ func formatProtocolVote(status algod.Status, metrics algod.Metrics) string {
110110
}
111111
failThreshold := status.UpgradeVoteRounds - status.UpgradeVotesRequired
112112
if status.UpgradeNoVotes > failThreshold {
113-
statusString = statusString + ", will not pass"
113+
statusString = statusString + ", will fail"
114114
}
115115
return statusString
116116
}

ui/protocol_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var protocolViewSnapshots = map[string]ProtocolViewModel{
1818
State: algod.SyncingState,
1919
Version: "v0.0.0-test",
2020
Network: "test-v1",
21+
NextVersionRound: 1,
2122
UpgradeVoteRounds: 10000,
2223
UpgradeYesVotes: 841,
2324
UpgradeNoVotes: 841,
@@ -35,6 +36,7 @@ var protocolViewSnapshots = map[string]ProtocolViewModel{
3536
State: algod.SyncingState,
3637
Version: "v0.0.0-test",
3738
Network: "test-v1",
39+
NextVersionRound: 1,
3840
UpgradeVoteRounds: 10000,
3941
UpgradeYesVotes: 841,
4042
UpgradeNoVotes: 841,
@@ -52,10 +54,11 @@ var protocolViewSnapshots = map[string]ProtocolViewModel{
5254
State: algod.SyncingState,
5355
Version: "v0.0.0-test",
5456
Network: "test-v1",
57+
NextVersionRound: 1,
5558
UpgradeVoteRounds: 10000,
56-
UpgradeYesVotes: 841,
57-
UpgradeNoVotes: 841,
58-
UpgradeVotes: 1682,
59+
UpgradeYesVotes: 3750,
60+
UpgradeNoVotes: 1250,
61+
UpgradeVotes: 5000,
5962
UpgradeVotesRequired: 9000,
6063
NeedsUpdate: true,
6164
LastRound: 0,
@@ -69,13 +72,17 @@ var protocolViewSnapshots = map[string]ProtocolViewModel{
6972
State: algod.SyncingState,
7073
Version: "v0.0.0-test",
7174
Network: "test-v1",
75+
NextVersionRound: 180777,
7276
UpgradeVoteRounds: 10000,
7377
UpgradeYesVotes: 841,
7478
UpgradeNoVotes: 841,
7579
UpgradeVotes: 1682,
7680
UpgradeVotesRequired: 9000,
7781
NeedsUpdate: true,
78-
LastRound: 0,
82+
LastRound: 100,
83+
},
84+
Metrics: algod.Metrics{
85+
RoundTime: time.Duration(2.89 * float64(time.Second)),
7986
},
8087
TerminalWidth: 80,
8188
TerminalHeight: 40,
@@ -86,6 +93,7 @@ var protocolViewSnapshots = map[string]ProtocolViewModel{
8693
State: algod.SyncingState,
8794
Version: "v0.0.0-test",
8895
Network: "test-v1",
96+
NextVersionRound: 1,
8997
UpgradeVoteRounds: 0,
9098
UpgradeYesVotes: 0,
9199
UpgradeNoVotes: 0,
@@ -103,6 +111,7 @@ var protocolViewSnapshots = map[string]ProtocolViewModel{
103111
State: algod.SyncingState,
104112
Version: "v0.0.0-test",
105113
Network: "test-v1",
114+
NextVersionRound: 1,
106115
UpgradeVoteRounds: 0,
107116
UpgradeYesVotes: 0,
108117
UpgradeNoVotes: 0,

ui/testdata/Test_ProtocolSnapshot/NoVoteOrUpgrade.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
│ Network: test-v1 │
55
│ │
66
│ Protocol Upgrade: No │
7-
╰──────────────────────────────────────────────────────────────────────────────╯
7+
╰──────────────────────────────────────────────────────────────────────────────╯

ui/testdata/Test_ProtocolSnapshot/NoVoteOrUpgradeSmall.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
│ Protocol Upgrade: No │
55
│ │
66
│ │
7-
╰──────────────────────────────────────────────────────────────────────────────╯
7+
╰──────────────────────────────────────────────────────────────────────────────╯

ui/testdata/Test_ProtocolSnapshot/Visible.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
│ │
44
│ Network: test-v1 │
55
│ │
6-
Consensus Upgrade Voting: true
7-
╰──────────────────────────────────────────────────────────────────────────────╯
6+
Protocol Upgrade: Voting 50% complete, 75% Yes, will fail
7+
╰──────────────────────────────────────────────────────────────────────────────╯
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
╭──Protocol────────────────────────────────────────────────────────────────────╮
22
│ Node: v0.0.0-test │
33
│ Network: test-v1 │
4-
│ Protocol Upgrade: No
4+
│ Protocol Upgrade: Scheduled 6 days 1 hour
55
│ Upgrade Available: true │
66
│ │
77
╰──────────────────────────────────────────────────────────────────────────────╯

0 commit comments

Comments
 (0)