Skip to content

Commit

Permalink
add some checks to tenscan test
Browse files Browse the repository at this point in the history
  • Loading branch information
badgersrus committed Apr 24, 2024
1 parent 351a827 commit 3de0bdd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion go/host/storage/hostdb/rollup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package hostdb
import (
"database/sql"
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/rlp"
"github.com/pkg/errors"
"github.com/ten-protocol/go-ten/go/common"
"github.com/ten-protocol/go-ten/go/common/errutil"
"math/big"

gethcommon "github.com/ethereum/go-ethereum/common"
)
Expand Down
35 changes: 24 additions & 11 deletions integration/tenscan/tenscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,37 @@ func TestTenscan(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, batchlistingObj.Result.BatchesData[0].Header.Hash(), batchObj.Item.Header.Hash())

statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/info/obscuro/", serverAddress))
statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/items/rollups/?offset=0&size=10", serverAddress))
assert.NoError(t, err)
assert.Equal(t, 200, statusCode)

type configFetch struct {
Item common.ObscuroNetworkInfo `json:"item"`
type rollupListing struct {
Result common.RollupListingResponse `json:"result"`
}

//TODO DELETE ME
//Timer for running local tests
countdownDuration := 20 * time.Minute
tickDuration := 5 * time.Second
rollupListingObj := rollupListing{}
err = json.Unmarshal(body, &rollupListingObj)
assert.NoError(t, err)
assert.LessOrEqual(t, 4, len(rollupListingObj.Result.RollupsData))
assert.LessOrEqual(t, uint64(4), rollupListingObj.Result.Total)
assert.Contains(t, string(body), "\"hash\"")

for remaining := countdownDuration; remaining > 0; remaining -= tickDuration {
fmt.Printf("Shutting down in %s...\n", remaining)
time.Sleep(tickDuration)
statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/items/rollup/%s/batches", serverAddress, rollupListingObj.Result.RollupsData[0].Header.Hash()))
assert.NoError(t, err)
assert.Equal(t, 200, statusCode)

err = json.Unmarshal(body, &batchlistingObj)
assert.NoError(t, err)
// we should find batches given the rollup hash
assert.True(t, batchlistingObj.Result.Total > 0)

statusCode, body, err = fasthttp.Get(nil, fmt.Sprintf("%s/info/obscuro/", serverAddress))
assert.NoError(t, err)
assert.Equal(t, 200, statusCode)

type configFetch struct {
Item common.ObscuroNetworkInfo `json:"item"`
}
//TODO DELETE ME

configFetchObj := configFetch{}
err = json.Unmarshal(body, &configFetchObj)
Expand Down

0 comments on commit 3de0bdd

Please sign in to comment.