fix new panics in invoker_test.go
This commit is contained in:
parent
0202192fc0
commit
a968784908
@ -6,6 +6,8 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
@ -80,6 +82,30 @@ func (basicContract) InvokeSomething10(rt runtime2.Runtime, params *basicParams)
|
||||
return nil
|
||||
}
|
||||
|
||||
type basicRtMessage struct{}
|
||||
|
||||
var _ runtime2.Message = (*basicRtMessage)(nil)
|
||||
|
||||
func (*basicRtMessage) Caller() address.Address {
|
||||
a, err := address.NewIDAddress(0)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (*basicRtMessage) Receiver() address.Address {
|
||||
a, err := address.NewIDAddress(1)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func (*basicRtMessage) ValueReceived() abi.TokenAmount {
|
||||
return big.NewInt(0)
|
||||
}
|
||||
|
||||
func TestInvokerBasic(t *testing.T) {
|
||||
inv := ActorRegistry{}
|
||||
code, err := inv.transform(basicContract{})
|
||||
@ -89,7 +115,7 @@ func TestInvokerBasic(t *testing.T) {
|
||||
bParam, err := actors.SerializeParams(&basicParams{B: 1})
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, aerr := code[0](&Runtime{}, bParam)
|
||||
_, aerr := code[0](&Runtime{Message: &basicRtMessage{}}, bParam)
|
||||
|
||||
assert.Equal(t, exitcode.ExitCode(1), aerrors.RetCode(aerr), "return code should be 1")
|
||||
if aerrors.IsFatal(aerr) {
|
||||
@ -101,7 +127,7 @@ func TestInvokerBasic(t *testing.T) {
|
||||
bParam, err := actors.SerializeParams(&basicParams{B: 2})
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, aerr := code[10](&Runtime{}, bParam)
|
||||
_, aerr := code[10](&Runtime{Message: &basicRtMessage{}}, bParam)
|
||||
assert.Equal(t, exitcode.ExitCode(12), aerrors.RetCode(aerr), "return code should be 12")
|
||||
if aerrors.IsFatal(aerr) {
|
||||
t.Fatal("err should not be fatal")
|
||||
@ -113,6 +139,7 @@ func TestInvokerBasic(t *testing.T) {
|
||||
vm: &VM{ntwkVersion: func(ctx context.Context, epoch abi.ChainEpoch) network.Version {
|
||||
return network.Version0
|
||||
}},
|
||||
Message: &basicRtMessage{},
|
||||
}, []byte{99})
|
||||
if aerrors.IsFatal(aerr) {
|
||||
t.Fatal("err should not be fatal")
|
||||
@ -125,6 +152,7 @@ func TestInvokerBasic(t *testing.T) {
|
||||
vm: &VM{ntwkVersion: func(ctx context.Context, epoch abi.ChainEpoch) network.Version {
|
||||
return network.Version7
|
||||
}},
|
||||
Message: &basicRtMessage{},
|
||||
}, []byte{99})
|
||||
if aerrors.IsFatal(aerr) {
|
||||
t.Fatal("err should not be fatal")
|
||||
|
Loading…
Reference in New Issue
Block a user