Skip to content

Commit

Permalink
client/testing: Make simnet tests modular.
Browse files Browse the repository at this point in the history
Change the simnet harness tests to work with all currently supported
assets.
  • Loading branch information
JoeGruffins committed May 12, 2022
1 parent 9fd4054 commit 34538e7
Show file tree
Hide file tree
Showing 4 changed files with 399 additions and 171 deletions.
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

0 comments on commit 34538e7

Please sign in to comment.