Skip to content

Commit

Permalink
Merge pull request #188 from terra-project/develop
Browse files Browse the repository at this point in the history
v0.2.3
  • Loading branch information
dokwon authored Jun 22, 2019
2 parents 10f09c2 + bdf0358 commit 3162406
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 0.2.3
- [\#187](https://github.com/terra-project/core/pull/187): Change all time instance timezone to UTC to remove gap in time calculation

### Changes
#### [\#187](https://github.com/terra-project/core/pull/187) Bugfix/fix-time-zone
In update_230000.go, we change genesis time derivation from
```
genesisTime := time.Unix(genesisUnixTime, 0)
```
to
```
genesisTime := time.Unix(genesisUnixTime, 0).UTC()
```

## 0.2.2

- [\#185](https://github.com/terra-project/core/pull/185): Improve oracle specs
Expand Down
2 changes: 2 additions & 0 deletions types/graded_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func init() {
panic(err)
}

timeGenesis = timeGenesis.UTC()

monthlyTimes = []int64{}
for i := 0; i < 4; i++ {
for j := 0; j < 12; j++ {
Expand Down
2 changes: 2 additions & 0 deletions types/lazy_graded_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func init() {
panic(err)
}

timeGenesis = timeGenesis.UTC()

monthlyTimes = []int64{}
for i := 0; i < 4; i++ {
for j := 0; j < 12; j++ {
Expand Down
4 changes: 2 additions & 2 deletions update/plan/update_230000.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func updatePreseedSchedules(gvacc types.GradedVestingAccount) []types.LazyVestin
var lazyVestingSchedule types.LazyVestingSchedule
var lazySchedules []types.LazySchedule

genesisTime := time.Unix(genesisUnixTime, 0)
genesisTime := time.Unix(genesisUnixTime, 0).UTC()
lazySchedules = append(lazySchedules,
types.NewLazySchedule(
genesisTime.AddDate(0, 1, 0).Unix(), genesisTime.AddDate(0, 2, 0).Unix(), sdk.NewDecWithPrec(10, 2)),
Expand Down Expand Up @@ -251,7 +251,7 @@ func updateSeedSchedules(gvacc types.GradedVestingAccount) []types.LazyVestingSc
var lazyVestingSchedule types.LazyVestingSchedule
var lazySchedules []types.LazySchedule

genesisTime := time.Unix(genesisUnixTime, 0)
genesisTime := time.Unix(genesisUnixTime, 0).UTC()
lazySchedules = append(lazySchedules,
types.NewLazySchedule(
genesisTime.AddDate(0, 1, 0).Unix(), genesisTime.AddDate(0, 2, 0).Unix(), ratio.Mul(sdk.NewDecWithPrec(10, 2))),
Expand Down
14 changes: 13 additions & 1 deletion update/plan/update_230000_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var (
genesisTime = time.Unix(1556085600, 0)
genesisTime = time.Unix(1556085600, 0).UTC()

preseedSchedule types.VestingSchedule
seedSchedule types.VestingSchedule
Expand Down Expand Up @@ -244,6 +244,18 @@ func init() {
}
}

func TestTimeZone(t *testing.T) {
genesisTime := time.Unix(1556085600, 0)
location, _ := time.LoadLocation("Europe/Budapest")
genesisTime = genesisTime.In(location)
result := genesisTime.AddDate(0, 10, 0).Unix()
require.NotEqual(t, int64(1582524000), result)

genesisTime = genesisTime.UTC()
result = genesisTime.AddDate(0, 10, 0).Unix()
require.Equal(t, int64(1582524000), result)
}

func TestPreseedAccountUpdate(t *testing.T) {

for _, acc := range preseedAccounts {
Expand Down

0 comments on commit 3162406

Please sign in to comment.