lotus/conformance/rand_fixed.go
Andrew Jackson (Ajax) a520ee85d6 master-to-sturdy
2023-09-21 10:37:02 -05:00

28 lines
745 B
Go

package conformance
import (
"context"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/rand"
)
type fixedRand struct{}
var _ rand.Rand = (*fixedRand)(nil)
// NewFixedRand creates a test vm.Rand that always returns fixed bytes value
// of utf-8 string 'i_am_random_____i_am_random_____'.
func NewFixedRand() rand.Rand {
return &fixedRand{}
}
func (r *fixedRand) GetChainRandomness(_ context.Context, _ abi.ChainEpoch) ([32]byte, error) {
return *(*[32]byte)([]byte("i_am_random_____i_am_random_____")), nil
}
func (r *fixedRand) GetBeaconRandomness(_ context.Context, _ abi.ChainEpoch) ([32]byte, error) {
return *(*[32]byte)([]byte("i_am_random_____i_am_random_____")), nil // 32 bytes.
}