refactor: remove IsReceiver branch

This commit is contained in:
Alan Shaw 2020-09-15 14:56:58 +01:00
parent 49a94b7cba
commit d607ca6118
No known key found for this signature in database
GPG Key ID: 731D1C308A48A6B9
2 changed files with 0 additions and 26 deletions

View File

@ -35,8 +35,6 @@ const (
CallerValidationBranchTwice
// CallerValidationBranchIs causes caller validation against CallerValidationArgs.Addrs.
CallerValidationBranchIs
// CallerValidationBranchIsReceiver causes validation that the caller was also the receiver.
CallerValidationBranchIsReceiver
// CallerValidationBranchType causes caller validation against CallerValidationArgs.Types.
CallerValidationBranchType
)
@ -148,8 +146,6 @@ func (a Actor) CallerValidation(rt runtime.Runtime, args *CallerValidationArgs)
rt.ValidateImmediateCallerAcceptAny()
case CallerValidationBranchIs:
rt.ValidateImmediateCallerIs(args.Addrs...)
case CallerValidationBranchIsReceiver:
rt.ValidateImmediateCallerIs(rt.Message().Receiver())
case CallerValidationBranchType:
rt.ValidateImmediateCallerType(args.Types...)
default:

View File

@ -67,28 +67,6 @@ func TestCallerValidationIs(t *testing.T) {
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) {
caller := atesting.NewIDAddr(t, 100)
receiver := atesting.NewIDAddr(t, 101)