Skip to content
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

client/testing: Make simnet tests modular. #1603

Merged
merged 2 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/asset/eth/eth.go
Expand Up @@ -2219,8 +2219,8 @@ func (eth *baseWallet) SyncStatus() (bool, float32, error) {
// and after it has finished. In order to discern when syncing has begun,
// check that the best header came in under dexeth.MaxBlockInterval.
prog := eth.node.syncProgress()
syncing := prog.CurrentBlock >= prog.HighestBlock
if !syncing {
syncing := prog.CurrentBlock < prog.HighestBlock || prog.HighestBlock == 0
if syncing {
var ratio float32
if prog.HighestBlock != 0 {
ratio = float32(prog.CurrentBlock) / float32(prog.HighestBlock)
Expand Down
29 changes: 20 additions & 9 deletions client/asset/eth/eth_test.go
Expand Up @@ -407,10 +407,6 @@ func TestCheckForNewBlocks(t *testing.T) {
}

func TestSyncStatus(t *testing.T) {
fourthSyncProg := &ethereum.SyncProgress{
CurrentBlock: 25,
HighestBlock: 100,
}
tests := []struct {
name string
syncProg ethereum.SyncProgress
Expand All @@ -419,20 +415,35 @@ func TestSyncStatus(t *testing.T) {
wantErr, wantSynced bool
wantRatio float32
}{{
name: "ok synced",
name: "ok synced",
syncProg: ethereum.SyncProgress{
CurrentBlock: 25,
HighestBlock: 25,
},
wantRatio: 1,
wantSynced: true,
}, {
name: "ok syncing",
syncProg: *fourthSyncProg,
name: "ok syncing",
syncProg: ethereum.SyncProgress{
CurrentBlock: 25,
HighestBlock: 100,
},
wantRatio: 0.25,
}, {
name: "ok header too old",
name: "ok header too old",
syncProg: ethereum.SyncProgress{
CurrentBlock: 25,
HighestBlock: 25,
},
subSecs: dexeth.MaxBlockInterval + 1,
}, {
name: "best header error",
bestHdrErr: errors.New(""),
wantErr: true,
syncProg: ethereum.SyncProgress{
CurrentBlock: 25,
HighestBlock: 25,
},
wantErr: true,
}}

for _, test := range tests {
Expand Down