refactor: remove IsReceiver branch
This commit is contained in:
parent
49a94b7cba
commit
d607ca6118
@ -35,8 +35,6 @@ const (
|
|||||||
CallerValidationBranchTwice
|
CallerValidationBranchTwice
|
||||||
// CallerValidationBranchIs causes caller validation against CallerValidationArgs.Addrs.
|
// CallerValidationBranchIs causes caller validation against CallerValidationArgs.Addrs.
|
||||||
CallerValidationBranchIs
|
CallerValidationBranchIs
|
||||||
// CallerValidationBranchIsReceiver causes validation that the caller was also the receiver.
|
|
||||||
CallerValidationBranchIsReceiver
|
|
||||||
// CallerValidationBranchType causes caller validation against CallerValidationArgs.Types.
|
// CallerValidationBranchType causes caller validation against CallerValidationArgs.Types.
|
||||||
CallerValidationBranchType
|
CallerValidationBranchType
|
||||||
)
|
)
|
||||||
@ -148,8 +146,6 @@ func (a Actor) CallerValidation(rt runtime.Runtime, args *CallerValidationArgs)
|
|||||||
rt.ValidateImmediateCallerAcceptAny()
|
rt.ValidateImmediateCallerAcceptAny()
|
||||||
case CallerValidationBranchIs:
|
case CallerValidationBranchIs:
|
||||||
rt.ValidateImmediateCallerIs(args.Addrs...)
|
rt.ValidateImmediateCallerIs(args.Addrs...)
|
||||||
case CallerValidationBranchIsReceiver:
|
|
||||||
rt.ValidateImmediateCallerIs(rt.Message().Receiver())
|
|
||||||
case CallerValidationBranchType:
|
case CallerValidationBranchType:
|
||||||
rt.ValidateImmediateCallerType(args.Types...)
|
rt.ValidateImmediateCallerType(args.Types...)
|
||||||
default:
|
default:
|
||||||
|
@ -67,28 +67,6 @@ func TestCallerValidationIs(t *testing.T) {
|
|||||||
rt.Verify()
|
rt.Verify()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCallerValidationIsReceiver(t *testing.T) {
|
|
||||||
caller := atesting.NewIDAddr(t, 100)
|
|
||||||
receiver := atesting.NewIDAddr(t, 101)
|
|
||||||
builder := mock.NewBuilder(context.Background(), receiver)
|
|
||||||
|
|
||||||
rt := builder.Build(t)
|
|
||||||
var a Actor
|
|
||||||
|
|
||||||
rt.SetCaller(caller, builtin.AccountActorCodeID)
|
|
||||||
rt.ExpectValidateCallerAddr(receiver)
|
|
||||||
// FIXME: https://github.com/filecoin-project/specs-actors/pull/1155
|
|
||||||
rt.ExpectAbort(exitcode.ErrForbidden, func() {
|
|
||||||
rt.Call(a.CallerValidation, &CallerValidationArgs{Branch: CallerValidationBranchIsReceiver})
|
|
||||||
})
|
|
||||||
rt.Verify()
|
|
||||||
|
|
||||||
rt.SetCaller(receiver, builtin.AccountActorCodeID)
|
|
||||||
rt.ExpectValidateCallerAddr(receiver)
|
|
||||||
rt.Call(a.CallerValidation, &CallerValidationArgs{Branch: CallerValidationBranchIsReceiver})
|
|
||||||
rt.Verify()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCallerValidationType(t *testing.T) {
|
func TestCallerValidationType(t *testing.T) {
|
||||||
caller := atesting.NewIDAddr(t, 100)
|
caller := atesting.NewIDAddr(t, 100)
|
||||||
receiver := atesting.NewIDAddr(t, 101)
|
receiver := atesting.NewIDAddr(t, 101)
|
||||||
|
Loading…
Reference in New Issue
Block a user