-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P-chain UTs consolidation 2 - Context and Config #2121
Conversation
0a3cb46
to
079eac8
Compare
|
||
var ( | ||
fork = ts.DurangoFork | ||
forkTime = ts.ValidateStartTime.Add(-2 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
different packages still have different fork times set. We'll fix this in next PR #2169
var ( | ||
fork ts.ActiveFork | ||
forkTime time.Time | ||
) | ||
switch { | ||
case postDurango: | ||
fork = ts.DurangoFork | ||
forkTime = ts.ValidateStartTime.Add(-2 * time.Second).Add(-2 * time.Second) | ||
case postCortina: | ||
fork = ts.CortinaFork | ||
forkTime = ts.ValidateStartTime.Add(-2 * time.Second).Add(-2 * time.Second) | ||
case postBanff: | ||
fork = ts.BanffFork | ||
forkTime = ts.ValidateEndTime.Add(-2 * time.Second) | ||
default: | ||
fork = ts.ApricotPhase5Fork | ||
forkTime = ts.GenesisTime | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of arbitrary, but this is what we have been using fo far. Will be cleaned up in next PR #2169
ApricotPhase3Time: ts.ValidateEndTime, | ||
ApricotPhase5Time: ts.ValidateEndTime, | ||
BanffTime: time.Time{}, // neglecting fork ordering this for package tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is partially fixed in this PR, meaning that at least we sort forks in the right order in testsetup
package. In next PR #2169 we'll complete the fix by using the same fork times across different packages
fork = ts.ApricotPhase5Fork | ||
forkTime = ts.ValidateEndTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these values come from defaultConfig
(now ditched in favour of ts.Config()
)
func Context(tb testing.TB, baseDB database.Database) (*snow.Context, *MutableSharedMemory) { | ||
ctx := snowtest.Context(tb, snowtest.PChainID) | ||
m := atomic.NewMemory(baseDB) | ||
msm := &MutableSharedMemory{ | ||
SharedMemory: m.NewSharedMemory(ctx.ChainID), | ||
} | ||
ctx.SharedMemory = msm | ||
|
||
return ctx, msm | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving this to its own package seems over fragmenting
}, | ||
ApricotPhase3Time: genesistest.ValidateEndTime, | ||
ApricotPhase5Time: genesistest.ValidateEndTime, | ||
BanffTime: time.Time{}, // neglecting fork ordering this for package tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I start changing this partially in this PR and finally fix fork times ordering in next PR
var ( | ||
fork configtest.ActiveFork | ||
forkTime time.Time | ||
) | ||
switch { | ||
case postDurango: | ||
fork = configtest.DurangoFork | ||
forkTime = genesistest.ValidateStartTime.Add(-2 * time.Second).Add(-2 * time.Second) | ||
case postCortina: | ||
fork = configtest.CortinaFork | ||
forkTime = genesistest.ValidateStartTime.Add(-2 * time.Second).Add(-2 * time.Second) | ||
case postBanff: | ||
fork = configtest.BanffFork | ||
forkTime = genesistest.ValidateEndTime.Add(-2 * time.Second) | ||
default: | ||
fork = configtest.ApricotPhase5Fork | ||
forkTime = genesistest.GenesisTime | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just a refactoring of the way we set fork times right now. We'll fix this in next PR
This PR has become stale because it has been open for 30 days with no activity. Adding the |
Why this should be merged
In #2107 we moved to a
genesistest
the machinery to build UTs genesis. Here we keep on going withvm.Config
andvm.Ctx
, moving them to aconfigtest
packageThanks @joshua-kim and @marun for the discussions that brought me to these changes.
How this works
Just refactor UTs setup
How this was tested
CI