That was fixed in granadanet by this merge request: https://gitlab.com/tezos/tezos/-/merge_requests/2815
You need to add self.add_flag("initial-cast") in the contract constructor to solve the issue until mainnet adopts the new protocol.
Doing math on nats casts them to an int. The value needs to be casted back to a nat after the subtraction:
self.data.shop_items[item_to_purchase.key].amount = sp.as_nat(self.data.shop_items[item_to_purchase.key].amount - item_to_purchase.value)
SmartPy test interpreter already handles internal operations failures really well.
Here is an example: https://smartpy.io/ide?cid=QmV3nwdkwHGXdJbWwV8LDgm3TPbC49Es7Wm6GufMeh8Pz2&k=184987b7b8089b73396a
Please, don't provide incomplete examples. I always find myself wasting tremendous amounts of time just to put those examples to work.
It is not possible to cast an int to a string in Michelson.
I recommend you to have static error messages, such as:
SOME_ERROR = "SOME_ERROR"
# some contract
x_i = (sp.to_int(params.x + I))
y_j = (sp.to_int(params.y + j))
SmartPy also gives you the option to ...
Both transactions sent from your address have the same fee 0.01 tez that is not enough, taking into account the gas limit 50000. Try to set the fee 0.015 tez. If this doesn't help, it also can be a problem with the node you use, so try to use another one, like Tezos Giga Node.
And yes, operations stay in the mempool for only an hour, however TzKT explorer ...
Don't worry, your funds are safe. You need to wait a bit and then try again with a higher fee or lower gas_limit.
Why did that happen?
You sent a transaction with large gas_limit: 50000 (despite a simple tz-to-tz transfer consumes about 1427 gas) and rather small, for such gas limit, fee:10000. So no one baker picked your transaction to include into a block ...