-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update go mod * clock package * refactor network * new cmd * last changes * typoe * import * fix unit test * fix test 2 * Upgrade for send request * publish: add balance * new logic for adding accounts * format * change switch * changelog * Update ignite/cmd/network_chain_join.go Co-authored-by: Thomas Bruyelle <[email protected]> Co-authored-by: Alex Johnson <[email protected]> Co-authored-by: Thomas Bruyelle <[email protected]>
- Loading branch information
1 parent
e778671
commit 83ab4c8
Showing
21 changed files
with
432 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package xtime | ||
|
||
import "time" | ||
|
||
// Clock represents a clock that can retrieve current time | ||
type Clock interface { | ||
Now() time.Time | ||
Add(duration time.Duration) | ||
} | ||
|
||
// ClockSystem is a clock that retrieves system time | ||
type ClockSystem struct{} | ||
|
||
// NewClockSystem returns a new ClockSystem | ||
func NewClockSystem() ClockSystem { | ||
return ClockSystem{} | ||
} | ||
|
||
// Now implements Clock | ||
func (ClockSystem) Now() time.Time { | ||
return time.Now() | ||
} | ||
|
||
// Add implements Clock | ||
func (ClockSystem) Add(_ time.Duration) { | ||
panic("Add can't be called for ClockSystem") | ||
} | ||
|
||
// ClockMock is a clock mocking time with an internal counter | ||
type ClockMock struct { | ||
t time.Time | ||
} | ||
|
||
// NewClockMock returns a new ClockMock | ||
func NewClockMock(originalTime time.Time) *ClockMock { | ||
return &ClockMock{ | ||
t: originalTime, | ||
} | ||
} | ||
|
||
// Now implements Clock | ||
func (c ClockMock) Now() time.Time { | ||
return c.t | ||
} | ||
|
||
// Add implements Clock | ||
func (c *ClockMock) Add(duration time.Duration) { | ||
c.t = c.t.Add(duration) | ||
} |
Oops, something went wrong.