Skip to content

Commit

Permalink
test: fix bug with usage of time.Now()
Browse files Browse the repository at this point in the history
  • Loading branch information
mbreithecker committed Oct 26, 2023
1 parent 1ebec79 commit 04f459d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
8 changes: 6 additions & 2 deletions x/pool/keeper/msg_server_cancel_runtime_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() {
gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String()
votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod

var currentTime uint64

BeforeEach(func() {
s = i.NewCleanChain()

Expand All @@ -43,6 +45,8 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() {
}
pool.Runtime = "@kyve/test"
s.App().PoolKeeper.SetPool(s.Ctx(), pool)

currentTime = uint64(time.Now().Unix())
})

AfterEach(func() {
Expand Down Expand Up @@ -87,7 +91,7 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down Expand Up @@ -139,7 +143,7 @@ var _ = Describe("msg_server_cancel_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()),
ScheduledAt: currentTime,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down
26 changes: 15 additions & 11 deletions x/pool/keeper/msg_server_schedule_runtime_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
gov := s.App().GovKeeper.GetGovernanceAccount(s.Ctx()).GetAddress().String()
votingPeriod := s.App().GovKeeper.GetParams(s.Ctx()).VotingPeriod

var currentTime uint64

BeforeEach(func() {
s = i.NewCleanChain()

Expand All @@ -46,6 +48,8 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
}
pool.Runtime = "@kyve/test"
s.App().PoolKeeper.SetPool(s.Ctx(), pool)

currentTime = uint64(time.Now().Unix())
})

AfterEach(func() {
Expand All @@ -58,7 +62,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Authority: i.DUMMY[0],
Runtime: "@kyve/test",
Version: "1.0.0",
ScheduledAt: uint64(time.Now().Unix()),
ScheduledAt: currentTime,
}

// ACT
Expand All @@ -76,7 +80,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()),
ScheduledAt: currentTime,
}

proposal, _ := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand All @@ -96,7 +100,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()),
ScheduledAt: currentTime,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down Expand Up @@ -125,7 +129,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()),
ScheduledAt: currentTime,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down Expand Up @@ -154,7 +158,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()) - 7*24*3600,
ScheduledAt: currentTime - 7*24*3600,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down Expand Up @@ -191,7 +195,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand All @@ -215,7 +219,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Expect(pool.UpgradePlan).To(Equal(&types.UpgradePlan{
Version: "1.0.0",
Binaries: "{}",
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
Duration: 60,
}))
})
Expand All @@ -228,7 +232,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "1.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand All @@ -251,7 +255,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Expect(pool.UpgradePlan).To(Equal(&types.UpgradePlan{
Version: "1.0.0",
Binaries: "{}",
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
Duration: 60,
}))

Expand All @@ -262,7 +266,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Version: "2.0.0",
Binaries: "{}",
Duration: 60,
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
}

p, v = BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand All @@ -285,7 +289,7 @@ var _ = Describe("msg_server_schedule_runtime_upgrade.go", Ordered, func() {
Expect(pool.UpgradePlan).To(Equal(&types.UpgradePlan{
Version: "1.0.0",
Binaries: "{}",
ScheduledAt: uint64(time.Now().Unix()) + 7*24*3600,
ScheduledAt: currentTime + 7*24*3600,
Duration: 60,
}))
})
Expand Down
3 changes: 2 additions & 1 deletion x/query/client/cli/query_fundings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package cli

import (
"context"
"strconv"

"github.com/KYVENetwork/chain/x/query/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/spf13/cobra"
"strconv"
)

func byFunder(
Expand Down

0 comments on commit 04f459d

Please sign in to comment.