Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fsm/message_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func (x *MessageEditOrder) Check() lib.ErrorI {
if len(x.Data) > 100 {
return ErrInvalidOpcode()
}
if x.AmountForSale == 0 || x.RequestedAmount == 0 {
if x.AmountForSale == 0 {
return ErrInvalidAmount()
}
return checkExternalAddress(x.SellerReceiveAddress)
Expand Down
17 changes: 17 additions & 0 deletions fsm/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,17 @@ func TestCheckMessage(t *testing.T) {
// convert the message to 'any' for transaction wrapping
msgSendAny, e := lib.NewAny(sendMsg)
require.NoError(t, e)
// predefine an edit-order message that leaves requested amount at zero
editOrderMsg := &MessageEditOrder{
OrderId: newTestOrderId(t, 0),
ChainId: lib.CanopyChainId,
AmountForSale: 1,
RequestedAmount: 0,
SellerReceiveAddress: newTestAddressBytes(t),
}
// convert the message to 'any' for transaction wrapping
msgEditOrderAny, e := lib.NewAny(editOrderMsg)
require.NoError(t, e)
tests := []struct {
name string
detail string
Expand Down Expand Up @@ -746,6 +757,12 @@ func TestCheckMessage(t *testing.T) {
msg: msgSendAny,
expected: sendMsg,
},
{
name: "valid edit order keeps requested amount zero",
detail: "an edit order may keep the requested amount at zero",
msg: msgEditOrderAny,
expected: editOrderMsg,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down