diff --git a/conformance/chaos/actor.go b/conformance/chaos/actor.go index f162b2c8f..3792a4bfe 100644 --- a/conformance/chaos/actor.go +++ b/conformance/chaos/actor.go @@ -77,7 +77,7 @@ func (a Actor) Exports() []interface{} { MethodDeleteActor: a.DeleteActor, MethodSend: a.Send, MethodMutateState: a.MutateState, - MethodAbort: a.Abort, + MethodAbort: a.AbortWith, } } @@ -235,17 +235,17 @@ func (a Actor) MutateState(rt runtime.Runtime, args *MutateStateArgs) *adt.Empty return nil } -// AbortArgs are the arguments to the abort method, specifying the exit code to -// (optionally) abort with and the message. -type AbortArgs struct { - Code exitcode.ExitCode - NoCode bool - Message string +// AbortWithArgs are the arguments to the Actor.AbortWith method, specifying the +// exit code to (optionally) abort with and the message. +type AbortWithArgs struct { + Code exitcode.ExitCode + Message string + Uncontrolled bool } -// Abort simply causes a panic or abort with the passed exit code. -func (a Actor) Abort(rt runtime.Runtime, args *AbortArgs) *adt.EmptyValue { - if args.NoCode { // no code, just plain old panic +// AbortWith simply causes a panic with the passed exit code. +func (a Actor) AbortWith(rt runtime.Runtime, args *AbortWithArgs) *adt.EmptyValue { + if args.Uncontrolled { // uncontrolled abort: directly panic panic(args.Message) } else { rt.Abortf(args.Code, args.Message) diff --git a/conformance/chaos/cbor_gen.go b/conformance/chaos/cbor_gen.go index 00825c8f3..710b84b93 100644 --- a/conformance/chaos/cbor_gen.go +++ b/conformance/chaos/cbor_gen.go @@ -615,14 +615,14 @@ func (t *MutateStateArgs) UnmarshalCBOR(r io.Reader) error { return nil } -var lengthBufAbortArgs = []byte{131} +var lengthBufAbortWithArgs = []byte{131} -func (t *AbortArgs) MarshalCBOR(w io.Writer) error { +func (t *AbortWithArgs) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write(lengthBufAbortArgs); err != nil { + if _, err := w.Write(lengthBufAbortWithArgs); err != nil { return err } @@ -639,11 +639,6 @@ func (t *AbortArgs) MarshalCBOR(w io.Writer) error { } } - // t.NoCode (bool) (bool) - if err := cbg.WriteBool(w, t.NoCode); err != nil { - return err - } - // t.Message (string) (string) if len(t.Message) > cbg.MaxLength { return xerrors.Errorf("Value in field t.Message was too long") @@ -655,11 +650,16 @@ func (t *AbortArgs) MarshalCBOR(w io.Writer) error { if _, err := io.WriteString(w, string(t.Message)); err != nil { return err } + + // t.Uncontrolled (bool) (bool) + if err := cbg.WriteBool(w, t.Uncontrolled); err != nil { + return err + } return nil } -func (t *AbortArgs) UnmarshalCBOR(r io.Reader) error { - *t = AbortArgs{} +func (t *AbortWithArgs) UnmarshalCBOR(r io.Reader) error { + *t = AbortWithArgs{} br := cbg.GetPeeker(r) scratch := make([]byte, 8) @@ -701,23 +701,6 @@ func (t *AbortArgs) UnmarshalCBOR(r io.Reader) error { t.Code = exitcode.ExitCode(extraI) } - // t.NoCode (bool) (bool) - - maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) - if err != nil { - return err - } - if maj != cbg.MajOther { - return fmt.Errorf("booleans must be major type 7") - } - switch extra { - case 20: - t.NoCode = false - case 21: - t.NoCode = true - default: - return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) - } // t.Message (string) (string) { @@ -728,5 +711,22 @@ func (t *AbortArgs) UnmarshalCBOR(r io.Reader) error { t.Message = string(sval) } + // t.Uncontrolled (bool) (bool) + + maj, extra, err = cbg.CborReadHeaderBuf(br, scratch) + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.Uncontrolled = false + case 21: + t.Uncontrolled = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + } return nil } diff --git a/conformance/chaos/gen/gen.go b/conformance/chaos/gen/gen.go index dbf8463d4..97ea98dc8 100644 --- a/conformance/chaos/gen/gen.go +++ b/conformance/chaos/gen/gen.go @@ -14,7 +14,7 @@ func main() { chaos.SendArgs{}, chaos.SendReturn{}, chaos.MutateStateArgs{}, - chaos.AbortArgs{}, + chaos.AbortWithArgs{}, ); err != nil { panic(err) }