2022-08-29 14:25:30 +00:00
|
|
|
// stm: ignore
|
|
|
|
// Only tests external library behavior, therefore it should not be annotated
|
2020-04-15 14:13:20 +00:00
|
|
|
package drand
|
|
|
|
|
|
|
|
import (
|
2020-05-27 12:09:04 +00:00
|
|
|
"os"
|
2020-04-15 14:13:20 +00:00
|
|
|
"testing"
|
2020-05-22 14:07:38 +00:00
|
|
|
|
|
|
|
dchain "github.com/drand/drand/chain"
|
2020-06-10 18:17:03 +00:00
|
|
|
hclient "github.com/drand/drand/client/http"
|
2020-05-22 14:07:38 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-06-23 19:56:03 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
|
2020-06-23 19:56:03 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2020-04-15 14:13:20 +00:00
|
|
|
)
|
|
|
|
|
2020-05-22 14:07:38 +00:00
|
|
|
func TestPrintGroupInfo(t *testing.T) {
|
2020-10-01 09:02:57 +00:00
|
|
|
server := build.DrandConfigs[build.DrandDevnet].Servers[0]
|
2020-06-23 19:56:03 +00:00
|
|
|
c, err := hclient.New(server, nil, nil)
|
2020-05-22 14:07:38 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
cg := c.(interface {
|
|
|
|
FetchChainInfo(groupHash []byte) (*dchain.Info, error)
|
|
|
|
})
|
|
|
|
chain, err := cg.FetchChainInfo(nil)
|
|
|
|
assert.NoError(t, err)
|
2023-03-08 04:24:48 +00:00
|
|
|
err = chain.ToJSON(os.Stdout, nil)
|
2020-05-22 14:07:38 +00:00
|
|
|
assert.NoError(t, err)
|
2020-04-15 14:13:20 +00:00
|
|
|
}
|
2021-09-27 01:23:41 +00:00
|
|
|
|
|
|
|
func TestMaxBeaconRoundForEpoch(t *testing.T) {
|
|
|
|
todayTs := uint64(1652222222)
|
|
|
|
db, err := NewDrandBeacon(todayTs, build.BlockDelaySecs, nil, build.DrandConfigs[build.DrandDevnet])
|
|
|
|
assert.NoError(t, err)
|
|
|
|
mbr15 := db.MaxBeaconRoundForEpoch(network.Version15, 100)
|
|
|
|
mbr16 := db.MaxBeaconRoundForEpoch(network.Version16, 100)
|
|
|
|
assert.Equal(t, mbr15+1, mbr16)
|
|
|
|
}
|