Skip to content

Commit

Permalink
Fix incorrect data on stagenet (#394)
Browse files Browse the repository at this point in the history
* Test on invoke with zero reissue added

* WIP: adding new test

* Recipient as Address handling fixed
  • Loading branch information
alexeykiselev authored Dec 2, 2020
1 parent 0352bcd commit 0ba3c16
Show file tree
Hide file tree
Showing 4 changed files with 485 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/proto/scripting.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,17 @@ func ValidateActions(actions []ScriptAction, restrictions ActionsValidationRestr
if otherActionsCount > maxScriptActions {
return errors.Errorf("number of actions produced by script is more than allowed %d", maxScriptActions)
}
if ta.Quantity <= 0 {
return errors.New("negative or zero quantity")
if ta.Quantity < 0 {
return errors.New("negative quantity")
}

case *BurnScriptAction:
otherActionsCount++
if otherActionsCount > maxScriptActions {
return errors.Errorf("number of actions produced by script is more than allowed %d", maxScriptActions)
}
if ta.Quantity <= 0 {
return errors.New("negative or zero quantity")
if ta.Quantity < 0 {
return errors.New("negative quantity")
}

case *SponsorshipScriptAction:
Expand Down
13 changes: 9 additions & 4 deletions pkg/ride/functions_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,17 @@ func addressToString(_ RideEnvironment, args ...rideType) (rideType, error) {
if err := checkArgs(args, 1); err != nil {
return nil, errors.Wrap(err, "addressToString")
}
a, ok := args[0].(rideAddress)
if !ok {
switch a := args[0].(type) {
case rideAddress:
return rideString(proto.Address(a).String()), nil
case rideRecipient:
if a.Address == nil {
return nil, errors.Errorf("addressToString: recipient is not an Address '%s'", args[0].instanceOf())
}
return rideString(a.Address.String()), nil
default:
return nil, errors.Errorf("addressToString: invalid argument type '%s'", args[0].instanceOf())
}
s := proto.Address(a).String()
return rideString(s), nil
}

func rsaVerify(_ RideEnvironment, args ...rideType) (rideType, error) {
Expand Down
9 changes: 8 additions & 1 deletion pkg/ride/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,14 @@ func (a rideAddressLike) get(prop string) (rideType, error) {
type rideRecipient proto.Recipient

func (a rideRecipient) instanceOf() string {
return "Recipient"
switch {
case a.Address != nil:
return "Address"
case a.Alias != nil:
return "Alias"
default:
return "Recipient"
}
}

func (a rideRecipient) eq(other rideType) bool {
Expand Down
464 changes: 464 additions & 0 deletions pkg/ride/tree_evaluation_test.go

Large diffs are not rendered by default.

0 comments on commit 0ba3c16

Please sign in to comment.