lite2: remove expiration checks on functions that don't require them (#4477)

closes: #4455

Verifying backwards checks that the trustedHeader hasn't expired both before and after the loop in case of verifying many headers (a longer operation), but not during the loop itself.

TrustedHeader() no longer checks whether the header saved in the store has expired.

Tests have been updated to reflect the changes

## Commits:

* verify headers backwards out of trust period

* removed expiration check in trusted header func

* modified tests to reflect changes

* wrote new tests for backwards verification

* modified TrustedHeader and TrustedValSet functions

* condensed test functions

* condensed test functions further

* fix build error

* update doc

* add comments

* remove unnecessary declaration

* extract latestHeight check into a separate func

Co-authored-by: Callum Waters <cmwaters19@gmail.com>
This commit is contained in:
Anton Kaliaev
2020-02-26 16:15:06 +01:00
committed by GitHub
parent 9231b52e0d
commit 6daea31f50
5 changed files with 202 additions and 176 deletions

View File

@@ -76,7 +76,7 @@ func TestExample_Client_AutoUpdate(t *testing.T) {
time.Sleep(2 * time.Second)
h, err := c.TrustedHeader(0, time.Now())
h, err := c.TrustedHeader(0)
if err != nil {
stdlog.Fatal(err)
}
@@ -146,7 +146,7 @@ func TestExample_Client_ManualUpdate(t *testing.T) {
stdlog.Fatal(err)
}
h, err := c.TrustedHeader(3, time.Now())
h, err := c.TrustedHeader(3)
if err != nil {
stdlog.Fatal(err)
}