Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jan 7, 2025
2 parents 84f9f73 + 929817b commit f97afc9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions challenger/db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestChallenge(t *testing.T) {
Type: challengertypes.EventTypeDeposit,
Id: 10,
},
Time: time.Unix(0, 10000),
Time: time.Unix(0, 10000).UTC(),
}

challenges, err := LoadChallenges(db)
Expand Down Expand Up @@ -110,13 +110,13 @@ func TestDeleteFutureChallenges(t *testing.T) {
Type: challengertypes.EventTypeOracle,
Id: uint64(i),
},
Time: time.Unix(0, int64(i)),
Time: time.Unix(0, int64(i)).UTC(),
}
err = SaveChallenge(db, challenge)
require.NoError(t, err)
}

err = DeleteFutureChallenges(db, time.Unix(0, 5))
err = DeleteFutureChallenges(db, time.Unix(0, 5).UTC())
require.NoError(t, err)

challenges, err := LoadChallenges(db)
Expand All @@ -127,7 +127,7 @@ func TestDeleteFutureChallenges(t *testing.T) {
require.Equal(t, uint64(i), challenges[i-1].Id.Id)
}

err = DeleteFutureChallenges(db, time.Unix(0, 8))
err = DeleteFutureChallenges(db, time.Unix(0, 8).UTC())
require.NoError(t, err)

challenges, err = LoadChallenges(db)
Expand All @@ -138,7 +138,7 @@ func TestDeleteFutureChallenges(t *testing.T) {
require.Equal(t, uint64(i), challenges[i-1].Id.Id)
}

err = DeleteFutureChallenges(db, time.Unix(0, 0))
err = DeleteFutureChallenges(db, time.Unix(0, 0).UTC())
require.NoError(t, err)

challenges, err = LoadChallenges(db)
Expand Down
6 changes: 3 additions & 3 deletions challenger/eventhandler/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func TestDBLoadPendingEvents(t *testing.T) {
require.NoError(t, err)

events := []challengertypes.ChallengeEvent{
challengertypes.NewDeposit(1, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 100)),
challengertypes.NewDeposit(2, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 101)),
challengertypes.NewOracle(1, []byte("data"), time.Unix(0, 102)),
challengertypes.NewDeposit(1, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 100).UTC()),
challengertypes.NewDeposit(2, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 101).UTC()),
challengertypes.NewOracle(1, []byte("data"), time.Unix(0, 102).UTC()),
}

err = SavePendingEvents(db, events)
Expand Down
20 changes: 10 additions & 10 deletions challenger/eventhandler/pending_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ func TestPendingEvent(t *testing.T) {
require.ElementsMatch(t, pendingEvents, events)

processedEvents := []challengertypes.ChallengeEvent{
challengertypes.NewDeposit(1, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 100)),
challengertypes.NewOracle(3, []byte("data"), time.Unix(0, 103)),
challengertypes.NewDeposit(1, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 100).UTC()),
challengertypes.NewOracle(3, []byte("data"), time.Unix(0, 103).UTC()),
}

unprocessedEvents := eventHandler.GetUnprocessedPendingEvents(processedEvents)
require.Equal(t, unprocessedEvents, []challengertypes.ChallengeEvent{
challengertypes.NewDeposit(2, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 101)),
challengertypes.NewOracle(4, []byte("data2"), time.Unix(0, 104)),
challengertypes.NewDeposit(2, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 101).UTC()),
challengertypes.NewOracle(4, []byte("data2"), time.Unix(0, 104).UTC()),
})

sortedPendingEvents := eventHandler.GetAllSortedPendingEvents()
require.Equal(t, sortedPendingEvents, []challengertypes.ChallengeEvent{
challengertypes.NewDeposit(1, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 100)),
challengertypes.NewDeposit(2, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 101)),
challengertypes.NewOracle(3, []byte("data"), time.Unix(0, 103)),
challengertypes.NewOracle(4, []byte("data2"), time.Unix(0, 104)),
challengertypes.NewDeposit(1, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 100).UTC()),
challengertypes.NewDeposit(2, 2, "from", "to", "l1Denom", "amount", time.Unix(0, 101).UTC()),
challengertypes.NewOracle(3, []byte("data"), time.Unix(0, 103).UTC()),
challengertypes.NewOracle(4, []byte("data2"), time.Unix(0, 104).UTC()),
})

eventHandler.DeletePendingEvent(events[0].Id())
Expand All @@ -66,8 +66,8 @@ func TestPendingEvent(t *testing.T) {
oracleEvents := eventHandler.getOraclePendingEvents(5)
require.Len(t, oracleEvents, 2)
require.Equal(t, oracleEvents, []challengertypes.ChallengeEvent{
challengertypes.NewOracle(3, []byte("data"), time.Unix(0, 103)),
challengertypes.NewOracle(4, []byte("data2"), time.Unix(0, 104)),
challengertypes.NewOracle(3, []byte("data"), time.Unix(0, 103).UTC()),
challengertypes.NewOracle(4, []byte("data2"), time.Unix(0, 104).UTC()),
})

eventHandler.DeletePendingEvents(events[1:])
Expand Down
2 changes: 1 addition & 1 deletion challenger/host/deposit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestInitializeDepositHandler(t *testing.T) {
initialL1Sequence: 0,
eventHandlerArgs: nodetypes.EventHandlerArgs{
BlockHeight: 1,
BlockTime: time.Unix(0, 100),
BlockTime: time.Unix(0, 100).UTC(),
LatestHeight: 1,
TxIndex: 0,
EventAttributes: hostprovider.InitiateTokenDepositEvents(1, "init1hrasklz3tr6s9rls4r8fjuf0k4zuha6w9rude5", "init1z3689ct7pc72yr5an97nsj89dnlefydxwdhcv0", sdk.NewInt64Coin("l1Denom", 100), []byte("databytes"), 1, "l2denom"),
Expand Down

0 comments on commit f97afc9

Please sign in to comment.