2020-10-07 11:45:11 +00:00
|
|
|
package conformance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-12-17 05:58:20 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
|
|
|
|
2020-10-07 11:45:11 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/lotus/chain/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type fixedRand struct{}
|
|
|
|
|
|
|
|
var _ vm.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() vm.Rand {
|
|
|
|
return &fixedRand{}
|
|
|
|
}
|
|
|
|
|
2021-12-17 05:58:20 +00:00
|
|
|
func (r *fixedRand) GetChainRandomness(_ context.Context, _ network.Version, _ crypto.DomainSeparationTag, _ abi.ChainEpoch, _ []byte) ([]byte, error) {
|
2021-09-18 17:57:04 +00:00
|
|
|
return []byte("i_am_random_____i_am_random_____"), nil // 32 bytes.
|
|
|
|
}
|
|
|
|
|
2021-12-17 05:58:20 +00:00
|
|
|
func (r *fixedRand) GetBeaconRandomness(_ context.Context, _ network.Version, _ crypto.DomainSeparationTag, _ abi.ChainEpoch, _ []byte) ([]byte, error) {
|
2020-10-07 11:45:11 +00:00
|
|
|
return []byte("i_am_random_____i_am_random_____"), nil // 32 bytes.
|
|
|
|
}
|