lotus/chain/vm/runtime_test.go
Steven Allen 32eeb96ce7 Update to specs-actors 0.9.9
This patch changes the runtime interfaces, to make it possible to abstract over them.
2020-09-14 12:47:39 -07:00

48 lines
918 B
Go

package vm
import (
"io"
"testing"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/exitcode"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
)
type NotAVeryGoodMarshaler struct{}
func (*NotAVeryGoodMarshaler) MarshalCBOR(writer io.Writer) error {
return xerrors.Errorf("no")
}
var _ cbg.CBORMarshaler = &NotAVeryGoodMarshaler{}
func TestRuntimePutErrors(t *testing.T) {
defer func() {
err := recover()
if err == nil {
t.Fatal("expected non-nil recovery")
}
aerr := err.(aerrors.ActorError)
if aerr.IsFatal() {
t.Fatal("expected non-fatal actor error")
}
if aerr.RetCode() != exitcode.ErrSerialization {
t.Fatal("expected serialization error")
}
}()
rt := Runtime{
cst: cbor.NewCborStore(nil),
}
rt.StorePut(&NotAVeryGoodMarshaler{})
t.Error("expected panic")
}