refactor: remove IsReceiver branch
This commit is contained in:
parent
49a94b7cba
commit
d607ca6118
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user