VDB-120 include tic in dent and tend (#118)

* Add constants for TTL and tic for fakeHeader

* Add tic to tend transformer

* Update tests for tend

* Fix string conversion bug in fakes

* Fix tend integration tests after staging rebase

* Add tic to dent transformer

* Update dent tests

* Change integration tests to use hardcoded block timestamp
This commit is contained in:
Edvard Hübinette
2018-11-15 12:57:29 +01:00
committed by GitHub
parent 8f4648a9e3
commit 40408e8300
15 changed files with 86 additions and 35 deletions
@@ -1,3 +1,6 @@
package constants
var DataItemLength = 32
// TODO Grab this from DB, since it can change through governance
var TTL = int64(10800) // 60 * 60 * 3 == 10800 seconds == 3 hours
+13
View File
@@ -15,6 +15,7 @@
package shared
import (
"database/sql"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"math/big"
)
@@ -78,3 +79,15 @@ func convert(conversion string, value string, precision int) string {
}
return result.Text('f', precision)
}
// Grabs the block timestamp for an headerID, and adds the TTL constant
func GetTicInTx(headerID int64, tx *sql.Tx) (int64, error) {
var blockTimestamp int64
err := tx.QueryRow(`SELECT block_timestamp FROM public.headers WHERE id = $1;`, headerID).Scan(&blockTimestamp)
if err != nil {
return 0, err
}
tic := blockTimestamp + constants.TTL
return tic, nil
}