lotus/conformance/rand_fixed.go

28 lines
745 B
Go
Raw Permalink Normal View History

2020-10-07 11:45:11 +00:00
package conformance
import (
"context"
"github.com/filecoin-project/go-state-types/abi"
2023-08-22 15:14:17 +00:00
"github.com/filecoin-project/lotus/chain/rand"
2020-10-07 11:45:11 +00:00
)
type fixedRand struct{}
2023-08-22 15:14:17 +00:00
var _ rand.Rand = (*fixedRand)(nil)
2020-10-07 11:45:11 +00:00
// NewFixedRand creates a test vm.Rand that always returns fixed bytes value
// of utf-8 string 'i_am_random_____i_am_random_____'.
2023-08-22 15:14:17 +00:00
func NewFixedRand() rand.Rand {
2020-10-07 11:45:11 +00:00
return &fixedRand{}
}
func (r *fixedRand) GetChainRandomness(_ context.Context, _ abi.ChainEpoch) ([32]byte, error) {
return *(*[32]byte)([]byte("i_am_random_____i_am_random_____")), nil
2021-09-18 17:57:04 +00:00
}
func (r *fixedRand) GetBeaconRandomness(_ context.Context, _ abi.ChainEpoch) ([32]byte, error) {
return *(*[32]byte)([]byte("i_am_random_____i_am_random_____")), nil // 32 bytes.
2020-10-07 11:45:11 +00:00
}