lite2: add Start, TrustedValidatorSet funcs (#4337)

* lite2: add Start method

There are few reasons to do that:

1) separation of state and dynamics (some users will want to delay
   starting the light client; does not matter we should not allow them
   to create a light client object)
2) less important, but some users might not need autoUpdateRoutine and
   removeNoLongerTrustedHeadersRoutine routines

* lite2: wait till routines are finished in Stop

because they are started in Start, it feels more natural to wait for
them to finish in Stop.

* lite2: add TrustedValidatorSet func
This commit is contained in:
Anton Kaliaev
2020-01-27 19:49:04 +04:00
committed by GitHub
parent 48be9bcb09
commit 59a922d38a
3 changed files with 96 additions and 17 deletions

View File

@@ -63,6 +63,10 @@ func TestExample_Client_AutoUpdate(t *testing.T) {
if err != nil {
stdlog.Fatal(err)
}
err = c.Start()
if err != nil {
stdlog.Fatal(err)
}
defer func() {
c.Stop()
c.Cleanup()
@@ -125,6 +129,10 @@ func TestExample_Client_ManualUpdate(t *testing.T) {
if err != nil {
stdlog.Fatal(err)
}
err = c.Start()
if err != nil {
stdlog.Fatal(err)
}
defer func() {
c.Stop()
c.Cleanup()